diff --git a/src/DTO/Entry.php b/src/DTO/Entry.php index a16fd20..d043f17 100644 --- a/src/DTO/Entry.php +++ b/src/DTO/Entry.php @@ -77,6 +77,11 @@ class Entry */ private $status; + /** + * @var string|null + */ + private $creditDebitIndicator; + /** * @param int $index */ @@ -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; + } } diff --git a/src/DTO/EntryTransactionDetail.php b/src/DTO/EntryTransactionDetail.php index 9774917..ed3abb8 100644 --- a/src/DTO/EntryTransactionDetail.php +++ b/src/DTO/EntryTransactionDetail.php @@ -61,6 +61,11 @@ class EntryTransactionDetail */ private $amount; + /** + * @var string|null + */ + private $creditDebitIndicator; + /** * @param \Genkgo\Camt\DTO\Reference|null $reference * @return void @@ -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; + } } diff --git a/src/Decoder/Entry.php b/src/Decoder/Entry.php index 1c935bf..c3396ae 100644 --- a/src/Decoder/Entry.php +++ b/src/Decoder/Entry.php @@ -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); diff --git a/src/Decoder/EntryTransactionDetail.php b/src/Decoder/EntryTransactionDetail.php index c706e8a..7cef53e 100644 --- a/src/Decoder/EntryTransactionDetail.php +++ b/src/Decoder/EntryTransactionDetail.php @@ -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 diff --git a/src/Decoder/Record.php b/src/Decoder/Record.php index 55cead2..072a749 100644 --- a/src/Decoder/Record.php +++ b/src/Decoder/Record.php @@ -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)) { diff --git a/test/data/camt052.v1.json b/test/data/camt052.v1.json index 3b43659..1ea3d02 100644 --- a/test/data/camt052.v1.json +++ b/test/data/camt052.v1.json @@ -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", diff --git a/test/data/camt052.v2.json b/test/data/camt052.v2.json index 4fac33f..f8cdaa8 100644 --- a/test/data/camt052.v2.json +++ b/test/data/camt052.v2.json @@ -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", @@ -86,6 +87,7 @@ } }, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getReference": null, "getRelatedAgent": { "__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent", diff --git a/test/data/camt052.v2.other-account.json b/test/data/camt052.v2.other-account.json index 7917f8b..f7f5443 100644 --- a/test/data/camt052.v2.other-account.json +++ b/test/data/camt052.v2.other-account.json @@ -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", @@ -86,6 +87,7 @@ } }, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getReference": null, "getRelatedAgent": { "__CLASS__": "Genkgo\\Camt\\DTO\\RelatedAgent", diff --git a/test/data/camt052.v4.json b/test/data/camt052.v4.json index b772760..71a7b92 100644 --- a/test/data/camt052.v4.json +++ b/test/data/camt052.v4.json @@ -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", @@ -139,6 +140,7 @@ } } }, + "getCreditDebitIndicator": "DBIT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, diff --git a/test/data/camt052.v6.json b/test/data/camt052.v6.json index 4bd6bf0..0879fe5 100644 --- a/test/data/camt052.v6.json +++ b/test/data/camt052.v6.json @@ -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", @@ -139,6 +140,7 @@ } } }, + "getCreditDebitIndicator": "DBIT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, diff --git a/test/data/camt052.v8.json b/test/data/camt052.v8.json index d95b33d..b901bb7 100644 --- a/test/data/camt052.v8.json +++ b/test/data/camt052.v8.json @@ -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", diff --git a/test/data/camt053.v2.five.decimals.json b/test/data/camt053.v2.five.decimals.json index 2b5eb4a..d8f6981 100644 --- a/test/data/camt053.v2.five.decimals.json +++ b/test/data/camt053.v2.five.decimals.json @@ -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", @@ -107,6 +108,7 @@ } }, "getCharges": null, + "getCreditDebitIndicator": "CRDT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, diff --git a/test/data/camt053.v2.minimal.json b/test/data/camt053.v2.minimal.json index a7ac52d..cbe15a0 100644 --- a/test/data/camt053.v2.minimal.json +++ b/test/data/camt053.v2.minimal.json @@ -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", @@ -145,6 +146,7 @@ } }, "getCharges": null, + "getCreditDebitIndicator": "CRDT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, diff --git a/test/data/camt053.v2.minimal.ultimate.json b/test/data/camt053.v2.minimal.ultimate.json index 3937683..4480113 100644 --- a/test/data/camt053.v2.minimal.ultimate.json +++ b/test/data/camt053.v2.minimal.ultimate.json @@ -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", @@ -145,6 +146,7 @@ } }, "getCharges": null, + "getCreditDebitIndicator": "CRDT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, diff --git a/test/data/camt053.v2.multi.statement.json b/test/data/camt053.v2.multi.statement.json index 57660b7..a911ef3 100644 --- a/test/data/camt053.v2.multi.statement.json +++ b/test/data/camt053.v2.multi.statement.json @@ -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", @@ -107,6 +108,7 @@ } }, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, diff --git a/test/data/camt053.v3.json b/test/data/camt053.v3.json index 840ac4d..e983811 100644 --- a/test/data/camt053.v3.json +++ b/test/data/camt053.v3.json @@ -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", @@ -154,6 +155,7 @@ "getProprietary": null }, "getCharges": null, + "getCreditDebitIndicator": "CRDT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, diff --git a/test/data/camt053.v4.json b/test/data/camt053.v4.json index 5c1ee9f..0a7cfb3 100644 --- a/test/data/camt053.v4.json +++ b/test/data/camt053.v4.json @@ -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", @@ -153,6 +154,7 @@ "getProprietary": null }, "getCharges": null, + "getCreditDebitIndicator": "CRDT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, diff --git a/test/data/camt053.v8.json b/test/data/camt053.v8.json index f7a03ed..a847bbc 100644 --- a/test/data/camt053.v8.json +++ b/test/data/camt053.v8.json @@ -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", @@ -153,6 +154,7 @@ "getProprietary": null }, "getCharges": null, + "getCreditDebitIndicator": "CRDT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, diff --git a/test/data/camt054.v2.json b/test/data/camt054.v2.json index 71813ab..b1e0b35 100644 --- a/test/data/camt054.v2.json +++ b/test/data/camt054.v2.json @@ -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", @@ -77,6 +78,7 @@ "getProprietary": null }, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, @@ -150,6 +152,7 @@ "getProprietary": null }, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, @@ -216,6 +219,7 @@ "getProprietary": null }, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, diff --git a/test/data/camt054.v4.json b/test/data/camt054.v4.json index 3341e45..bfea1e3 100644 --- a/test/data/camt054.v4.json +++ b/test/data/camt054.v4.json @@ -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", @@ -112,6 +113,7 @@ } }, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, @@ -262,6 +264,7 @@ } }, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, @@ -405,6 +408,7 @@ } }, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, diff --git a/test/data/camt054.v8-with-UETR.json b/test/data/camt054.v8-with-UETR.json index 037d47c..e219721 100644 --- a/test/data/camt054.v8-with-UETR.json +++ b/test/data/camt054.v8-with-UETR.json @@ -21,6 +21,7 @@ "getBatchPaymentId": null, "getBookingDate": null, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getIndex": 0, "getRecord": { "__CLASS__": "Genkgo\\Camt\\Camt054\\DTO\\Notification", @@ -62,6 +63,7 @@ "getProprietary": null }, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, diff --git a/test/data/camt054.v8-with-financial-institution.json b/test/data/camt054.v8-with-financial-institution.json index a9b2863..947ae78 100644 --- a/test/data/camt054.v8-with-financial-institution.json +++ b/test/data/camt054.v8-with-financial-institution.json @@ -21,6 +21,7 @@ "getBatchPaymentId": null, "getBookingDate": null, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getIndex": 0, "getRecord": { "__CLASS__": "Genkgo\\Camt\\Camt054\\DTO\\Notification", @@ -62,6 +63,7 @@ "getProprietary": null }, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getReference": null, "getRelatedAgent": null, "getRelatedAgents": [], diff --git a/test/data/camt054.v8.json b/test/data/camt054.v8.json index 3341e45..bfea1e3 100644 --- a/test/data/camt054.v8.json +++ b/test/data/camt054.v8.json @@ -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", @@ -112,6 +113,7 @@ } }, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, @@ -262,6 +264,7 @@ } }, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null, @@ -405,6 +408,7 @@ } }, "getCharges": null, + "getCreditDebitIndicator": "DBIT", "getReference": { "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", "getAccountOwnerTransactionId": null,