Esempio n. 1
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++;
     }
 }
Esempio n. 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 = Money::stringToUnits((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));
         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->NtryDtls->Btch->PmtInfId) && (string) $entryXml->NtryDtls->Btch->PmtInfId) {
             $entry->setBatchPaymentId((string) $entryXml->NtryDtls->Btch->PmtInfId);
         }
         $this->addTransactionDetailsToEntry($entryXml, $entry);
         $statement->addEntry($entry);
         $index++;
     }
 }