-
Notifications
You must be signed in to change notification settings - Fork 63
BTRL - Banca Transilvania Romania #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <?php | ||
|
|
||
| namespace Kingsquare\Parser\Banking\Mt940\Engine; | ||
|
|
||
| use Kingsquare\Parser\Banking\Mt940\Engine; | ||
|
|
||
| class Btrl extends Engine | ||
| { | ||
| /** | ||
| * | ||
| * {@inheritdoc} | ||
| * @see \Kingsquare\Parser\Banking\Mt940\Engine::parseStatementBank() | ||
| */ | ||
| protected function parseStatementBank() | ||
| { | ||
| return 'BTRL'; | ||
| } | ||
|
|
||
| /** | ||
| * uses the 61 field to determine amount/value of the transaction. | ||
| * | ||
| * @return float | ||
| */ | ||
| protected function parseTransactionPrice() | ||
| { | ||
| $results = []; | ||
| if (preg_match('/^:61:.*?[CD]([\d,\.]+)[NSF]/i', $this->getCurrentTransactionData(), $results) | ||
| && !empty($results[1]) | ||
| ) { | ||
| return $this->sanitizePrice($results[1]); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * | ||
| * {@inheritdoc} | ||
| * @see \Kingsquare\Parser\Banking\Mt940\Engine::isApplicable() | ||
| */ | ||
| public static function isApplicable($string) | ||
| { | ||
| $firstline = strtok($string, "\r\n\t"); | ||
|
|
||
| return strpos($firstline, 'BTRL') !== false; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,27 +7,27 @@ | |
| /** | ||
| * | ||
| */ | ||
| class ParseTest extends \PHPUnit_Framework_TestCase | ||
| class ParseTest extends \PHPUnit\Framework\TestCase | ||
| { | ||
| /** | ||
| * @var Abn | ||
| */ | ||
| private $engine; | ||
|
|
||
| protected function setUp() | ||
| protected function setUp(): void | ||
| { | ||
| $this->engine = new Abn(); | ||
| $this->engine->loadString(file_get_contents(__DIR__.'/sample')); | ||
| } | ||
|
|
||
| public function testParseStatementBank() | ||
| public function testParseStatementBank():void | ||
| { | ||
| $method = new \ReflectionMethod($this->engine, 'parseStatementBank'); | ||
| $method->setAccessible(true); | ||
| $this->assertEquals('ABN', $method->invoke($this->engine)); | ||
| } | ||
|
|
||
| public function testParsesAllFoundStatements() | ||
| public function testParsesAllFoundStatements():void | ||
| { | ||
| $statements = $this->engine->parse(); | ||
|
|
||
|
|
@@ -78,22 +78,4 @@ public function testIssue48() | |
| $this->assertEquals('15-12-2016', $transactions[1]->getValueTimestamp('d-m-Y')); | ||
| $this->assertEquals('15-12-2016', $transactions[1]->getEntryTimestamp('d-m-Y')); | ||
| } | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test methods should not be deleted. |
||
| public function testParseTransactionDebitCredit() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = reset($statements)->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals('D', $firstTransaction->getDebitCredit()); | ||
| } | ||
|
|
||
| public function testParseTransactionPrice() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = reset($statements)->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals(7.5, $firstTransaction->getPrice()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,22 +48,4 @@ public function testParseTransactionEntryTimestamp() | |
| $lastTransaction = end($transactions); | ||
| $this->assertEquals('02-01-2020', $lastTransaction->getEntryTimestamp('d-m-Y')); | ||
| } | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test methods should not be deleted. |
||
| public function testParseTransactionDebitCredit() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = reset($statements)->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals('D', $firstTransaction->getDebitCredit()); | ||
| } | ||
|
|
||
| public function testParseTransactionPrice() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = reset($statements)->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals(2000, $firstTransaction->getPrice()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <?php | ||
|
|
||
| namespace Kingsquare\Parser\Banking\Mt940\Engine\Btrl; | ||
|
|
||
| use Kingsquare\Parser\Banking\Mt940\Engine\Btrl; | ||
|
|
||
| /** | ||
| * | ||
| */ | ||
| class ParseTest extends \PHPUnit\Framework\TestCase | ||
| { | ||
| /** | ||
| * @var Btrl | ||
| */ | ||
| private $engine; | ||
|
|
||
| protected function setUp(): void | ||
| { | ||
| $this->engine = new Btrl(); | ||
| $this->engine->loadString(file_get_contents(__DIR__.'/sample')); | ||
| } | ||
|
|
||
| public function testParseStatementBank():void | ||
| { | ||
| $method = new \ReflectionMethod($this->engine, 'parseStatementBank'); | ||
| $method->setAccessible(true); | ||
| $this->assertEquals('BTRL', $method->invoke($this->engine)); | ||
| } | ||
|
|
||
| public function testParseTransactionPrice(): void | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $this->assertCount(1, $statements); | ||
| $transactions = $statements[0]->getTransactions(); | ||
|
|
||
| $this->assertEquals('980.42', $transactions[0]->getPrice()); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| {1:F01BTRLRO22AXXX1111111111}{2:I940BTRLRO22XXXXN}{3:{108:005MSOG2109700AI}}{4: | ||
| :20:005RONCRT0072583603 | ||
| :25:RO21BTRLRONCRT0072583603 | ||
| :28C:00004/00001 | ||
| :60F:C210406RON0, | ||
| :61:2104060406C980,42FTRFNONREF//005z001210960373 | ||
| :86:Card 5487-6174 ID005696ER 04/04/21 Ora 22:44:12 RRN 005481058051 | ||
| ECOMM 551 Plata factura DV - 20666 - 723121 | ||
| Data entry carduri REF. 005z001210960373 | ||
| :61:2104060406C418,37FTRFNONREF//005z001210960481 | ||
| :86:Card 5299-2132 ID005696ER 05/04/21 Ora 08:14:25 RRN 005481324613 | ||
| :86:transf in ct.crt | ||
| Transfer intern - canal electronic REF. 405ECIT210960154 | ||
| :62F:C210406RON0, | ||
| :64:C210406RON0,00 | ||
| -} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,22 +51,4 @@ public function testParseTransactionEntryTimestamp() | |
| $lastTransaction = end($transactions); | ||
| $this->assertEquals('24-05-2019', $lastTransaction->getEntryTimestamp('d-m-Y')); | ||
| } | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test methods should not be deleted. |
||
| public function testParseTransactionDebitCredit() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = reset($statements)->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals('C', $firstTransaction->getDebitCredit()); | ||
| } | ||
|
|
||
| public function testParseTransactionPrice() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = reset($statements)->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals(2, $firstTransaction->getPrice()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,22 +54,4 @@ public function testParseTransactionEntryTimestamp() | |
| $lastTransaction = end($transactions); | ||
| $this->assertEquals('2010-07-21', $lastTransaction->getEntryTimestamp('Y-m-d')); | ||
| } | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test methods should not be deleted. |
||
| public function testParseTransactionDebitCredit() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = reset($statements)->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals('C', $firstTransaction->getDebitCredit()); | ||
| } | ||
|
|
||
| public function testParseTransactionPrice() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = reset($statements)->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals(25.03, $firstTransaction->getPrice()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,22 +89,4 @@ public function testEndPrice() { | |
| $price_f = $statements[0]->getEndPrice(); | ||
| $this->assertSame(13057.49 , $price_f); | ||
| } | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test methods should not be deleted. |
||
| public function testParseTransactionDebitCredit() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = reset($statements)->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals('D', $firstTransaction->getDebitCredit()); | ||
| } | ||
|
|
||
| public function testParseTransactionPrice() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = reset($statements)->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals(15, $firstTransaction->getPrice()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,22 +52,4 @@ public function testParseTransactionEntryTimestamp() | |
| $lastTransaction = end($transactions); | ||
| $this->assertEquals('30-09-2020', $lastTransaction->getEntryTimestamp('d-m-Y')); | ||
| } | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test methods should not be deleted. |
||
| public function testParseTransactionDebitCredit() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = reset($statements)->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals('D', $firstTransaction->getDebitCredit()); | ||
| } | ||
|
|
||
| public function testParseTransactionPrice() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = reset($statements)->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals(20, $firstTransaction->getPrice()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,22 +108,4 @@ public function testHandlingOfPREF() { | |
| $statements = $this->engine->parse(); | ||
| $this->assertSame('PmtInfId-20151208-987', $statements[0]->getTransactions()[1]->getDescription()); | ||
| } | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test methods should not be deleted. |
||
| public function testParseTransactionDebitCredit() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = $statements[5]->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals('C', $firstTransaction->getDebitCredit()); | ||
| } | ||
|
|
||
| public function testParseTransactionPrice() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = $statements[5]->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals(500, $firstTransaction->getPrice()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,13 +51,4 @@ public function testParsesAllFoundStatements() | |
| $this->assertEquals('18-02-2010', $last->getStartTimestamp('d-m-Y')); | ||
| $this->assertEquals('18-02-2010', $last->getEndTimestamp('d-m-Y')); | ||
| } | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test methods should not be deleted. |
||
| public function testParseTransactionDebitCredit() | ||
| { | ||
| $statements = $this->engine->parse(); | ||
| $transactions = reset($statements)->getTransactions(); | ||
| $firstTransaction = reset($transactions); | ||
|
|
||
| $this->assertEquals('C', $firstTransaction->getDebitCredit()); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kbs,ZetbandKontistshould not be deleted.