diff --git a/src/Camt054/DTO/Notification.php b/src/Camt054/DTO/Notification.php index 103edbf..7795adf 100644 --- a/src/Camt054/DTO/Notification.php +++ b/src/Camt054/DTO/Notification.php @@ -4,8 +4,23 @@ namespace Genkgo\Camt\Camt054\DTO; +use DateTimeImmutable; +use Genkgo\Camt\DTO\Account; use Genkgo\Camt\DTO\Record; class Notification extends Record { + protected ?DateTimeImmutable $createdOn; + + public function __construct(string $id, ?DateTimeImmutable $createdOn, Account $account) + { + parent::__construct($id, $account); + + $this->createdOn = $createdOn; + } + + public function getCreatedOn(): ?DateTimeImmutable + { + return $this->createdOn; + } } diff --git a/src/Camt054/Decoder/Message.php b/src/Camt054/Decoder/Message.php index 1e92368..b21eb8a 100644 --- a/src/Camt054/Decoder/Message.php +++ b/src/Camt054/Decoder/Message.php @@ -20,9 +20,10 @@ public function addRecords(DTO\Message $message, SimpleXMLElement $document): vo $xmlNotifications = $this->getRootElement($document)->Ntfctn; foreach ($xmlNotifications as $xmlNotification) { + $createdOn = (string) $xmlNotification->CreDtTm; $notification = new Camt054DTO\Notification( (string) $xmlNotification->Id, - $this->dateDecoder->decode((string) $xmlNotification->CreDtTm), + $createdOn ? $this->dateDecoder->decode($createdOn) : null, $this->getAccount($xmlNotification) ); diff --git a/src/DTO/Record.php b/src/DTO/Record.php index 9ee4cad..698b4f6 100644 --- a/src/DTO/Record.php +++ b/src/DTO/Record.php @@ -10,8 +10,6 @@ abstract class Record { protected string $id; - protected DateTimeImmutable $createdOn; - protected Account $account; protected ?Pagination $pagination = null; @@ -33,10 +31,9 @@ abstract class Record protected ?string $additionalInformation = null; - public function __construct(string $id, DateTimeImmutable $createdOn, Account $account) + public function __construct(string $id, Account $account) { $this->id = $id; - $this->createdOn = $createdOn; $this->account = $account; } @@ -45,11 +42,6 @@ public function getId(): string return $this->id; } - public function getCreatedOn(): DateTimeImmutable - { - return $this->createdOn; - } - public function getAccount(): Account { return $this->account; diff --git a/src/DTO/RecordWithBalances.php b/src/DTO/RecordWithBalances.php index 9312696..ec4b2ff 100644 --- a/src/DTO/RecordWithBalances.php +++ b/src/DTO/RecordWithBalances.php @@ -4,8 +4,24 @@ namespace Genkgo\Camt\DTO; +use DateTimeImmutable; + abstract class RecordWithBalances extends Record { + protected DateTimeImmutable $createdOn; + + public function __construct(string $id, DateTimeImmutable $createdOn, Account $account) + { + parent::__construct($id, $account); + + $this->createdOn = $createdOn; + } + + public function getCreatedOn(): DateTimeImmutable + { + return $this->createdOn; + } + /** * @var Balance[] */ diff --git a/test/data/camt054.v8-grphdr-credttm.json b/test/data/camt054.v8-grphdr-credttm.json new file mode 100644 index 0000000..a254ddd --- /dev/null +++ b/test/data/camt054.v8-grphdr-credttm.json @@ -0,0 +1,152 @@ +{ + "__CLASS__": "Genkgo\\Camt\\DTO\\Message", + "getEntries": [ + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Entry", + "getAccountServicerReference": null, + "getAdditionalInfo": "", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "4740", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "EUR" + } + }, + "getBankTransactionCode": { + "__CLASS__": "Genkgo\\Camt\\DTO\\BankTransactionCode", + "getDomain": { + "__CLASS__": "Genkgo\\Camt\\DTO\\DomainBankTransactionCode", + "getCode": "PMNT", + "getFamily": { + "__CLASS__": "Genkgo\\Camt\\DTO\\DomainFamilyBankTransactionCode", + "getCode": "RRCT", + "getSubFamilyCode": "ESCT" + } + }, + "getProprietary": null + }, + "getBatchPaymentId": null, + "getBookingDate": null, + "getCharges": null, + "getCreditDebitIndicator": "CRDT", + "getIndex": 0, + "getRecord": { + "__CLASS__": "Genkgo\\Camt\\Camt054\\DTO\\Notification", + "getAccount": { + "__CLASS__": "Genkgo\\Camt\\DTO\\IbanAccount", + "getIban": { + "__CLASS__": "Genkgo\\Camt\\Iban", + "getIban": "DE91100000000123456789" + }, + "getIdentification": "DE91100000000123456789", + "getName": null + }, + "getAdditionalInformation": null, + "getCopyDuplicateIndicator": null, + "getCreatedOn": null, + "getElectronicSequenceNumber": null, + "getEntries": [ + "__RECURSIVITY__" + ], + "getFromDate": null, + "getId": "250326012345678", + "getLegalSequenceNumber": null, + "getPagination": null, + "getToDate": null + }, + "getReference": null, + "getReversalIndicator": false, + "getStatus": "INFO", + "getTransactionDetail": { + "__CLASS__": "Genkgo\\Camt\\DTO\\EntryTransactionDetail", + "getAdditionalTransactionInformation": null, + "getAmount": null, + "getAmountDetails": null, + "getBankTransactionCode": { + "__CLASS__": "Genkgo\\Camt\\DTO\\BankTransactionCode", + "getDomain": null, + "getProprietary": null + }, + "getCharges": null, + "getCreditDebitIndicator": "CRDT", + "getReference": { + "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", + "getAccountOwnerTransactionId": null, + "getAccountServicerReference": null, + "getAccountServicerTransactionId": null, + "getChequeNumber": null, + "getClearingSystemReference": null, + "getEndToEndId": "NOTPROVIDED", + "getInstructionId": null, + "getMandateId": null, + "getMarketInfrastructureTransactionId": null, + "getMessageId": null, + "getPaymentInformationId": null, + "getProcessingId": null, + "getProprietaries": [], + "getTransactionId": null, + "getUuidEndToEndReference": null + }, + "getRelatedAgent": null, + "getRelatedAgents": [], + "getRelatedDates": null, + "getRelatedParties": [ + { + "__CLASS__": "Genkgo\\Camt\\DTO\\RelatedParty", + "getAccount": null, + "getRelatedPartyType": { + "__CLASS__": "Genkgo\\Camt\\DTO\\Creditor", + "getAddress": null, + "getIdentification": null, + "getName": "MyBigCompany GmbH" + } + }, + { + "__CLASS__": "Genkgo\\Camt\\DTO\\RelatedParty", + "getAccount": { + "__CLASS__": "Genkgo\\Camt\\DTO\\IbanAccount", + "getIban": { + "__CLASS__": "Genkgo\\Camt\\Iban", + "getIban": "DE02200505501015871393" + }, + "getIdentification": "DE02200505501015871393", + "getName": null + }, + "getRelatedPartyType": { + "__CLASS__": "Genkgo\\Camt\\DTO\\Debtor", + "getAddress": null, + "getIdentification": null, + "getName": "Remote Party" + } + } + ], + "getRelatedParty": "__RECURSIVITY__", + "getRemittanceInformation": null, + "getReturnInformation": null + }, + "getTransactionDetails": [ + "__RECURSIVITY__" + ], + "getValueDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2025-03-25T00:00:00+00:00" + } + } + ], + "getGroupHeader": { + "__CLASS__": "Genkgo\\Camt\\Camt054\\DTO\\V04\\GroupHeader", + "getAdditionalInformation": null, + "getCreatedOn": { + "__CLASS__": "DateTimeImmutable", + "0": "2025-03-25T20:18:34+00:00" + }, + "getMessageId": "COBADEFF250326012345678", + "getMessageRecipient": null, + "getOriginalBusinessQuery": null, + "getPagination": null + }, + "getRecords": [ + "__RECURSIVITY__" + ] +} diff --git a/test/data/camt054.v8-grphdr-credttm.xml b/test/data/camt054.v8-grphdr-credttm.xml new file mode 100644 index 0000000..ac3b65f --- /dev/null +++ b/test/data/camt054.v8-grphdr-credttm.xml @@ -0,0 +1,65 @@ + + + + + COBADEFF250326012345678 + 2025-03-25T21:18:34+01:00 + + + 250326012345678 + + + DE91100000000123456789 + + + + COBADEFF + + + + + 47.4 + CRDT + + INFO + + +
2025-03-25
+
+ + + PMNT + + RRCT + ESCT + + + + + + + NOTPROVIDED + + + + + Remote Party + + + + + DE02200505501015871393 + + + + + MyBigCompany GmbH + + + + + +
+
+
+
\ No newline at end of file diff --git a/test/data/camt054.v8-ntfctn-credttm.json b/test/data/camt054.v8-ntfctn-credttm.json new file mode 100644 index 0000000..5b09c40 --- /dev/null +++ b/test/data/camt054.v8-ntfctn-credttm.json @@ -0,0 +1,155 @@ +{ + "__CLASS__": "Genkgo\\Camt\\DTO\\Message", + "getEntries": [ + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Entry", + "getAccountServicerReference": null, + "getAdditionalInfo": "", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "4740", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "EUR" + } + }, + "getBankTransactionCode": { + "__CLASS__": "Genkgo\\Camt\\DTO\\BankTransactionCode", + "getDomain": { + "__CLASS__": "Genkgo\\Camt\\DTO\\DomainBankTransactionCode", + "getCode": "PMNT", + "getFamily": { + "__CLASS__": "Genkgo\\Camt\\DTO\\DomainFamilyBankTransactionCode", + "getCode": "RRCT", + "getSubFamilyCode": "ESCT" + } + }, + "getProprietary": null + }, + "getBatchPaymentId": null, + "getBookingDate": null, + "getCharges": null, + "getCreditDebitIndicator": "CRDT", + "getIndex": 0, + "getRecord": { + "__CLASS__": "Genkgo\\Camt\\Camt054\\DTO\\Notification", + "getAccount": { + "__CLASS__": "Genkgo\\Camt\\DTO\\IbanAccount", + "getIban": { + "__CLASS__": "Genkgo\\Camt\\Iban", + "getIban": "DE91100000000123456789" + }, + "getIdentification": "DE91100000000123456789", + "getName": null + }, + "getAdditionalInformation": null, + "getCopyDuplicateIndicator": null, + "getCreatedOn": { + "__CLASS__": "DateTimeImmutable", + "0": "2025-03-25T20:17:59+00:00" + }, + "getElectronicSequenceNumber": null, + "getEntries": [ + "__RECURSIVITY__" + ], + "getFromDate": null, + "getId": "250326012345678", + "getLegalSequenceNumber": null, + "getPagination": null, + "getToDate": null + }, + "getReference": null, + "getReversalIndicator": false, + "getStatus": "INFO", + "getTransactionDetail": { + "__CLASS__": "Genkgo\\Camt\\DTO\\EntryTransactionDetail", + "getAdditionalTransactionInformation": null, + "getAmount": null, + "getAmountDetails": null, + "getBankTransactionCode": { + "__CLASS__": "Genkgo\\Camt\\DTO\\BankTransactionCode", + "getDomain": null, + "getProprietary": null + }, + "getCharges": null, + "getCreditDebitIndicator": "CRDT", + "getReference": { + "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", + "getAccountOwnerTransactionId": null, + "getAccountServicerReference": null, + "getAccountServicerTransactionId": null, + "getChequeNumber": null, + "getClearingSystemReference": null, + "getEndToEndId": "NOTPROVIDED", + "getInstructionId": null, + "getMandateId": null, + "getMarketInfrastructureTransactionId": null, + "getMessageId": null, + "getPaymentInformationId": null, + "getProcessingId": null, + "getProprietaries": [], + "getTransactionId": null, + "getUuidEndToEndReference": null + }, + "getRelatedAgent": null, + "getRelatedAgents": [], + "getRelatedDates": null, + "getRelatedParties": [ + { + "__CLASS__": "Genkgo\\Camt\\DTO\\RelatedParty", + "getAccount": null, + "getRelatedPartyType": { + "__CLASS__": "Genkgo\\Camt\\DTO\\Creditor", + "getAddress": null, + "getIdentification": null, + "getName": "MyBigCompany GmbH" + } + }, + { + "__CLASS__": "Genkgo\\Camt\\DTO\\RelatedParty", + "getAccount": { + "__CLASS__": "Genkgo\\Camt\\DTO\\IbanAccount", + "getIban": { + "__CLASS__": "Genkgo\\Camt\\Iban", + "getIban": "DE02200505501015871393" + }, + "getIdentification": "DE02200505501015871393", + "getName": null + }, + "getRelatedPartyType": { + "__CLASS__": "Genkgo\\Camt\\DTO\\Debtor", + "getAddress": null, + "getIdentification": null, + "getName": "Remote Party" + } + } + ], + "getRelatedParty": "__RECURSIVITY__", + "getRemittanceInformation": null, + "getReturnInformation": null + }, + "getTransactionDetails": [ + "__RECURSIVITY__" + ], + "getValueDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2025-03-25T00:00:00+00:00" + } + } + ], + "getGroupHeader": { + "__CLASS__": "Genkgo\\Camt\\Camt054\\DTO\\V04\\GroupHeader", + "getAdditionalInformation": null, + "getCreatedOn": { + "__CLASS__": "DateTimeImmutable", + "0": "2025-03-25T20:18:34+00:00" + }, + "getMessageId": "COBADEFF250326012345678", + "getMessageRecipient": null, + "getOriginalBusinessQuery": null, + "getPagination": null + }, + "getRecords": [ + "__RECURSIVITY__" + ] +} diff --git a/test/data/camt054.v8-ntfctn-credttm.xml b/test/data/camt054.v8-ntfctn-credttm.xml new file mode 100644 index 0000000..2061660 --- /dev/null +++ b/test/data/camt054.v8-ntfctn-credttm.xml @@ -0,0 +1,66 @@ + + + + + COBADEFF250326012345678 + 2025-03-25T21:18:34+01:00 + + + 250326012345678 + 2025-03-25T21:17:59+01:00 + + + DE91100000000123456789 + + + + COBADEFF + + + + + 47.4 + CRDT + + INFO + + +
2025-03-25
+
+ + + PMNT + + RRCT + ESCT + + + + + + + NOTPROVIDED + + + + + Remote Party + + + + + DE02200505501015871393 + + + + + MyBigCompany GmbH + + + + + +
+
+
+
\ No newline at end of file