-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added LBBW Bank (Draft)
- Loading branch information
Showing
4 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Jejik\MT940 library | ||
* | ||
* Copyright (c) 2020 Powercloud GmbH <d.richter@powercloud.de> | ||
* Licensed under the MIT license | ||
* | ||
* For the full copyright and license information, please see the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Jejik\MT940\Parser; | ||
|
||
/** | ||
* Sparkasse provides a parser for Sparkasse Bank | ||
* @package Jejik\MT940\Parser | ||
*/ | ||
class Lbbw extends GermanBank | ||
{ | ||
/** | ||
* Test if the document can be read by the parser | ||
*/ | ||
public function accept(string $text): bool | ||
{ | ||
$allowedUniqueIdentifiers = [ | ||
':20:LBBW' | ||
]; | ||
|
||
// unique identifier check | ||
$mt940Identifier = substr($text, 0, 8); | ||
if (in_array($mt940Identifier, $allowedUniqueIdentifiers)) { | ||
return true; | ||
} | ||
|
||
// if not check it's BLZ | ||
return $this->isBLZAllowed($text); | ||
} | ||
|
||
/** | ||
* Get an array of allowed BLZ for this bank | ||
*/ | ||
public function getAllowedBLZ(): array | ||
{ | ||
return [ | ||
]; | ||
} | ||
|
||
/** | ||
* Get the contra account from a transaction | ||
* | ||
* @param array $lines The transaction text at offset 0 and the description at offset 1 | ||
*/ | ||
protected function contraAccountNumber(array $lines): ?string | ||
{ | ||
if (preg_match('/\?31(.*?)\?32/s', $lines[1], $match)) { | ||
return trim(preg_replace('/\s\s+/', '', $match[1])); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
protected function contraAccountName(array $lines): ?string | ||
{ | ||
if (preg_match('/\?32(.*?)\?34/s', $lines[1], $match)) { | ||
return trim(preg_replace('/\s\s+/', '', $match[1])); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
//TODO: reformat :86: Mehrzweckfeld | ||
protected function description(?string $description): ?string | ||
{ | ||
return parent::description($description); // TODO: Change the autogenerated stub | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
:20:LBBW | ||
:21:NONREF | ||
:25:12345678/1324357 | ||
:28C:1 | ||
:60F:C210120EUR0,00 | ||
:61:2102080208D0,01NCMZNONREF | ||
:86:834?00KONTENPOOL?102?20BUCHUNG AUF KTO 7402050699?21BANKLEITZAHL | ||
60050101?3060050101?3111111111 | ||
:61:2102080208C0,01NCOLKREF+//202102040007693 | ||
:86:171?00SEPA EINZUGSAUFTRAG?101?20KREF+SEPA-20210203175805-00?21154 | ||
800-P1?22SVWZ+E-MOBILITY ABRECHNUNG?23NR. 28 ZU VERTRAG 9433, KUN | ||
?24DENNUMMER 11111?30SOLADEST600?31DE59600501010007907986?32NIC R | ||
ICHTER | ||
:62F:C210208EUR0,00 | ||
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Jejik\MT940 library | ||
* | ||
* Copyright (c) 2020 Powercloud GmbH <d.richter@powercloud.de> | ||
* Licensed under the MIT license | ||
* | ||
* For the full copyright and license information, please see the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Jejik\Tests\MT940\Parser; | ||
|
||
use Jejik\MT940\Reader; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Tests for Jejik\MT940\Parser\Sparkasse | ||
* | ||
* @author Dominic Richter <d.richter@powercloud.de> | ||
*/ | ||
class LbbwTest extends TestCase | ||
{ | ||
public $statements = []; | ||
|
||
/** | ||
* @throws \Jejik\MT940\Exception\NoParserFoundException | ||
*/ | ||
public function setUp(): void | ||
{ | ||
$reader = new Reader(); | ||
$reader->addParser('Lbbw', \Jejik\MT940\Parser\Lbbw::class); | ||
$this->statements = $reader->getStatements(file_get_contents(__DIR__ . '/../Fixture/document/lbbw.txt')); | ||
} | ||
|
||
public function testStatement() | ||
{ | ||
$this->assertCount(1, $this->statements, 'Assert counting statements.'); | ||
$statement = $this->statements[0]; | ||
|
||
$this->assertEquals('1', $statement->getNumber()); | ||
$this->assertEquals('12345678/1324357', $statement->getAccount()->getNumber()); | ||
} | ||
|
||
public function testBalance() | ||
{ | ||
$balance = $this->statements[0]->getOpeningBalance(); | ||
$this->assertInstanceOf(\Jejik\MT940\Balance::class, $balance); | ||
$this->assertEquals('2021-01-20 00:00:00', $balance->getDate()->format('Y-m-d H:i:s')); | ||
$this->assertEquals('EUR', $balance->getCurrency()); | ||
$this->assertEquals(0, $balance->getAmount()); | ||
} | ||
|
||
public function testTransaction() | ||
{ | ||
$transactions = $this->statements[0]->getTransactions(); | ||
|
||
$this->assertCount(2, $transactions); | ||
|
||
$this->assertNull($transactions[0]->getContraAccount()); | ||
|
||
$this->assertEquals(-0.01, $transactions[0]->getAmount()); | ||
$expectedDescription = "834?00KONTENPOOL?102?20BUCHUNG AUF KTO 7402050699?21BANKLEITZAHL\r | ||
60050101?3060050101?3111111111"; | ||
$this->assertEquals($expectedDescription, $transactions[0]->getDescription()); | ||
$this->assertEquals('2021-02-08 00:00:00', $transactions[0]->getValueDate()->format('Y-m-d H:i:s'), 'Assert Value Date'); | ||
$this->assertEquals('2021-02-08 00:00:00', $transactions[0]->getBookDate()->format('Y-m-d H:i:s'), 'Assert Book Date'); | ||
|
||
$this->assertEquals('CMZ', $transactions[0]->getCode()); | ||
$this->assertEquals('NONREF', $transactions[0]->getRef()); | ||
$this->assertEquals('NONREF', $transactions[0]->getBankRef()); | ||
|
||
$this->assertEquals('834', $transactions[0]->getGVC()); | ||
$this->assertEquals('KONTENPOOL', $transactions[0]->getTxText()); | ||
$this->assertEquals('2', $transactions[0]->getPrimanota()); | ||
$this->assertNull($transactions[0]->getExtCode()); | ||
$this->assertNull($transactions[0]->getEref()); | ||
$this->assertEquals('60050101', $transactions[0]->getBIC()); | ||
$this->assertEquals('11111111', $transactions[0]->getIBAN()); | ||
$this->assertNull($transactions[0]->getAccountHolder()); | ||
$this->assertNull($transactions[0]->getKref()); | ||
$this->assertNull($transactions[0]->getMref()); | ||
$this->assertNull($transactions[0]->getCred()); | ||
$this->assertNull($transactions[0]->getSvwz()); | ||
|
||
$this->assertEquals('NIC RICHTER', $transactions[1]->getAccountHolder()); | ||
$this->assertEquals('SEPA-20210203175805-00154800-P1', $transactions[1]->getKref()); | ||
$this->assertNull($transactions[1]->getMref()); | ||
$this->assertNull($transactions[1]->getCred()); | ||
$this->assertEquals( | ||
'E-MOBILITY ABRECHNUNGNR. 28 ZU VERTRAG 9433, KUNDENNUMMER 11111', | ||
$transactions[1]->getSvwz() | ||
); | ||
} | ||
} |