Skip to content

Commit

Permalink
Populate entryTransaction->getAgentBic() for recent CAMT format (#165)
Browse files Browse the repository at this point in the history
`BIC` is only available in old camt.052.001.01, camt.052.001.02, 
camt.053.001.02 and camt.054.001.02. All later versions of CAMT instead 
use `BICFI` to represent the same information.

Co-authored-by: Michael Krasselt <[email protected]>
  • Loading branch information
mkrasselt1 and Michael Krasselt authored Jan 6, 2025
1 parent ca4fe9f commit 196cd87
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
16 changes: 7 additions & 9 deletions src/Decoder/EntryTransactionDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,13 @@ public function addRemittanceInformation(DTO\EntryTransactionDetail $detail, Sim
);
}

if (isset($xmlDetailsStructuredBlock->CdtrRefInf->Tp, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry->Prtry)

) {
if (isset($xmlDetailsStructuredBlock->CdtrRefInf->Tp, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry->Prtry)) {
$creditorReferenceInformation->setProprietary(
(string) $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry->Prtry
);
}

if (isset($xmlDetailsStructuredBlock->CdtrRefInf->Tp, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry->Cd)

) {
if (isset($xmlDetailsStructuredBlock->CdtrRefInf->Tp, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry->Cd)) {
$creditorReferenceInformation->setCode(
(string) $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry->Cd
);
Expand All @@ -218,8 +214,10 @@ public function addRemittanceInformation(DTO\EntryTransactionDetail $detail, Sim

// Legacy : do not overwrite message if already defined above
// and no creditor reference is already defined
if (false === $unstructuredBlockExists
&& $remittanceInformation->getCreditorReferenceInformation() === null) {
if (
false === $unstructuredBlockExists
&& $remittanceInformation->getCreditorReferenceInformation() === null
) {
$remittanceInformation->setCreditorReferenceInformation($creditorReferenceInformation);
}
}
Expand Down Expand Up @@ -362,6 +360,6 @@ abstract public function getRelatedPartyAccount(?SimpleXMLElement $xmlRelatedPar
*/
protected function getAgentBic(SimpleXMLElement $xmlAgent): ?SimpleXMLElement
{
return $xmlAgent->FinInstnId->BIC;
return $xmlAgent->FinInstnId->BIC ?? $xmlAgent->FinInstnId->BICFI;
}
}
4 changes: 2 additions & 2 deletions test/data/camt052.v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
"getRelatedAgentType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\CreditorAgent",
"getBIC": "",
"getBIC": "BANKCHZHXXX",
"getName": ""
}
},
Expand All @@ -190,7 +190,7 @@
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
"getRelatedAgentType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\DebtorAgent",
"getBIC": "",
"getBIC": "BANKCHBE",
"getName": ""
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/data/camt052.v6.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
"getRelatedAgentType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\CreditorAgent",
"getBIC": "",
"getBIC": "BANKCHZHXXX",
"getName": ""
}
},
Expand All @@ -190,7 +190,7 @@
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
"getRelatedAgentType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\DebtorAgent",
"getBIC": "",
"getBIC": "BANKCHBE",
"getName": ""
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/data/camt053.v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
"getRelatedAgentType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\CreditorAgent",
"getBIC": "",
"getBIC": "KREDBEBB",
"getName": ""
}
},
Expand All @@ -194,7 +194,7 @@
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
"getRelatedAgentType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\DebtorAgent",
"getBIC": "",
"getBIC": "KREDBEBB",
"getName": ""
}
}
Expand Down

0 comments on commit 196cd87

Please sign in to comment.