Exemple #1
0
 /**
  * @param SimpleXMLElement $entryXml
  * @param Entry $entry
  */
 private function addTransactionDetailsToEntry(SimpleXMLElement $entryXml, Entry $entry)
 {
     $detailsXml = $entryXml->NtryDtls->TxDtls;
     if ($detailsXml) {
         foreach ($detailsXml as $detailXml) {
             $detail = new EntryTransactionDetail();
             $this->addReferencesToTransactionDetails($detailXml, $detail);
             $this->addRelatedPartiesToTransactionDetails($detailXml, $detail);
             $this->addRemittanceInformationToTransactionDetails($detailXml, $detail);
             $this->addReturnInformationToTransactionDetails($detailXml, $detail);
             $this->addAdditionalTransactionInformation($detailXml, $detail);
             $entry->addTransactionDetail($detail);
         }
     }
 }
Exemple #2
0
 private function addRelatedAgentsToTransactionDetails(SimpleXMLElement $detailXml, EntryTransactionDetail $detail, Entry $entry)
 {
     if (isset($detailXml->RltdAgts)) {
         foreach ($detailXml->RltdAgts as $relatedAgentXml) {
             if ($entry->isDebit() && isset($relatedAgentXml->CdtrAgt)) {
                 $relatedFinancialInstitution = $relatedAgentXml->CdtrAgt->FinInstnId;
                 $agentClass = CreditorAgent::class;
             } elseif ($entry->isCredit() && isset($relatedAgentXml->DbtrAgt)) {
                 $relatedFinancialInstitution = $relatedAgentXml->DbtrAgt->FinInstnId;
                 $agentClass = DebtorAgent::class;
             } else {
                 continue;
             }
             $bankCode = null;
             if (isset($relatedFinancialInstitution->BIC)) {
                 $bankCode = $relatedFinancialInstitution->BIC;
             } elseif (isset($relatedFinancialInstitution->Othr->Id)) {
                 $bankCode = $relatedFinancialInstitution->Othr->Id;
             }
             $name = null;
             if (isset($relatedFinancialInstitution->Nm)) {
                 $name = $relatedFinancialInstitution->Nm;
             }
             /** @var RelatedAgentTypeInterface $agentDetails */
             $agentDetails = new $agentClass((string) $name);
             if (isset($relatedFinancialInstitution->PstlAdr)) {
                 $address = new Address();
                 /** @var SimpleXMLElement $addressPart */
                 foreach ($relatedFinancialInstitution->PstlAdr as $addressPart) {
                     if ($addressPart->getName() === 'Ctry') {
                         $address = $address->setCountry((string) $addressPart);
                     } else {
                         $address = $address->addAddressLine((string) $addressPart);
                     }
                 }
                 $agentDetails->setAddress($address);
             }
             $relatedAgent = new RelatedAgent($agentDetails, (string) $bankCode);
             $detail->addRelatedAgent($relatedAgent);
         }
     }
 }