Exemple #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++;
     }
 }
Exemple #2
0
 /**
  * @param SimpleXMLElement $statementXml
  * @param Statement $statement
  */
 private function addEntriesToStatement(SimpleXMLElement $statementXml, Statement $statement)
 {
     $index = 0;
     $entriesXml = $statementXml->Ntry;
     foreach ($entriesXml as $entryXml) {
         $amount = StringToUnits::convert((string) $entryXml->Amt);
         $currency = (string) $entryXml->Amt['Ccy'];
         $bookingDate = (string) $entryXml->BookgDt->Dt;
         $valueDate = (string) $entryXml->ValDt->Dt;
         if ((string) $entryXml->CdtDbtInd === 'DBIT') {
             $amount = $amount * -1;
         }
         $entry = new Entry($statement, $index, new Money($amount, new Currency($currency)), new DateTimeImmutable($bookingDate), new DateTimeImmutable($valueDate), BankTransactionCode::fromUnstructured($entryXml->BkTxCd));
         if (isset($entryXml->RvslInd) && (string) $entryXml->RvslInd === 'true') {
             $entry->setReversalIndicator(true);
         }
         if (isset($entryXml->NtryRef) && (string) $entryXml->NtryRef) {
             $entry->setReference((string) $entryXml->NtryRef);
         }
         if (isset($entryXml->AcctSvcrRef) && (string) $entryXml->AcctSvcrRef) {
             $entry->setAccountServicerReference((string) $entryXml->AcctSvcrRef);
         }
         if (isset($entryXml->NtryDtls->Btch->PmtInfId) && (string) $entryXml->NtryDtls->Btch->PmtInfId) {
             $entry->setBatchPaymentId((string) $entryXml->NtryDtls->Btch->PmtInfId);
         }
         if (isset($entryXml->AddtlInfInd->MsgNmId) && (string) $entryXml->AddtlInfInd->MsgNmId) {
             $entry->setMessageNameIdentification((string) $entryXml->AddtlInfInd->MsgNmId);
         }
         $this->addTransactionDetailsToEntry($entryXml, $entry);
         $statement->addEntry($entry);
         $index++;
     }
 }
Exemple #3
0
 public function testFiveDecimals()
 {
     $this->assertEquals('1815', StringToUnits::convert('18.15000'));
 }
 /**
  * @param DTO\EntryTransactionDetail $detail
  * @param SimpleXMLElement           $xmlDetail
  * @param SimpleXMLElement           $CdtDbtInd
  */
 public function addAmountDetails(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail, $CdtDbtInd)
 {
     if (isset($xmlDetail->AmtDtls)) {
         $amountDetails = new DTO\AmountDetails();
         if (isset($xmlDetail->AmtDtls->TxAmt) && isset($xmlDetail->AmtDtls->TxAmt->Amt)) {
             $amount = StringToUnits::convert((string) $xmlDetail->AmtDtls->TxAmt->Amt);
             if ((string) $CdtDbtInd === 'DBIT') {
                 $amount = $amount * -1;
             }
             $money = new Money($amount, new Currency((string) $xmlDetail->AmtDtls->TxAmt->Amt['Ccy']));
             $amountDetails->setAmount($money);
         }
         $detail->setAmountDetails($amountDetails);
     }
 }