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 detail.

Test fixture files are updated to contain the added fields.

Resolves: #146
Related: #116
  • Loading branch information
sbuerk committed May 25, 2023
1 parent 15f3d03 commit e21e2fd
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 0 deletions.
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 $creditDebitIdentifier = 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 getCreditDebitIdentifier(): ?string
{
return $this->creditDebitIdentifier;
}

public function setCreditDebitIdentifier(?string $creditDebitIdentifier): void
{
$this->creditDebitIdentifier = $creditDebitIdentifier;
}
}
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->setCreditDebitIdentifier($creditDebitIdentifier);
}

public function addReference(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail): void
{
if (false === isset($xmlDetail->Refs)) {
Expand Down
1 change: 1 addition & 0 deletions test/data/camt052.v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
}
},
"getCharges": null,
"getCreditDebitIdentifier": "DBIT",
"getReference": null,
"getRelatedAgent": {
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
Expand Down
1 change: 1 addition & 0 deletions test/data/camt052.v2.other-account.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
}
},
"getCharges": null,
"getCreditDebitIdentifier": "DBIT",
"getReference": null,
"getRelatedAgent": {
"__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent",
Expand Down
1 change: 1 addition & 0 deletions test/data/camt052.v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
}
}
},
"getCreditDebitIdentifier": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
1 change: 1 addition & 0 deletions test/data/camt052.v6.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
}
}
},
"getCreditDebitIdentifier": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
1 change: 1 addition & 0 deletions test/data/camt053.v2.five.decimals.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
}
},
"getCharges": null,
"getCreditDebitIdentifier": "CRDT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
1 change: 1 addition & 0 deletions test/data/camt053.v2.minimal.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
}
},
"getCharges": null,
"getCreditDebitIdentifier": "CRDT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
1 change: 1 addition & 0 deletions test/data/camt053.v2.minimal.ultimate.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
}
},
"getCharges": null,
"getCreditDebitIdentifier": "CRDT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
1 change: 1 addition & 0 deletions test/data/camt053.v2.multi.statement.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
}
},
"getCharges": null,
"getCreditDebitIdentifier": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
1 change: 1 addition & 0 deletions test/data/camt053.v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIdentifier": "CRDT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
1 change: 1 addition & 0 deletions test/data/camt053.v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIdentifier": "CRDT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
1 change: 1 addition & 0 deletions test/data/camt053.v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIdentifier": "CRDT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
3 changes: 3 additions & 0 deletions test/data/camt054.v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIdentifier": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down Expand Up @@ -150,6 +151,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIdentifier": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down Expand Up @@ -216,6 +218,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIdentifier": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
3 changes: 3 additions & 0 deletions test/data/camt054.v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
}
},
"getCharges": null,
"getCreditDebitIdentifier": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down Expand Up @@ -262,6 +263,7 @@
}
},
"getCharges": null,
"getCreditDebitIdentifier": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down Expand Up @@ -405,6 +407,7 @@
}
},
"getCharges": null,
"getCreditDebitIdentifier": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
1 change: 1 addition & 0 deletions test/data/camt054.v8-with-UETR.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIdentifier": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down
1 change: 1 addition & 0 deletions test/data/camt054.v8-with-financial-institution.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"getProprietary": null
},
"getCharges": null,
"getCreditDebitIdentifier": "DBIT",
"getReference": null,
"getRelatedAgent": null,
"getRelatedAgents": [],
Expand Down
3 changes: 3 additions & 0 deletions test/data/camt054.v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
}
},
"getCharges": null,
"getCreditDebitIdentifier": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down Expand Up @@ -262,6 +263,7 @@
}
},
"getCharges": null,
"getCreditDebitIdentifier": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down Expand Up @@ -405,6 +407,7 @@
}
},
"getCharges": null,
"getCreditDebitIdentifier": "DBIT",
"getReference": {
"__CLASS__": "Genkgo\\Camt\\DTO\\Reference",
"getAccountOwnerTransactionId": null,
Expand Down

0 comments on commit e21e2fd

Please sign in to comment.