Skip to content

Commit

Permalink
Merge pull request #78 from PaulvanKaam/patch-1
Browse files Browse the repository at this point in the history
KNAB Engine: Key addition for parser ('F' added)
  • Loading branch information
fruitl00p authored Nov 5, 2020
2 parents 70d4b0e + be06599 commit 5d956c8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Parser/Banking/Mt940/Engine/Knab.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,31 @@ protected function parseStatementBank()
*/
protected function parseStatementStartPrice()
{
return $this->parseStatementPrice('60M');
return $this->parseStatementPrice('60[FM]');
}

/**
* @inheritdoc
*/
protected function parseStatementEndPrice()
{
return $this->parseStatementPrice('62M');
return $this->parseStatementPrice('62[FM]');
}

/**
* @inheritdoc
*/
protected function parseStatementStartTimestamp()
{
return $this->parseTimestampFromStatement('60M');
return $this->parseTimestampFromStatement('60[FM]');
}

/**
* @inheritdoc
*/
protected function parseStatementEndTimestamp()
{
return $this->parseTimestampFromStatement('62M');
return $this->parseTimestampFromStatement('62[FM]');
}

/**
Expand Down
25 changes: 25 additions & 0 deletions test/Parser/Banking/Mt940/Engine/Knab/ParseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,29 @@ public function testStructuredMt940() {
$this->assertEquals('ACHMEA SCHADEVERZEKERINGEN N.V.', $structuredTransaction->getAccountName());
$this->assertEquals('EERSTE MAAND, MAART VERZEKERING 5002100023 310160', $structuredTransaction->getDescription());
}


public function testStartPrice() {
$this->engine->loadString(file_get_contents(__DIR__.'/sample'));
$statements = $this->engine->parse();
$start_price_m = $statements[0]->getStartPrice();
$this->assertSame(1000.21 , $start_price_m);

$this->engine->loadString(file_get_contents(__DIR__.'/sample2'));
$statements = $this->engine->parse();
$start_price_f = $statements[0]->getStartPrice();
$this->assertSame(12490.07 , $start_price_f);
}

public function testEndPrice() {
$this->engine->loadString(file_get_contents(__DIR__.'/sample'));
$statements = $this->engine->parse();
$price_m = $statements[0]->getEndPrice();
$this->assertSame(945.21 , $price_m);

$this->engine->loadString(file_get_contents(__DIR__.'/sample2'));
$statements = $this->engine->parse();
$price_f = $statements[0]->getEndPrice();
$this->assertSame(13057.49 , $price_f);
}
}
10 changes: 10 additions & 0 deletions test/Parser/Banking/Mt940/Engine/Knab/sample2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{1:F01KNABNL2HAXXX0000000000}{2:I940KNABNL2HXXXXN3020}{4:
:20:C0D28MSTE73HKBCM
:25:NL52RABO0326203011
:28C:108/1
:60F:C200427EUR12490,07
:61:2004270427C567,42N110NONREF//C0D27XM01D000031
:86:/TRTP/OVERBOEKING/IBAN/123/BIC/SXPYDEHHXX
X/NAME/STRIPE PAYMENTS UK LTD/REMI/SHOPIFY D3DJ2
:62F:C200428EUR13057,49
-}

0 comments on commit 5d956c8

Please sign in to comment.