Skip to content

Commit 196cd87

Browse files
mkrasselt1Michael Krasselt
and
Michael Krasselt
authored
Populate entryTransaction->getAgentBic() for recent CAMT format (#165)
`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]>
1 parent ca4fe9f commit 196cd87

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

src/Decoder/EntryTransactionDetail.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,13 @@ public function addRemittanceInformation(DTO\EntryTransactionDetail $detail, Sim
198198
);
199199
}
200200

201-
if (isset($xmlDetailsStructuredBlock->CdtrRefInf->Tp, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry->Prtry)
202-
203-
) {
201+
if (isset($xmlDetailsStructuredBlock->CdtrRefInf->Tp, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry->Prtry)) {
204202
$creditorReferenceInformation->setProprietary(
205203
(string) $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry->Prtry
206204
);
207205
}
208206

209-
if (isset($xmlDetailsStructuredBlock->CdtrRefInf->Tp, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry->Cd)
210-
211-
) {
207+
if (isset($xmlDetailsStructuredBlock->CdtrRefInf->Tp, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry, $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry->Cd)) {
212208
$creditorReferenceInformation->setCode(
213209
(string) $xmlDetailsStructuredBlock->CdtrRefInf->Tp->CdOrPrtry->Cd
214210
);
@@ -218,8 +214,10 @@ public function addRemittanceInformation(DTO\EntryTransactionDetail $detail, Sim
218214

219215
// Legacy : do not overwrite message if already defined above
220216
// and no creditor reference is already defined
221-
if (false === $unstructuredBlockExists
222-
&& $remittanceInformation->getCreditorReferenceInformation() === null) {
217+
if (
218+
false === $unstructuredBlockExists
219+
&& $remittanceInformation->getCreditorReferenceInformation() === null
220+
) {
223221
$remittanceInformation->setCreditorReferenceInformation($creditorReferenceInformation);
224222
}
225223
}
@@ -362,6 +360,6 @@ abstract public function getRelatedPartyAccount(?SimpleXMLElement $xmlRelatedPar
362360
*/
363361
protected function getAgentBic(SimpleXMLElement $xmlAgent): ?SimpleXMLElement
364362
{
365-
return $xmlAgent->FinInstnId->BIC;
363+
return $xmlAgent->FinInstnId->BIC ?? $xmlAgent->FinInstnId->BICFI;
366364
}
367365
}

test/data/camt052.v4.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
181181
"getRelatedAgentType": {
182182
"__CLASS__": "Genkgo\\Camt\\DTO\\CreditorAgent",
183-
"getBIC": "",
183+
"getBIC": "BANKCHZHXXX",
184184
"getName": ""
185185
}
186186
},
@@ -190,7 +190,7 @@
190190
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
191191
"getRelatedAgentType": {
192192
"__CLASS__": "Genkgo\\Camt\\DTO\\DebtorAgent",
193-
"getBIC": "",
193+
"getBIC": "BANKCHBE",
194194
"getName": ""
195195
}
196196
}

test/data/camt052.v6.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
181181
"getRelatedAgentType": {
182182
"__CLASS__": "Genkgo\\Camt\\DTO\\CreditorAgent",
183-
"getBIC": "",
183+
"getBIC": "BANKCHZHXXX",
184184
"getName": ""
185185
}
186186
},
@@ -190,7 +190,7 @@
190190
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
191191
"getRelatedAgentType": {
192192
"__CLASS__": "Genkgo\\Camt\\DTO\\DebtorAgent",
193-
"getBIC": "",
193+
"getBIC": "BANKCHBE",
194194
"getName": ""
195195
}
196196
}

test/data/camt053.v3.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
185185
"getRelatedAgentType": {
186186
"__CLASS__": "Genkgo\\Camt\\DTO\\CreditorAgent",
187-
"getBIC": "",
187+
"getBIC": "KREDBEBB",
188188
"getName": ""
189189
}
190190
},
@@ -194,7 +194,7 @@
194194
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
195195
"getRelatedAgentType": {
196196
"__CLASS__": "Genkgo\\Camt\\DTO\\DebtorAgent",
197-
"getBIC": "",
197+
"getBIC": "KREDBEBB",
198198
"getName": ""
199199
}
200200
}

0 commit comments

Comments
 (0)