Esempio n. 1
0
 /**
  * @param DTO\Record       $record
  * @param SimpleXMLElement $xmlRecord
  */
 public function addEntries(DTO\Record $record, SimpleXMLElement $xmlRecord)
 {
     $index = 0;
     $xmlEntries = $xmlRecord->Ntry;
     foreach ($xmlEntries as $xmlEntry) {
         $amount = StringToUnits::convert((string) $xmlEntry->Amt);
         $currency = (string) $xmlEntry->Amt['Ccy'];
         $bookingDate = (string) $xmlEntry->BookgDt->Dt ?: (string) $xmlEntry->BookgDt->DtTm;
         $valueDate = (string) $xmlEntry->ValDt->Dt ?: (string) $xmlEntry->ValDt->DtTm;
         $additionalInfo = (string) $xmlEntry->AddtlNtryInf ?: (string) $xmlEntry->AddtlNtryInf;
         if ((string) $xmlEntry->CdtDbtInd === 'DBIT') {
             $amount = $amount * -1;
         }
         $entry = new DTO\Entry($record, $index, new Money($amount, new Currency($currency)), new DateTimeImmutable($bookingDate), new DateTimeImmutable($valueDate), $additionalInfo);
         if (isset($xmlEntry->RvslInd) && (string) $xmlEntry->RvslInd === 'true') {
             $entry->setReversalIndicator(true);
         }
         if (isset($xmlEntry->NtryRef) && (string) $xmlEntry->NtryRef) {
             $entry->setReference((string) $xmlEntry->NtryRef);
         }
         if (isset($xmlEntry->AcctSvcrRef) && (string) $xmlEntry->AcctSvcrRef) {
             $entry->setAccountServicerReference((string) $xmlEntry->AcctSvcrRef);
         }
         if (isset($xmlEntry->NtryDtls->Btch->PmtInfId) && (string) $xmlEntry->NtryDtls->Btch->PmtInfId) {
             $entry->setBatchPaymentId((string) $xmlEntry->NtryDtls->Btch->PmtInfId);
         }
         if (isset($xmlEntry->NtryDtls->TxDtls->Refs->PmtInfId) && (string) $xmlEntry->NtryDtls->TxDtls->Refs->PmtInfId) {
             $entry->setBatchPaymentId((string) $xmlEntry->NtryDtls->TxDtls->Refs->PmtInfId);
         }
         if (isset($xmlEntry->BkTxCd)) {
             $bankTransactionCode = new DTO\BankTransactionCode();
             if (isset($xmlEntry->BkTxCd->Prtry)) {
                 $proprietaryBankTransactionCode = new DTO\ProprietaryBankTransactionCode((string) $xmlEntry->BkTxCd->Prtry->Cd, (string) $xmlEntry->BkTxCd->Prtry->Issr);
                 $bankTransactionCode->setProprietary($proprietaryBankTransactionCode);
             }
             $entry->setBankTransactionCode($bankTransactionCode);
         }
         $this->entryDecoder->addTransactionDetails($entry, $xmlEntry);
         $record->addEntry($entry);
         $index++;
     }
 }
Esempio n. 2
0
 /**
  * @param DTO\EntryTransactionDetail $detail
  * @param SimpleXMLElement           $xmlDetail
  */
 public function addBankTransactionCode(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail)
 {
     $bankTransactionCode = new DTO\BankTransactionCode();
     if (isset($xmlDetail->BkTxCd)) {
         $bankTransactionCode = new DTO\BankTransactionCode();
         if (isset($xmlDetail->BkTxCd->Prtry)) {
             $proprietaryBankTransactionCode = new DTO\ProprietaryBankTransactionCode((string) $xmlDetail->BkTxCd->Prtry->Cd, (string) $xmlDetail->BkTxCd->Prtry->Issr);
             $bankTransactionCode->setProprietary($proprietaryBankTransactionCode);
         }
     }
     $detail->setBankTransactionCode($bankTransactionCode);
 }