From a9fb23fc5089b2ed773077e518fa10b7938e6cf1 Mon Sep 17 00:00:00 2001 From: Sennur Tas <77441376+ccsenny@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:19:24 +0200 Subject: [PATCH] Add BNP Paribas bank (#58) * Adjust eref information for the ING bank. This bank gives the payment information in both the /EREF/ field and the /REMI/USTD// field. * Add BNP Paribas bank --- lib/Jejik/MT940/Parser/Paribas.php | 37 +++++++++ lib/Jejik/MT940/Reader.php | 1 + .../Tests/MT940/Fixture/document/paribas.txt | 22 ++++++ .../Jejik/Tests/MT940/Parser/ParibasTest.php | 79 +++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 lib/Jejik/MT940/Parser/Paribas.php create mode 100644 tests/Jejik/Tests/MT940/Fixture/document/paribas.txt create mode 100644 tests/Jejik/Tests/MT940/Parser/ParibasTest.php diff --git a/lib/Jejik/MT940/Parser/Paribas.php b/lib/Jejik/MT940/Parser/Paribas.php new file mode 100644 index 0000000..3b4c803 --- /dev/null +++ b/lib/Jejik/MT940/Parser/Paribas.php @@ -0,0 +1,37 @@ +isBLZAllowed($text); + } +} diff --git a/lib/Jejik/MT940/Reader.php b/lib/Jejik/MT940/Reader.php index 7029db5..d665077 100644 --- a/lib/Jejik/MT940/Reader.php +++ b/lib/Jejik/MT940/Reader.php @@ -57,6 +57,7 @@ class Reader 'Triodos' => Parser\Triodos::class, 'UniCreditBank' => Parser\UniCreditBank::class, 'Bil' => Parser\Bil::class, + 'Paribas' => Parser\Paribas::class, ); /** diff --git a/tests/Jejik/Tests/MT940/Fixture/document/paribas.txt b/tests/Jejik/Tests/MT940/Fixture/document/paribas.txt new file mode 100644 index 0000000..3159151 --- /dev/null +++ b/tests/Jejik/Tests/MT940/Fixture/document/paribas.txt @@ -0,0 +1,22 @@ +:20:TELEREPORTING +:21:TELEREPORTING +:25:12345678/0123456789EUR +:28C:00001/00001 +:60F:C240731EUR0,00 +:61:2408010801D10,00NCOMNONREF//TB-CA-TB001ZQ0 +BNPP Fees - 202408DE00292772 +:86:808?00ENTGELTE / FEES?20BNPP Fees - 202408DE1234567?212 - 07/2024 +/?32INVOICE +:62F:D240801EUR10,00 +- +:20:TELEREPORTING +:21:TELEREPORTING +:25:51210600/3023166036EUR +:28C:00001/00001 +:60F:C240731EUR0,00 +:61:2408010801D10,00NCOMNONREF//TB-CA-TB001ZQ0 +BNPP Fees - 202408DE00292772 +:86:808?00ENTGELTE / FEES?20BNPP Fees - 202408DE1234567?212 - 07/2024 +/?32INVOICE +:62F:D240801EUR10,00 +- diff --git a/tests/Jejik/Tests/MT940/Parser/ParibasTest.php b/tests/Jejik/Tests/MT940/Parser/ParibasTest.php new file mode 100644 index 0000000..efd1d0e --- /dev/null +++ b/tests/Jejik/Tests/MT940/Parser/ParibasTest.php @@ -0,0 +1,79 @@ +addParser('Paribas', \Jejik\MT940\Parser\Paribas::class); + $this->statements = $reader->getStatements(file_get_contents(__DIR__ . '/../Fixture/document/paribas.txt')); + } + + public function testStatement() + { + $this->assertCount(2, $this->statements); + $statement = $this->statements[0]; + + $this->assertEquals('00001/00001', $statement->getNumber()); + $this->assertNotNull($statement->getAccount()); + $this->assertEquals('12345678/0123456789EUR', $statement->getAccount()->getNumber()); + } + + public function testBalance() + { + $balance = $this->statements[0]->getOpeningBalance(); + $this->assertInstanceOf(\Jejik\MT940\Balance::class, $balance); + $this->assertEquals('2024-07-31 00:00:00', $balance->getDate()->format('Y-m-d H:i:s')); + $this->assertEquals('EUR', $balance->getCurrency()); + $this->assertEquals(0, $balance->getAmount()); + + $closingBalance = $this->statements[0]->getClosingBalance(); + $this->assertInstanceOf(\Jejik\MT940\Balance::class, $closingBalance); + $this->assertEquals('2024-08-01 00:00:00', $closingBalance->getDate()->format('Y-m-d H:i:s')); + $this->assertEquals('EUR', $closingBalance->getCurrency()); + $this->assertEquals(-10, $closingBalance->getAmount()); + } + + public function testTransaction() + { + $transactions = $this->statements[0]->getTransactions(); + $this->assertCount(1, $transactions); + + $this->assertNull($transactions[0]->getContraAccount()); + $this->assertEquals(-10.00, $transactions[0]->getAmount()); + $expected = "808?00ENTGELTE / FEES?20BNPP Fees - 202408DE1234567?212 - 07/2024\r\n/?32INVOICE"; + $this->assertEquals($expected, $transactions[0]->getDescription()); + $this->assertEquals('2024-08-01 00:00:00', $transactions[0]->getValueDate()->format('Y-m-d H:i:s'), 'Assert Value Date'); + $this->assertEquals('2024-08-01 00:00:00', $transactions[0]->getBookDate()->format('Y-m-d H:i:s'), 'Assert Book Date'); + $this->assertEquals('COM', $transactions[0]->getCode()); + $this->assertEquals('NONREF', $transactions[0]->getRef()); + $this->assertEquals('TB', $transactions[0]->getBankRef()); + $this->assertEquals('808', $transactions[0]->getGVC()); + $this->assertEquals('ENTGELTE', $transactions[0]->getTxText()); + $this->assertEquals( + null, + $transactions[0]->getEref() + ); + $this->assertNull($transactions[0]->getExtCode()); + $this->assertEquals(null, $transactions[0]->getBIC()); + $this->assertEquals(null, $transactions[0]->getIBAN()); + $this->assertEquals(INVOICE, $transactions[0]->getAccountHolder()); + $this->assertEquals('BNPP Fees - 202408DE12345672 - 07/2024/', $transactions[0]->getRawSubfieldsData()); + } +}