예제 #1
0
 /**
  * Get the direct deposit account related value based on
  * passed parameters
  *
  * @param array $row Array of data from database
  * @param array $ddList Array of direct deposit objects of this employee
  *
  * @return string Value for this field from database
  */
 private function _getDDValue($row, $ddList)
 {
     $value = '';
     $parts = explode('_', $this->name);
     if (count($parts) == 2) {
         $ddNum = str_replace('DD', '', $parts[0]);
         $ddField = $parts[1];
         if (intval($ddNum) > 0) {
             if (count($ddList) >= $ddNum) {
                 $directDeposit = $ddList[$ddNum - 1];
                 switch ($ddField) {
                     case CustomizableCSVExport::DD_ROUTING:
                         $value = $directDeposit->getRoutingNumber();
                         break;
                     case CustomizableCSVExport::DD_ACCOUNT:
                         $value = $directDeposit->getAccount();
                         break;
                     case CustomizableCSVExport::DD_AMOUNT:
                         $value = $directDeposit->getAmount();
                         break;
                     case CustomizableCSVExport::DD_AMOUNTCODE:
                         $transactionTypes = array(EmpDirectDebit::TRANSACTION_TYPE_BLANK => 'Blank', EmpDirectDebit::TRANSACTION_TYPE_PERCENTAGE => '%', EmpDirectDebit::TRANSACTION_TYPE_FLAT => 'Flat', EmpDirectDebit::TRANSACTION_TYPE_FLAT_MINUS => 'Flat-');
                         $value = CSVField::getValueFromMap($transactionTypes, $directDeposit->getTransactionType());
                         break;
                     case CustomizableCSVExport::DD_CHECKING:
                         $accountTypes = array(EmpDirectDebit::ACCOUNT_TYPE_CHECKING => "Y", EmpDirectDebit::ACCOUNT_TYPE_SAVINGS => "");
                         $value = CSVField::getValueFromMap($accountTypes, $directDeposit->getAccountType());
                         break;
                     default:
                         throw new Exception("Invalid direct deposit field");
                 }
             }
         } else {
             throw new Exception("Invalid Direct deposit field number");
         }
     } else {
         throw Exception("Invalid Direct Deposit field definition");
     }
     return $value;
 }
예제 #2
0
 /** Test getValueFromMap() function */
 public function testGetValueFromMap()
 {
     $map = array('xyz' => 'Value 1', 'abc' => 'V2', 'def' => 'Value 3', 't' => 'Xyz');
     // unknown value
     $this->assertEquals("", CSVField::getValueFromMap($map, 'hello'));
     // known values
     $this->assertEquals('Value 1', CSVField::getValueFromMap($map, 'xyz'));
     $this->assertEquals('V2', CSVField::getValueFromMap($map, 'abc'));
     $this->assertEquals('Value 3', CSVField::getValueFromMap($map, 'def'));
     $this->assertEquals('Xyz', CSVField::getValueFromMap($map, 't'));
 }