Skip to content

Commit 809a968

Browse files
juliangumsPowerKiKi
authored andcommitted
Add support for named iban accounts
`IbanAccount::getName()` return the account name if defined in the CAMT file. Closes #161
1 parent 196cd87 commit 809a968

28 files changed

+659
-50
lines changed

src/Camt052/Decoder/EntryTransactionDetail.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ public function getRelatedPartyAccount(?SimpleXMLElement $xmlRelatedPartyTypeAcc
2525
}
2626

2727
if (isset($xmlRelatedPartyTypeAccount->Id->IBAN)) {
28-
return new DTO\IbanAccount(new Iban((string) $xmlRelatedPartyTypeAccount->Id->IBAN));
28+
$name = isset($xmlRelatedPartyTypeAccount->Nm) ? (string) $xmlRelatedPartyTypeAccount->Nm : null;
29+
30+
return new DTO\IbanAccount(new Iban((string) $xmlRelatedPartyTypeAccount->Id->IBAN), $name);
2931
}
3032

3133
if (isset($xmlRelatedPartyTypeAccount->Id->BBAN)) {

src/Camt052/Decoder/Message.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public function addRecords(DTO\Message $message, SimpleXMLElement $document): vo
5050
protected function getAccount(SimpleXMLElement $xmlRecord): Account
5151
{
5252
if (isset($xmlRecord->Acct->Id->IBAN)) {
53-
return new DTO\IbanAccount(new Iban((string) $xmlRecord->Acct->Id->IBAN));
53+
$name = isset($xmlRecord->Acct->Nm) ? (string) $xmlRecord->Acct->Nm : null;
54+
55+
return new DTO\IbanAccount(new Iban((string) $xmlRecord->Acct->Id->IBAN), $name);
5456
}
5557

5658
if (isset($xmlRecord->Acct->Id->BBAN)) {

src/Camt053/Decoder/EntryTransactionDetail.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ public function getRelatedPartyAccount(?SimpleXMLElement $xmlRelatedPartyTypeAcc
2525
}
2626

2727
if (isset($xmlRelatedPartyTypeAccount->Id->IBAN) && $ibanCode = (string) $xmlRelatedPartyTypeAccount->Id->IBAN) {
28-
return new DTO\IbanAccount(new Iban($ibanCode));
28+
$name = isset($xmlRelatedPartyTypeAccount->Nm) ? (string) $xmlRelatedPartyTypeAccount->Nm : null;
29+
30+
return new DTO\IbanAccount(new Iban($ibanCode), $name);
2931
}
3032

3133
if (false === isset($xmlRelatedPartyTypeAccount->Id->Othr)) {

src/Camt053/Decoder/Message.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public function getRootElement(SimpleXMLElement $document): SimpleXMLElement
5656
protected function getAccount(SimpleXMLElement $xmlRecord): DTO\Account
5757
{
5858
if (isset($xmlRecord->Acct->Id->IBAN)) {
59-
return new DTO\IbanAccount(new Iban((string) $xmlRecord->Acct->Id->IBAN));
59+
$name = isset($xmlRecord->Acct->Nm) ? (string) $xmlRecord->Acct->Nm : null;
60+
61+
return new DTO\IbanAccount(new Iban((string) $xmlRecord->Acct->Id->IBAN), $name);
6062
}
6163

6264
$xmlOtherIdentification = $xmlRecord->Acct->Id->Othr;

src/Camt054/Decoder/EntryTransactionDetail.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ public function getRelatedPartyAccount(?SimpleXMLElement $xmlRelatedPartyTypeAcc
2525
}
2626

2727
if (isset($xmlRelatedPartyTypeAccount->Id->IBAN)) {
28-
return new DTO\IbanAccount(new Iban((string) $xmlRelatedPartyTypeAccount->Id->IBAN));
28+
$name = isset($xmlRelatedPartyTypeAccount->Nm) ? (string) $xmlRelatedPartyTypeAccount->Nm : null;
29+
30+
return new DTO\IbanAccount(new Iban((string) $xmlRelatedPartyTypeAccount->Id->IBAN), $name);
2931
}
3032

3133
if (isset($xmlRelatedPartyTypeAccount->Id->BBAN)) {

src/Camt054/Decoder/Message.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ public function getRootElement(SimpleXMLElement $document): SimpleXMLElement
5757
protected function getAccount(SimpleXMLElement $xmlRecord): Account
5858
{
5959
if (isset($xmlRecord->Acct->Id->IBAN)) {
60-
return new DTO\IbanAccount(new Iban((string) $xmlRecord->Acct->Id->IBAN));
60+
$name = isset($xmlRecord->Acct->Nm) ? (string) $xmlRecord->Acct->Nm : null;
61+
62+
return new DTO\IbanAccount(new Iban((string) $xmlRecord->Acct->Id->IBAN), $name);
6163
}
6264

6365
if (isset($xmlRecord->Acct->Id->BBAN)) {

src/DTO/IbanAccount.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@
88

99
class IbanAccount extends Account
1010
{
11-
private Iban $iban;
12-
13-
public function __construct(Iban $iban)
14-
{
15-
$this->iban = $iban;
11+
public function __construct(
12+
private readonly Iban $iban,
13+
private readonly ?string $name,
14+
) {
1615
}
1716

1817
public function getIban(): Iban
1918
{
2019
return $this->iban;
2120
}
2221

22+
public function getName(): ?string
23+
{
24+
return $this->name;
25+
}
26+
2327
/**
2428
* @inheritDoc
2529
*/

test/data/camt052.v2.json

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@
118118
"__CLASS__": "Genkgo\\Camt\\Iban",
119119
"getIban": "NL56AGDH9619008421"
120120
},
121-
"getIdentification": "NL56AGDH9619008421"
121+
"getIdentification": "NL56AGDH9619008421",
122+
"getName": null
122123
},
123124
"getRelatedPartyType": {
124125
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
@@ -145,7 +146,8 @@
145146
"__CLASS__": "Genkgo\\Camt\\Iban",
146147
"getIban": "NL56AGDH9619008421"
147148
},
148-
"getIdentification": "NL56AGDH9619008421"
149+
"getIdentification": "NL56AGDH9619008421",
150+
"getName": null
149151
},
150152
"getRelatedPartyType": {
151153
"__CLASS__": "Genkgo\\Camt\\DTO\\Debtor",
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
{
2+
"__CLASS__": "Genkgo\\Camt\\DTO\\Message",
3+
"getEntries": [
4+
{
5+
"__CLASS__": "Genkgo\\Camt\\DTO\\Entry",
6+
"getAccountServicerReference": null,
7+
"getAdditionalInfo": "",
8+
"getAmount": {
9+
"__CLASS__": "Money\\Money",
10+
"getAmount": "-20000000",
11+
"getCurrency": {
12+
"__CLASS__": "Money\\Currency",
13+
"getCode": "SEK"
14+
}
15+
},
16+
"getBankTransactionCode": {
17+
"__CLASS__": "Genkgo\\Camt\\DTO\\BankTransactionCode",
18+
"getDomain": null,
19+
"getProprietary": null
20+
},
21+
"getBatchPaymentId": null,
22+
"getBookingDate": null,
23+
"getCharges": null,
24+
"getCreditDebitIndicator": "DBIT",
25+
"getIndex": 0,
26+
"getRecord": {
27+
"__CLASS__": "Genkgo\\Camt\\Camt052\\DTO\\Report",
28+
"getAccount": {
29+
"__CLASS__": "Genkgo\\Camt\\DTO\\IbanAccount",
30+
"getIban": {
31+
"__CLASS__": "Genkgo\\Camt\\Iban",
32+
"getIban": "CH2801234000123456789"
33+
},
34+
"getIdentification": "CH2801234000123456789",
35+
"getName": "Account Owner Name"
36+
},
37+
"getAdditionalInformation": null,
38+
"getBalances": [],
39+
"getCopyDuplicateIndicator": null,
40+
"getCreatedOn": {
41+
"__CLASS__": "DateTimeImmutable",
42+
"0": "2007-10-18T11:30:00+00:00"
43+
},
44+
"getElectronicSequenceNumber": null,
45+
"getEntries": [
46+
"__RECURSIVITY__"
47+
],
48+
"getFromDate": null,
49+
"getId": "AAAASESS-FP-ACCR001",
50+
"getLegalSequenceNumber": null,
51+
"getPagination": null,
52+
"getToDate": null
53+
},
54+
"getReference": null,
55+
"getReversalIndicator": false,
56+
"getStatus": "BOOK",
57+
"getTransactionDetail": {
58+
"__CLASS__": "Genkgo\\Camt\\DTO\\EntryTransactionDetail",
59+
"getAdditionalTransactionInformation": null,
60+
"getAmount": null,
61+
"getAmountDetails": null,
62+
"getBankTransactionCode": {
63+
"__CLASS__": "Genkgo\\Camt\\DTO\\BankTransactionCode",
64+
"getDomain": null,
65+
"getProprietary": null
66+
},
67+
"getCharges": null,
68+
"getCreditDebitIndicator": "DBIT",
69+
"getReference": null,
70+
"getRelatedAgent": null,
71+
"getRelatedAgents": [],
72+
"getRelatedDates": null,
73+
"getRelatedParties": [
74+
{
75+
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedParty",
76+
"getAccount": {
77+
"__CLASS__": "Genkgo\\Camt\\DTO\\IbanAccount",
78+
"getIban": {
79+
"__CLASS__": "Genkgo\\Camt\\Iban",
80+
"getIban": "CH2801234000123456789"
81+
},
82+
"getIdentification": "CH2801234000123456789",
83+
"getName": "Creditor Account Name"
84+
},
85+
"getRelatedPartyType": {
86+
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
87+
"getAddress": null,
88+
"getName": "Company Name"
89+
}
90+
},
91+
{
92+
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedParty",
93+
"getAccount": {
94+
"__CLASS__": "Genkgo\\Camt\\DTO\\IbanAccount",
95+
"getIban": {
96+
"__CLASS__": "Genkgo\\Camt\\Iban",
97+
"getIban": "CH2801234000123456789"
98+
},
99+
"getIdentification": "CH2801234000123456789",
100+
"getName": "Debitor Account Name"
101+
},
102+
"getRelatedPartyType": {
103+
"__CLASS__": "Genkgo\\Camt\\DTO\\Debtor",
104+
"getAddress": null,
105+
"getName": "NAME NAME"
106+
}
107+
}
108+
],
109+
"getRelatedParty": "__RECURSIVITY__",
110+
"getRemittanceInformation": null,
111+
"getReturnInformation": null
112+
},
113+
"getTransactionDetails": [
114+
"__RECURSIVITY__"
115+
],
116+
"getValueDate": null
117+
}
118+
],
119+
"getGroupHeader": {
120+
"__CLASS__": "Genkgo\\Camt\\DTO\\GroupHeader",
121+
"getAdditionalInformation": null,
122+
"getCreatedOn": {
123+
"__CLASS__": "DateTimeImmutable",
124+
"0": "2007-10-18T11:30:00+00:00"
125+
},
126+
"getMessageId": "AAAASESS-FP-ACCR001",
127+
"getMessageRecipient": null,
128+
"getPagination": null
129+
},
130+
"getRecords": [
131+
"__RECURSIVITY__"
132+
]
133+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:iso:std:iso:20022:tech:xsd:camt.052.001.02">
3+
<BkToCstmrAcctRpt>
4+
<GrpHdr>
5+
<MsgId>AAAASESS-FP-ACCR001</MsgId>
6+
<CreDtTm>2007-10-18T12:30:00+01:00</CreDtTm>
7+
</GrpHdr>
8+
<Rpt>
9+
<Id>AAAASESS-FP-ACCR001</Id>
10+
<CreDtTm>2007-10-18T12:30:00+01:00</CreDtTm>
11+
<Acct>
12+
<Id>
13+
<IBAN>CH2801234000123456789</IBAN>
14+
</Id>
15+
<Nm>Account Owner Name</Nm>
16+
</Acct>
17+
<Ntry>
18+
<Amt Ccy="SEK">200000</Amt>
19+
<CdtDbtInd>DBIT</CdtDbtInd>
20+
<Sts>BOOK</Sts>
21+
<BkTxCd>
22+
</BkTxCd>
23+
<NtryDtls>
24+
<TxDtls>
25+
<RltdPties>
26+
<Dbtr>
27+
<Nm>NAME NAME</Nm>
28+
</Dbtr>
29+
<DbtrAcct>
30+
<Id>
31+
<IBAN>CH2801234000123456789</IBAN>
32+
</Id>
33+
<Nm>Debitor Account Name</Nm>
34+
</DbtrAcct>
35+
<Cdtr>
36+
<Nm>Company Name</Nm>
37+
</Cdtr>
38+
<CdtrAcct>
39+
<Id>
40+
<IBAN>CH2801234000123456789</IBAN>
41+
</Id>
42+
<Nm>Creditor Account Name</Nm>
43+
</CdtrAcct>
44+
</RltdPties>
45+
</TxDtls>
46+
</NtryDtls>
47+
</Ntry>
48+
</Rpt>
49+
</BkToCstmrAcctRpt>
50+
</Document>

test/data/camt052.v4.json

100644100755
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"__CLASS__": "Genkgo\\Camt\\Iban",
4747
"getIban": "CH2801234000123456789"
4848
},
49-
"getIdentification": "CH2801234000123456789"
49+
"getIdentification": "CH2801234000123456789",
50+
"getName": null
5051
},
5152
"getAdditionalInformation": "Additional Information",
5253
"getBalances": [
@@ -205,7 +206,8 @@
205206
"__CLASS__": "Genkgo\\Camt\\Iban",
206207
"getIban": "CH2801234000123456789"
207208
},
208-
"getIdentification": "CH2801234000123456789"
209+
"getIdentification": "CH2801234000123456789",
210+
"getName": null
209211
},
210212
"getRelatedPartyType": {
211213
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
@@ -221,7 +223,8 @@
221223
"__CLASS__": "Genkgo\\Camt\\Iban",
222224
"getIban": "CH2401234004141414141"
223225
},
224-
"getIdentification": "CH2401234004141414141"
226+
"getIdentification": "CH2401234004141414141",
227+
"getName": null
225228
},
226229
"getRelatedPartyType": {
227230
"__CLASS__": "Genkgo\\Camt\\DTO\\Debtor",

test/data/camt052.v6.json

100644100755
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"__CLASS__": "Genkgo\\Camt\\Iban",
4747
"getIban": "CH2801234000123456789"
4848
},
49-
"getIdentification": "CH2801234000123456789"
49+
"getIdentification": "CH2801234000123456789",
50+
"getName": null
5051
},
5152
"getAdditionalInformation": "Additional Information",
5253
"getBalances": [
@@ -205,7 +206,8 @@
205206
"__CLASS__": "Genkgo\\Camt\\Iban",
206207
"getIban": "CH2801234000123456789"
207208
},
208-
"getIdentification": "CH2801234000123456789"
209+
"getIdentification": "CH2801234000123456789",
210+
"getName": null
209211
},
210212
"getRelatedPartyType": {
211213
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
@@ -221,7 +223,8 @@
221223
"__CLASS__": "Genkgo\\Camt\\Iban",
222224
"getIban": "CH2401234004141414141"
223225
},
224-
"getIdentification": "CH2401234004141414141"
226+
"getIdentification": "CH2401234004141414141",
227+
"getName": null
225228
},
226229
"getRelatedPartyType": {
227230
"__CLASS__": "Genkgo\\Camt\\DTO\\Debtor",

test/data/camt053.v2.all-balance-types.json

100644100755
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@
265265
"__CLASS__": "Genkgo\\Camt\\Iban",
266266
"getIban": "NL56AGDH9619008421"
267267
},
268-
"getIdentification": "NL56AGDH9619008421"
268+
"getIdentification": "NL56AGDH9619008421",
269+
"getName": null
269270
},
270271
"getRelatedPartyType": {
271272
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",

test/data/camt053.v2.five.decimals.json

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"__CLASS__": "Genkgo\\Camt\\Iban",
3939
"getIban": "NL26VAYB8060476890"
4040
},
41-
"getIdentification": "NL26VAYB8060476890"
41+
"getIdentification": "NL26VAYB8060476890",
42+
"getName": null
4243
},
4344
"getAdditionalInformation": "Additional Information",
4445
"getBalances": [
@@ -139,7 +140,8 @@
139140
"__CLASS__": "Genkgo\\Camt\\Iban",
140141
"getIban": "NL56AGDH9619008421"
141142
},
142-
"getIdentification": "NL56AGDH9619008421"
143+
"getIdentification": "NL56AGDH9619008421",
144+
"getName": null
143145
},
144146
"getRelatedPartyType": {
145147
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",

0 commit comments

Comments
 (0)