diff --git a/lib/Jejik/MT940/Parser/AbstractParser.php b/lib/Jejik/MT940/Parser/AbstractParser.php index 3f8ba25..ffa0e1a 100644 --- a/lib/Jejik/MT940/Parser/AbstractParser.php +++ b/lib/Jejik/MT940/Parser/AbstractParser.php @@ -471,6 +471,7 @@ protected function transaction(array $lines): TransactionInterface ->setCode($this->code($lines)) ->setRef($this->ref($lines)) ->setBankRef($this->bankRef($lines)) + ->setSupplementaryDetails($this->supplementaryDetails($lines)) ->setGVC($this->gvc($lines)) ->setTxText($this->txText($lines)) ->setPrimanota($this->primanota($lines)) @@ -582,6 +583,14 @@ protected function bankRef(array $lines): ?string return null; } + /** + * Parse supplementary details + */ + protected function supplementaryDetails(array $lines): ?string + { + return null; + } + /** * Parse txText for provided transaction lines */ diff --git a/lib/Jejik/MT940/Parser/GermanBank.php b/lib/Jejik/MT940/Parser/GermanBank.php index c51317e..fc1549d 100755 --- a/lib/Jejik/MT940/Parser/GermanBank.php +++ b/lib/Jejik/MT940/Parser/GermanBank.php @@ -74,6 +74,18 @@ protected function code(array $lines): ?string return substr($match[5], 0, 3); } + /** + * Parse supplementary details + */ + protected function supplementaryDetails(array $lines): ?string + { + $refLine = isset($lines[0]) ? $lines[0] : null; + + $parts = preg_split("/\\r\\n|\\r|\\n/", $refLine, 2); + + return isset($parts[1]) ? $parts[1] : null; + } + /** * Parse ref for provided transaction lines */ diff --git a/lib/Jejik/MT940/Transaction.php b/lib/Jejik/MT940/Transaction.php index 21abe3a..b3a2e9c 100644 --- a/lib/Jejik/MT940/Transaction.php +++ b/lib/Jejik/MT940/Transaction.php @@ -63,6 +63,11 @@ class Transaction implements TransactionInterface */ private $bankRef; + /** + * @var string + */ + private $supplementaryDetails; + /** * @var string */ @@ -265,6 +270,25 @@ public function setBankRef(string $bankRef = null): TransactionInterface return $this; } + /** + * @return string|null + */ + public function getSupplementaryDetails(): ?string + { + return $this->supplementaryDetails; + } + + /** + * @param string|null $supplementaryDetails + * @return TransactionInterface + */ + public function setSupplementaryDetails(?string $supplementaryDetails): TransactionInterface + { + $this->supplementaryDetails = $supplementaryDetails; + + return $this; + } + /** * Get GVC for this transaction */ diff --git a/lib/Jejik/MT940/TransactionInterface.php b/lib/Jejik/MT940/TransactionInterface.php index 3bfca86..3b3a52b 100644 --- a/lib/Jejik/MT940/TransactionInterface.php +++ b/lib/Jejik/MT940/TransactionInterface.php @@ -101,6 +101,16 @@ public function getBankRef(): ?string; */ public function setBankRef(string $bankRef = null): TransactionInterface; + /** + * Set supplementary details + */ + public function setSupplementaryDetails(?string $supplementaryDetails): TransactionInterface; + + /** + * Get supplementary details + */ + public function getSupplementaryDetails(): ?string; + /** * Get GVC for this transaction */ diff --git a/tests/Jejik/Tests/MT940/Parser/DeutscheBankTest.php b/tests/Jejik/Tests/MT940/Parser/DeutscheBankTest.php index ee6943a..a881c61 100644 --- a/tests/Jejik/Tests/MT940/Parser/DeutscheBankTest.php +++ b/tests/Jejik/Tests/MT940/Parser/DeutscheBankTest.php @@ -75,6 +75,7 @@ public function testTransaction() $this->assertNull($transactions[0]->getCode()); $this->assertEquals('KREF+', $transactions[0]->getRef()); $this->assertEquals('2016021783252833', $transactions[0]->getBankRef()); + $this->assertEquals('/OCMT/EUR11,85//CHGS/EUR0,50/', $transactions[0]->getSupplementaryDetails()); $this->assertEquals('109', $transactions[0]->getGVC()); $this->assertEquals('SEPA-LASTSCHR. RETOURE CORE', $transactions[0]->getTxText());