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: genkgo#146
Related: genkgo#116

Conflicts:
	src/DTO/Entry.php
	src/DTO/EntryTransactionDetail.php
	src/Decoder/EntryTransactionDetail.php
  • Loading branch information
sbuerk committed Jun 5, 2023
1 parent 65b786b commit e1c42f1
Show file tree
Hide file tree
Showing 23 changed files with 103 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/DTO/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ class Entry
*/
private $status;

/**
* @var string|null
*/
private $creditDebitIndicator;

/**
* @param int $index
*/
Expand Down Expand Up @@ -311,4 +316,21 @@ public function setStatus($status)
{
$this->status = $status;
}

/**
* @return string|null
*/
public function getCreditDebitIndicator()
{
return $this->creditDebitIndicator;
}

/**
* @param string|null $creditDebitIndicator
* @return void
*/
public function setCreditDebitIndicator($creditDebitIndicator)
{
$this->creditDebitIndicator = $creditDebitIndicator;
}
}
22 changes: 22 additions & 0 deletions src/DTO/EntryTransactionDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class EntryTransactionDetail
*/
private $amount;

/**
* @var string|null
*/
private $creditDebitIndicator;

/**
* @param \Genkgo\Camt\DTO\Reference|null $reference
* @return void
Expand Down Expand Up @@ -271,4 +276,21 @@ public function setAmount($amount)
{
$this->amount = $amount;
}

/**
* @return string|null
*/
public function getCreditDebitIndicator()
{
return $this->creditDebitIndicator;
}

/**
* @param string|null $creditDebitIndicator
* @return void
*/
public function setCreditDebitIndicator($creditDebitIndicator)
{
$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 @@ -29,6 +29,7 @@ public function addTransactionDetails($entry, $xmlEntry)
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
14 changes: 14 additions & 0 deletions src/Decoder/EntryTransactionDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ public function __construct(DateDecoderInterface $dateDecoder)
$this->moneyFactory = new MoneyFactory();
}

/**
* @param \Genkgo\Camt\DTO\EntryTransactionDetail $detail
* @param \SimpleXMLElement $CdtDbtInd
* @return void
*/
public function addCreditDebitIdentifier($detail, $CdtDbtInd)
{
$creditDebitIdentifier = (string) $CdtDbtInd;
$creditDebitIdentifier = in_array($creditDebitIdentifier, ['CRDT', 'DBIT'], true)
? $creditDebitIdentifier
: null;
$detail->setCreditDebitIndicator($creditDebitIdentifier);
}

/**
* @param \Genkgo\Camt\DTO\EntryTransactionDetail $detail
* @param \SimpleXMLElement $xmlDetail
Expand Down
4 changes: 4 additions & 0 deletions src/Decoder/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ public function addEntries($record, $xmlRecord)
$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 e1c42f1

Please sign in to comment.