Skip to content

Commit

Permalink
Add BNP Paribas bank (#58)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ccsenny authored Oct 22, 2024
1 parent cf21d1a commit a9fb23f
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 0 deletions.
37 changes: 37 additions & 0 deletions lib/Jejik/MT940/Parser/Paribas.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace Jejik\MT940\Parser;

/**
* Class Paribas
* @package Jejik\MT940\Parser
*/
class Paribas extends GermanBank
{
/**
* @inheritDoc
*/
public function getAllowedBLZ(): array
{
return [51210600];
}

/**
* @inheritDoc
*/
public function accept(string $text): bool
{
$allowedUniqueIdentifiers = [
':20:TELEREPORTING'
];

$mt940Identifier = substr($text, 0, 17);
if (in_array($mt940Identifier, $allowedUniqueIdentifiers)) {
return true;
}

return $this->isBLZAllowed($text);
}
}
1 change: 1 addition & 0 deletions lib/Jejik/MT940/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Reader
'Triodos' => Parser\Triodos::class,
'UniCreditBank' => Parser\UniCreditBank::class,
'Bil' => Parser\Bil::class,
'Paribas' => Parser\Paribas::class,
);

/**
Expand Down
22 changes: 22 additions & 0 deletions tests/Jejik/Tests/MT940/Fixture/document/paribas.txt
Original file line number Diff line number Diff line change
@@ -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
-
79 changes: 79 additions & 0 deletions tests/Jejik/Tests/MT940/Parser/ParibasTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

declare(strict_types=1);

namespace Jejik\Tests\MT940\Parser;

use Jejik\MT940\Reader;
use PHPUnit\Framework\TestCase;

/**
* Class ParibasTest
* @package Jejik\Tests\MT940\Parser
*/
class ParibasTest extends TestCase
{
public $statements = [];

/**
* @throws \Jejik\MT940\Exception\NoParserFoundException
*/
public function setUp(): void
{
$reader = new Reader();
$reader->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());
}
}

0 comments on commit a9fb23f

Please sign in to comment.