Skip to content

Add support for named iban accounts #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Camt052/Decoder/EntryTransactionDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public function getRelatedPartyAccount(?SimpleXMLElement $xmlRelatedPartyTypeAcc
}

if (isset($xmlRelatedPartyTypeAccount->Id->IBAN)) {
return new DTO\IbanAccount(new Iban((string) $xmlRelatedPartyTypeAccount->Id->IBAN));
$name = isset($xmlRelatedPartyTypeAccount->Nm) ? (string) $xmlRelatedPartyTypeAccount->Nm : null;

return new DTO\IbanAccount(new Iban((string) $xmlRelatedPartyTypeAccount->Id->IBAN), $name);
}

if (isset($xmlRelatedPartyTypeAccount->Id->BBAN)) {
Expand Down
4 changes: 3 additions & 1 deletion src/Camt052/Decoder/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public function addRecords(DTO\Message $message, SimpleXMLElement $document): vo
protected function getAccount(SimpleXMLElement $xmlRecord): Account
{
if (isset($xmlRecord->Acct->Id->IBAN)) {
return new DTO\IbanAccount(new Iban((string) $xmlRecord->Acct->Id->IBAN));
$name = isset($xmlRecord->Acct->Nm) ? (string) $xmlRecord->Acct->Nm : null;

return new DTO\IbanAccount(new Iban((string) $xmlRecord->Acct->Id->IBAN), $name);
}

if (isset($xmlRecord->Acct->Id->BBAN)) {
Expand Down
4 changes: 3 additions & 1 deletion src/Camt053/Decoder/EntryTransactionDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public function getRelatedPartyAccount(?SimpleXMLElement $xmlRelatedPartyTypeAcc
}

if (isset($xmlRelatedPartyTypeAccount->Id->IBAN) && $ibanCode = (string) $xmlRelatedPartyTypeAccount->Id->IBAN) {
return new DTO\IbanAccount(new Iban($ibanCode));
$name = isset($xmlRelatedPartyTypeAccount->Nm) ? (string) $xmlRelatedPartyTypeAccount->Nm : null;

return new DTO\IbanAccount(new Iban($ibanCode), $name);
}

if (false === isset($xmlRelatedPartyTypeAccount->Id->Othr)) {
Expand Down
4 changes: 3 additions & 1 deletion src/Camt053/Decoder/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public function getRootElement(SimpleXMLElement $document): SimpleXMLElement
protected function getAccount(SimpleXMLElement $xmlRecord): DTO\Account
{
if (isset($xmlRecord->Acct->Id->IBAN)) {
return new DTO\IbanAccount(new Iban((string) $xmlRecord->Acct->Id->IBAN));
$name = isset($xmlRecord->Acct->Nm) ? (string) $xmlRecord->Acct->Nm : null;

return new DTO\IbanAccount(new Iban((string) $xmlRecord->Acct->Id->IBAN), $name);
}

$xmlOtherIdentification = $xmlRecord->Acct->Id->Othr;
Expand Down
4 changes: 3 additions & 1 deletion src/Camt054/Decoder/EntryTransactionDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public function getRelatedPartyAccount(?SimpleXMLElement $xmlRelatedPartyTypeAcc
}

if (isset($xmlRelatedPartyTypeAccount->Id->IBAN)) {
return new DTO\IbanAccount(new Iban((string) $xmlRelatedPartyTypeAccount->Id->IBAN));
$name = isset($xmlRelatedPartyTypeAccount->Nm) ? (string) $xmlRelatedPartyTypeAccount->Nm : null;

return new DTO\IbanAccount(new Iban((string) $xmlRelatedPartyTypeAccount->Id->IBAN), $name);
}

if (isset($xmlRelatedPartyTypeAccount->Id->BBAN)) {
Expand Down
4 changes: 3 additions & 1 deletion src/Camt054/Decoder/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public function getRootElement(SimpleXMLElement $document): SimpleXMLElement
protected function getAccount(SimpleXMLElement $xmlRecord): Account
{
if (isset($xmlRecord->Acct->Id->IBAN)) {
return new DTO\IbanAccount(new Iban((string) $xmlRecord->Acct->Id->IBAN));
$name = isset($xmlRecord->Acct->Nm) ? (string) $xmlRecord->Acct->Nm : null;

return new DTO\IbanAccount(new Iban((string) $xmlRecord->Acct->Id->IBAN), $name);
}

if (isset($xmlRecord->Acct->Id->BBAN)) {
Expand Down
14 changes: 9 additions & 5 deletions src/DTO/IbanAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@

class IbanAccount extends Account
{
private Iban $iban;

public function __construct(Iban $iban)
{
$this->iban = $iban;
public function __construct(
private readonly Iban $iban,
private readonly ?string $name,
) {
}

public function getIban(): Iban
{
return $this->iban;
}

public function getName(): ?string
{
return $this->name;
}

/**
* @inheritDoc
*/
Expand Down
6 changes: 4 additions & 2 deletions test/data/camt052.v2.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
"__CLASS__": "Genkgo\\Camt\\Iban",
"getIban": "NL56AGDH9619008421"
},
"getIdentification": "NL56AGDH9619008421"
"getIdentification": "NL56AGDH9619008421",
"getName": null
},
"getRelatedPartyType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
Expand All @@ -145,7 +146,8 @@
"__CLASS__": "Genkgo\\Camt\\Iban",
"getIban": "NL56AGDH9619008421"
},
"getIdentification": "NL56AGDH9619008421"
"getIdentification": "NL56AGDH9619008421",
"getName": null
},
"getRelatedPartyType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Debtor",
Expand Down
133 changes: 133 additions & 0 deletions test/data/camt052.v2.with-account-name.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"__CLASS__": "Genkgo\\Camt\\DTO\\Message",
"getEntries": [
{
"__CLASS__": "Genkgo\\Camt\\DTO\\Entry",
"getAccountServicerReference": null,
"getAdditionalInfo": "",
"getAmount": {
"__CLASS__": "Money\\Money",
"getAmount": "-20000000",
"getCurrency": {
"__CLASS__": "Money\\Currency",
"getCode": "SEK"
}
},
"getBankTransactionCode": {
"__CLASS__": "Genkgo\\Camt\\DTO\\BankTransactionCode",
"getDomain": null,
"getProprietary": null
},
"getBatchPaymentId": null,
"getBookingDate": null,
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt052\\DTO\\Report",
"getAccount": {
"__CLASS__": "Genkgo\\Camt\\DTO\\IbanAccount",
"getIban": {
"__CLASS__": "Genkgo\\Camt\\Iban",
"getIban": "CH2801234000123456789"
},
"getIdentification": "CH2801234000123456789",
"getName": "Account Owner Name"
},
"getAdditionalInformation": null,
"getBalances": [],
"getCopyDuplicateIndicator": null,
"getCreatedOn": {
"__CLASS__": "DateTimeImmutable",
"0": "2007-10-18T11:30:00+00:00"
},
"getElectronicSequenceNumber": null,
"getEntries": [
"__RECURSIVITY__"
],
"getFromDate": null,
"getId": "AAAASESS-FP-ACCR001",
"getLegalSequenceNumber": null,
"getPagination": null,
"getToDate": null
},
"getReference": null,
"getReversalIndicator": false,
"getStatus": "BOOK",
"getTransactionDetail": {
"__CLASS__": "Genkgo\\Camt\\DTO\\EntryTransactionDetail",
"getAdditionalTransactionInformation": null,
"getAmount": null,
"getAmountDetails": null,
"getBankTransactionCode": {
"__CLASS__": "Genkgo\\Camt\\DTO\\BankTransactionCode",
"getDomain": null,
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getReference": null,
"getRelatedAgent": null,
"getRelatedAgents": [],
"getRelatedDates": null,
"getRelatedParties": [
{
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedParty",
"getAccount": {
"__CLASS__": "Genkgo\\Camt\\DTO\\IbanAccount",
"getIban": {
"__CLASS__": "Genkgo\\Camt\\Iban",
"getIban": "CH2801234000123456789"
},
"getIdentification": "CH2801234000123456789",
"getName": "Creditor Account Name"
},
"getRelatedPartyType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
"getAddress": null,
"getName": "Company Name"
}
},
{
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedParty",
"getAccount": {
"__CLASS__": "Genkgo\\Camt\\DTO\\IbanAccount",
"getIban": {
"__CLASS__": "Genkgo\\Camt\\Iban",
"getIban": "CH2801234000123456789"
},
"getIdentification": "CH2801234000123456789",
"getName": "Debitor Account Name"
},
"getRelatedPartyType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Debtor",
"getAddress": null,
"getName": "NAME NAME"
}
}
],
"getRelatedParty": "__RECURSIVITY__",
"getRemittanceInformation": null,
"getReturnInformation": null
},
"getTransactionDetails": [
"__RECURSIVITY__"
],
"getValueDate": null
}
],
"getGroupHeader": {
"__CLASS__": "Genkgo\\Camt\\DTO\\GroupHeader",
"getAdditionalInformation": null,
"getCreatedOn": {
"__CLASS__": "DateTimeImmutable",
"0": "2007-10-18T11:30:00+00:00"
},
"getMessageId": "AAAASESS-FP-ACCR001",
"getMessageRecipient": null,
"getPagination": null
},
"getRecords": [
"__RECURSIVITY__"
]
}
50 changes: 50 additions & 0 deletions test/data/camt052.v2.with-account-name.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:iso:std:iso:20022:tech:xsd:camt.052.001.02">
<BkToCstmrAcctRpt>
<GrpHdr>
<MsgId>AAAASESS-FP-ACCR001</MsgId>
<CreDtTm>2007-10-18T12:30:00+01:00</CreDtTm>
</GrpHdr>
<Rpt>
<Id>AAAASESS-FP-ACCR001</Id>
<CreDtTm>2007-10-18T12:30:00+01:00</CreDtTm>
<Acct>
<Id>
<IBAN>CH2801234000123456789</IBAN>
</Id>
<Nm>Account Owner Name</Nm>
</Acct>
<Ntry>
<Amt Ccy="SEK">200000</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Sts>BOOK</Sts>
<BkTxCd>
</BkTxCd>
<NtryDtls>
<TxDtls>
<RltdPties>
<Dbtr>
<Nm>NAME NAME</Nm>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>CH2801234000123456789</IBAN>
</Id>
<Nm>Debitor Account Name</Nm>
</DbtrAcct>
<Cdtr>
<Nm>Company Name</Nm>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>CH2801234000123456789</IBAN>
</Id>
<Nm>Creditor Account Name</Nm>
</CdtrAcct>
</RltdPties>
</TxDtls>
</NtryDtls>
</Ntry>
</Rpt>
</BkToCstmrAcctRpt>
</Document>
9 changes: 6 additions & 3 deletions test/data/camt052.v4.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"__CLASS__": "Genkgo\\Camt\\Iban",
"getIban": "CH2801234000123456789"
},
"getIdentification": "CH2801234000123456789"
"getIdentification": "CH2801234000123456789",
"getName": null
},
"getAdditionalInformation": "Additional Information",
"getBalances": [
Expand Down Expand Up @@ -205,7 +206,8 @@
"__CLASS__": "Genkgo\\Camt\\Iban",
"getIban": "CH2801234000123456789"
},
"getIdentification": "CH2801234000123456789"
"getIdentification": "CH2801234000123456789",
"getName": null
},
"getRelatedPartyType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
Expand All @@ -221,7 +223,8 @@
"__CLASS__": "Genkgo\\Camt\\Iban",
"getIban": "CH2401234004141414141"
},
"getIdentification": "CH2401234004141414141"
"getIdentification": "CH2401234004141414141",
"getName": null
},
"getRelatedPartyType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Debtor",
Expand Down
9 changes: 6 additions & 3 deletions test/data/camt052.v6.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"__CLASS__": "Genkgo\\Camt\\Iban",
"getIban": "CH2801234000123456789"
},
"getIdentification": "CH2801234000123456789"
"getIdentification": "CH2801234000123456789",
"getName": null
},
"getAdditionalInformation": "Additional Information",
"getBalances": [
Expand Down Expand Up @@ -205,7 +206,8 @@
"__CLASS__": "Genkgo\\Camt\\Iban",
"getIban": "CH2801234000123456789"
},
"getIdentification": "CH2801234000123456789"
"getIdentification": "CH2801234000123456789",
"getName": null
},
"getRelatedPartyType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
Expand All @@ -221,7 +223,8 @@
"__CLASS__": "Genkgo\\Camt\\Iban",
"getIban": "CH2401234004141414141"
},
"getIdentification": "CH2401234004141414141"
"getIdentification": "CH2401234004141414141",
"getName": null
},
"getRelatedPartyType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Debtor",
Expand Down
3 changes: 2 additions & 1 deletion test/data/camt053.v2.all-balance-types.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@
"__CLASS__": "Genkgo\\Camt\\Iban",
"getIban": "NL56AGDH9619008421"
},
"getIdentification": "NL56AGDH9619008421"
"getIdentification": "NL56AGDH9619008421",
"getName": null
},
"getRelatedPartyType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
Expand Down
6 changes: 4 additions & 2 deletions test/data/camt053.v2.five.decimals.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"__CLASS__": "Genkgo\\Camt\\Iban",
"getIban": "NL26VAYB8060476890"
},
"getIdentification": "NL26VAYB8060476890"
"getIdentification": "NL26VAYB8060476890",
"getName": null
},
"getAdditionalInformation": "Additional Information",
"getBalances": [
Expand Down Expand Up @@ -139,7 +140,8 @@
"__CLASS__": "Genkgo\\Camt\\Iban",
"getIban": "NL56AGDH9619008421"
},
"getIdentification": "NL56AGDH9619008421"
"getIdentification": "NL56AGDH9619008421",
"getName": null
},
"getRelatedPartyType": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
Expand Down
Loading