Skip to content
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

[FEATURE] Add CreditDebitIdentifier to entry transaction detail #147

Merged
merged 1 commit into from
May 30, 2023
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
12 changes: 12 additions & 0 deletions src/DTO/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class Entry

private ?string $status = null;

private ?string $creditDebitIndicator = null;

public function __construct(Record $record, int $index, Money $amount)
{
$this->record = $record;
Expand Down Expand Up @@ -186,4 +188,14 @@ public function setStatus(?string $status): void
{
$this->status = $status;
}

public function getCreditDebitIndicator(): ?string
{
return $this->creditDebitIndicator;
}

public function setCreditDebitIndicator(?string $creditDebitIndicator): void
{
$this->creditDebitIndicator = $creditDebitIndicator;
}
}
12 changes: 12 additions & 0 deletions src/DTO/EntryTransactionDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class EntryTransactionDetail

private ?Money $amount = null;

private ?string $creditDebitIndicator = null;

public function setReference(?Reference $reference): void
{
$this->reference = $reference;
Expand Down Expand Up @@ -169,4 +171,14 @@ public function setAmount(?Money $amount): void
{
$this->amount = $amount;
}

public function getCreditDebitIndicator(): ?string
{
return $this->creditDebitIndicator;
}

public function setCreditDebitIndicator(?string $creditDebitIndicator): void
{
$this->creditDebitIndicator = $creditDebitIndicator;
}
}
1 change: 1 addition & 0 deletions src/Decoder/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function addTransactionDetails(DTO\Entry $entry, SimpleXMLElement $xmlEnt
if ($xmlDetails !== null) {
foreach ($xmlDetails as $xmlDetail) {
$detail = new DTO\EntryTransactionDetail();
$this->entryTransactionDetailDecoder->addCreditDebitIdentifier($detail, $xmlEntry->CdtDbtInd);
$this->entryTransactionDetailDecoder->addReference($detail, $xmlDetail);
$this->entryTransactionDetailDecoder->addRelatedParties($detail, $xmlDetail);
$this->entryTransactionDetailDecoder->addRelatedAgents($detail, $xmlDetail);
Expand Down
9 changes: 9 additions & 0 deletions src/Decoder/EntryTransactionDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ public function __construct(DateDecoderInterface $dateDecoder)
$this->moneyFactory = new MoneyFactory();
}

public function addCreditDebitIdentifier(DTO\EntryTransactionDetail $detail, SimpleXMLElement $CdtDbtInd): void
{
$creditDebitIdentifier = (string) $CdtDbtInd;
$creditDebitIdentifier = in_array($creditDebitIdentifier, ['CRDT', 'DBIT'], true)
PowerKiKi marked this conversation as resolved.
Show resolved Hide resolved
? $creditDebitIdentifier
: null;
$detail->setCreditDebitIndicator($creditDebitIdentifier);
}

public function addReference(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail): void
{
if (false === isset($xmlDetail->Refs)) {
Expand Down
4 changes: 4 additions & 0 deletions src/Decoder/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public function addEntries(DTO\Record $record, SimpleXMLElement $xmlRecord): voi
$entry->setBatchPaymentId((string) $xmlEntry->NtryDtls->TxDtls->Refs->PmtInfId);
}

if (isset($xmlEntry->CdtDbtInd) && in_array((string) $xmlEntry->CdtDbtInd, ['CRDT', 'DBIT'], true)) {
$entry->setCreditDebitIndicator((string) $xmlEntry->CdtDbtInd);
}

$entry->setStatus($this->readStatus($xmlEntry));

if (isset($xmlEntry->BkTxCd)) {
Expand Down
1 change: 1 addition & 0 deletions test/data/camt052.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"0": "2007-10-18T09:15:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt052\\DTO\\Report",
Expand Down
2 changes: 2 additions & 0 deletions test/data/camt052.v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"0": "2007-10-18T09:15:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt052\\DTO\\Report",
Expand Down Expand Up @@ -86,6 +87,7 @@
}
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getReference": null,
"getRelatedAgent": {
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
Expand Down
2 changes: 2 additions & 0 deletions test/data/camt052.v2.other-account.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"0": "2007-10-18T09:15:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt052\\DTO\\Report",
Expand Down Expand Up @@ -86,6 +87,7 @@
}
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getReference": null,
"getRelatedAgent": {
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
Expand Down
2 changes: 2 additions & 0 deletions test/data/camt052.v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"0": "2007-10-18T00:00:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt052\\DTO\\Report",
Expand Down Expand Up @@ -139,6 +140,7 @@
}
}
},
"getCreditDebitIndicator": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
2 changes: 2 additions & 0 deletions test/data/camt052.v6.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"0": "2007-10-18T00:00:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt052\\DTO\\Report",
Expand Down Expand Up @@ -139,6 +140,7 @@
}
}
},
"getCreditDebitIndicator": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
1 change: 1 addition & 0 deletions test/data/camt052.v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"0": "2007-10-18T09:15:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt052\\DTO\\Report",
Expand Down
2 changes: 2 additions & 0 deletions test/data/camt053.v2.five.decimals.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"0": "2014-12-31T00:00:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "CRDT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt053\\DTO\\Statement",
Expand Down Expand Up @@ -107,6 +108,7 @@
}
},
"getCharges": null,
"getCreditDebitIndicator": "CRDT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
2 changes: 2 additions & 0 deletions test/data/camt053.v2.minimal.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"0": "2014-12-31T00:00:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "CRDT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt053\\DTO\\Statement",
Expand Down Expand Up @@ -145,6 +146,7 @@
}
},
"getCharges": null,
"getCreditDebitIndicator": "CRDT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
2 changes: 2 additions & 0 deletions test/data/camt053.v2.minimal.ultimate.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"0": "2014-12-31T00:00:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "CRDT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt053\\DTO\\Statement",
Expand Down Expand Up @@ -145,6 +146,7 @@
}
},
"getCharges": null,
"getCreditDebitIndicator": "CRDT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
2 changes: 2 additions & 0 deletions test/data/camt053.v2.multi.statement.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"0": "2014-12-31T00:00:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt053\\DTO\\Statement",
Expand Down Expand Up @@ -107,6 +108,7 @@
}
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
2 changes: 2 additions & 0 deletions test/data/camt053.v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"0": "2014-12-31T00:00:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "CRDT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt053\\DTO\\Statement",
Expand Down Expand Up @@ -154,6 +155,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIndicator": "CRDT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
2 changes: 2 additions & 0 deletions test/data/camt053.v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"0": "2014-12-31T00:00:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "CRDT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt053\\DTO\\Statement",
Expand Down Expand Up @@ -153,6 +154,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIndicator": "CRDT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
2 changes: 2 additions & 0 deletions test/data/camt053.v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"0": "2014-12-31T12:15:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "CRDT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt053\\DTO\\Statement",
Expand Down Expand Up @@ -153,6 +154,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIndicator": "CRDT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
4 changes: 4 additions & 0 deletions test/data/camt054.v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"0": "2007-10-18T12:15:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt054\\DTO\\Notification",
Expand Down Expand Up @@ -77,6 +78,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down Expand Up @@ -150,6 +152,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down Expand Up @@ -216,6 +219,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
4 changes: 4 additions & 0 deletions test/data/camt054.v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"0": "2007-10-18T00:00:00+00:00"
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt054\\DTO\\Notification",
Expand Down Expand Up @@ -112,6 +113,7 @@
}
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down Expand Up @@ -262,6 +264,7 @@
}
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down Expand Up @@ -405,6 +408,7 @@
}
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
2 changes: 2 additions & 0 deletions test/data/camt054.v8-with-UETR.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"getBatchPaymentId": null,
"getBookingDate": null,
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt054\\DTO\\Notification",
Expand Down Expand Up @@ -62,6 +63,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
2 changes: 2 additions & 0 deletions test/data/camt054.v8-with-financial-institution.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"getBatchPaymentId": null,
"getBookingDate": null,
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getIndex": 0,
"getRecord": {
"__CLASS__": "Genkgo\\Camt\\Camt054\\DTO\\Notification",
Expand Down Expand Up @@ -62,6 +63,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIndicator": "DBIT",
"getReference": null,
"getRelatedAgent": null,
"getRelatedAgents": [],
Expand Down
Loading