-
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.
corrected getTransactionLines if interim balance is at the end of the…
… file (#44)
- Loading branch information
Showing
7 changed files
with
136 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/phpunit.xml | ||
/vendor | ||
.idea | ||
.phpunit.result.cache |
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
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
28 changes: 28 additions & 0 deletions
28
tests/Jejik/Tests/MT940/Fixture/document/sparkasse_interim_balance.txt
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,28 @@ | ||
:20:STARTUMSE | ||
:25:87052000/123456789 | ||
:28C:00000/001 | ||
:60F:C190215EUR194,57 | ||
:61:1902180218DR20,00N037NONREF | ||
:86:106?00KARTENZAHLUNG?109262?20SVWZ+2019-02-15T20.10 Debit?21k. | ||
4 2019-12?22ABWA+Aral Tankstelle Chemni?23tz Leipziger Straße 257 | ||
//Ch?24emnitz/DE?30DRESDEFF430?31DE95430800830802029200?32ARAL AG | ||
?34011 | ||
:62F:C190218EUR174,57 | ||
- | ||
:20:STARTUMSE | ||
:25:87052000/123456789 | ||
:28C:00000/001 | ||
:60F:C190218EUR174,57 | ||
:61:1902190219DR20,00N033NONREF | ||
:86:177?00ONLINE-UEBERWEISUNG?109310?20SVWZ+Apple Pay?21DATUM 19. | ||
02.2019, 13.24 UHR?221.TAN 002153?30NTSBDEB1XXX?31DE1234567890123 | ||
4567890?32Max Mustermann?34997 | ||
:62F:C190219EUR154,57 | ||
- | ||
:20:STARTUMSE | ||
:25:87052000/123456789 | ||
:28C:00215/00129 | ||
:60M:C211102EUR0, | ||
:62F:C211102EUR0, | ||
:64:C211102EUR0, | ||
- |
96 changes: 96 additions & 0 deletions
96
tests/Jejik/Tests/MT940/Parser/SparkasseInterimBalanceTest.php
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,96 @@ | ||
<?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 SparkasseInterimBalanceTest extends TestCase | ||
{ | ||
public $statements = []; | ||
|
||
/** | ||
* @throws \Jejik\MT940\Exception\NoParserFoundException | ||
*/ | ||
public function setUp(): void | ||
{ | ||
$reader = new Reader(); | ||
$reader->addParser('Sparkasse', \Jejik\MT940\Parser\Sparkasse::class); | ||
$this->statements = $reader->getStatements(file_get_contents(__DIR__ . '/../Fixture/document/sparkasse_interim_balance.txt')); | ||
} | ||
|
||
public function testStatement() | ||
{ | ||
$this->assertCount(3, $this->statements, 'Assert counting statements.'); | ||
$statement = $this->statements[0]; | ||
|
||
$this->assertEquals('00000/001', $statement->getNumber()); | ||
$this->assertEquals('87052000/123456789', $statement->getAccount()->getNumber()); | ||
} | ||
|
||
public function testBalance() | ||
{ | ||
$balance = $this->statements[0]->getOpeningBalance(); | ||
$this->assertInstanceOf(\Jejik\MT940\Balance::class, $balance); | ||
$this->assertEquals('2019-02-15 00:00:00', $balance->getDate()->format('Y-m-d H:i:s')); | ||
$this->assertEquals('EUR', $balance->getCurrency()); | ||
$this->assertEquals(194.57, $balance->getAmount()); | ||
} | ||
|
||
public function testTransaction() | ||
{ | ||
$transactions = $this->statements[1]->getTransactions(); | ||
|
||
$this->assertCount(1, $transactions); | ||
|
||
$this->assertNotNull($transactions[0]->getContraAccount()); | ||
|
||
$this->assertEquals(-20.00, $transactions[0]->getAmount()); | ||
$expectedDescription = "177?00ONLINE-UEBERWEISUNG?109310?20SVWZ+Apple Pay?21DATUM 19.\r\n" . | ||
"02.2019, 13.24 UHR?221.TAN 002153?30NTSBDEB1XXX?31DE1234567890123\r\n" . | ||
"4567890?32Max Mustermann?34997"; | ||
$this->assertEquals($expectedDescription, $transactions[0]->getDescription()); | ||
$this->assertEquals('2019-02-19 00:00:00', $transactions[0]->getValueDate()->format('Y-m-d H:i:s'), 'Assert Value Date'); | ||
$this->assertEquals('2019-02-19 00:00:00', $transactions[0]->getBookDate()->format('Y-m-d H:i:s'), 'Assert Book Date'); | ||
|
||
$this->assertNull($transactions[0]->getCode()); | ||
$this->assertNull($transactions[0]->getRef()); | ||
$this->assertNull($transactions[0]->getBankRef()); | ||
|
||
$this->assertEquals('177', $transactions[0]->getGVC()); | ||
$this->assertEquals('ONLINE-UEBERWEISUNG', $transactions[0]->getTxText()); | ||
$this->assertEquals('9310', $transactions[0]->getPrimanota()); | ||
$this->assertEquals('997', $transactions[0]->getExtCode()); | ||
|
||
$this->assertNull($transactions[0]->getEref()); | ||
|
||
$this->assertEquals('NTSBDEB1XXX', $transactions[0]->getBIC()); | ||
$this->assertEquals('DE12345678901234567890', $transactions[0]->getIBAN()); | ||
$this->assertEquals('Max Mustermann', $transactions[0]->getAccountHolder()); | ||
|
||
$this->assertNull($transactions[0]->getKref()); | ||
$this->assertNull($transactions[0]->getMref()); | ||
$this->assertNull($transactions[0]->getCred()); | ||
|
||
$this->assertEquals('Apple PayDATUM 19.02.2019, 13.24 UHR1.TAN 002153', $transactions[0]->getSvwz()); | ||
$this->assertEquals('DE12345678901234567890', $transactions[0]->getContraAccount()->getNumber()); | ||
$this->assertEquals('Max Mustermann', $transactions[0]->getContraAccount()->getName()); | ||
} | ||
} |
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