Exemple #1
0
 /**
  * @param SimpleXMLElement $detailXml
  * @param EntryTransactionDetail $detail
  */
 private function addRelatedPartiesToTransactionDetails(SimpleXMLElement $detailXml, EntryTransactionDetail $detail)
 {
     if (isset($detailXml->RltdPties)) {
         foreach ($detailXml->RltdPties as $relatedPartyXml) {
             if (isset($relatedPartyXml->Cdtr)) {
                 $creditor = new Debtor((string) $relatedPartyXml->Cdtr->Nm);
                 if (isset($relatedPartyXml->Cdtr->PstlAdr)) {
                     $creditor->setAddress(Address::fromUnstructured($relatedPartyXml->Cdtr->PstlAdr));
                 }
                 if (isset($relatedPartyXml->CdtrAcct->Id->IBAN) && ($ibanCode = (string) $relatedPartyXml->CdtrAcct->Id->IBAN)) {
                     $account = new Account(new Iban($ibanCode));
                 } else {
                     $account = null;
                 }
                 $detail->addRelatedParty(new RelatedParty($creditor, $account));
             }
             if (isset($relatedPartyXml->Dbtr)) {
                 $debtor = new Debtor((string) $relatedPartyXml->Dbtr->Nm);
                 if (isset($relatedPartyXml->Dbtr->PstlAdr)) {
                     $debtor->setAddress(Address::fromUnstructured($relatedPartyXml->Dbtr->PstlAdr));
                 }
                 if (isset($relatedPartyXml->DbtrAcct->Id->IBAN) && ($ibanCode = (string) $relatedPartyXml->DbtrAcct->Id->IBAN)) {
                     $account = new Account(new Iban($ibanCode));
                 } else {
                     $account = null;
                 }
                 $detail->addRelatedParty(new RelatedParty($debtor, $account));
             }
         }
     }
 }
Exemple #2
0
 /**
  * @param SimpleXMLElement $detailXml
  * @param EntryTransactionDetail $detail
  */
 private function addRelatedPartiesToTransactionDetails(SimpleXMLElement $detailXml, EntryTransactionDetail $detail)
 {
     if (isset($detailXml->RltdPties)) {
         foreach ($detailXml->RltdPties as $relatedPartyXml) {
             if (isset($relatedPartyXml->Cdtr)) {
                 $relatedPartyTypeXml = $relatedPartyXml->Cdtr;
                 $relatedPartyTypeAccountXml = $relatedPartyXml->CdtrAcct;
                 $relatedPartyType = $creditor = new Creditor((string) $relatedPartyTypeXml->Nm);
             } elseif (isset($relatedPartyXml->Dbtr)) {
                 $relatedPartyTypeXml = $relatedPartyXml->Dbtr;
                 $relatedPartyTypeAccountXml = $relatedPartyXml->DbtrAcct;
                 $relatedPartyType = $creditor = new Debtor((string) $relatedPartyTypeXml->Nm);
             } else {
                 continue;
             }
             if (isset($relatedPartyTypeXml->PstlAdr)) {
                 $address = new Address();
                 if (isset($relatedPartyTypeXml->PstlAdr->Ctry)) {
                     $address = $address->setCountry($relatedPartyTypeXml->PstlAdr->Ctry);
                 }
                 if (isset($relatedPartyTypeXml->PstlAdr->AdrLine)) {
                     foreach ($relatedPartyTypeXml->PstlAdr->AdrLine as $line) {
                         $address = $address->addAddressLine((string) $line);
                     }
                 }
                 $relatedPartyType->setAddress($address);
             }
             if (isset($relatedPartyTypeAccountXml->Id->IBAN) && ($ibanCode = (string) $relatedPartyTypeAccountXml->Id->IBAN)) {
                 $account = new Account(new Iban($ibanCode));
             } else {
                 $account = null;
             }
             $relatedParty = new RelatedParty($relatedPartyType, $account);
             $detail->addRelatedParty($relatedParty);
         }
     }
 }