Skip to content

Commit

Permalink
[FEATURE] Add CreditDebitIdentifier to entry transaction detail
Browse files Browse the repository at this point in the history
The credit-debit-identifier (CrdDbtInd) have been used for
several details, e.g. amount, to proper represent values.
The information itself is not added.

As it could not be reliable retrieved from subvalues what
the original state was, this change now adds that detail
directly to the transaction details and the entry itself.

Test fixture files are updated to contain the added fields.

Resolves: #146
Related: #116
  • Loading branch information
sbuerk authored and PowerKiKi committed May 30, 2023
1 parent 15f3d03 commit 34d5bdf
Show file tree
Hide file tree
Showing 23 changed files with 78 additions and 0 deletions.
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)
? $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

0 comments on commit 34d5bdf

Please sign in to comment.