From cd388090668dad50f838ff49d4ec02d45a5c24c4 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Tue, 6 Feb 2018 12:09:16 +0100 Subject: [PATCH 1/2] [FIX] uses relative imports --- coda/parser.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/coda/parser.py b/coda/parser.py index 20c5a9a..f903537 100644 --- a/coda/parser.py +++ b/coda/parser.py @@ -26,12 +26,12 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # -import re import os +import re import time -from statement import Statement -from coda.statement import MovementRecord, MovementRecordType, InformationRecord,\ - FreeCommunication + +from .statement import MovementRecord, MovementRecordType, InformationRecord, \ + FreeCommunication, Statement class CodaParserException(Exception): From 6c8da2f6598d1f0709e7085dd9f173e986896923 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Tue, 6 Feb 2018 13:08:28 +0100 Subject: [PATCH 2/2] [IMP] support foreign account number --- coda/parser.py | 6 +++--- coda/tests/Coda_foreign_account.txt | 10 ++++++++++ coda/tests/test_parser.py | 9 +++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 coda/tests/Coda_foreign_account.txt diff --git a/coda/parser.py b/coda/parser.py index f903537..5e60ef8 100644 --- a/coda/parser.py +++ b/coda/parser.py @@ -157,9 +157,9 @@ def _parseHeaderDetails(self, line, statement): statement.acc_number = rmspaces(line[5:21]) statement.currency = rmspaces(line[39:42]) elif line[1] == '3': # foreign bank account IBAN structure - raise CodaParserException( - ' R1002', 'Foreign bank accounts with IBAN structure are ' - 'not supported ') + _val = line[5:42] + statement.acc_number = rmspaces(_val[:-3]) + statement.currency = rmspaces(_val[-3:]) else: # Something else, not supported raise CodaParserException( ' R1003', 'Unsupported bank account structure ') diff --git a/coda/tests/Coda_foreign_account.txt b/coda/tests/Coda_foreign_account.txt new file mode 100644 index 0000000..bc4c04c --- /dev/null +++ b/coda/tests/Coda_foreign_account.txt @@ -0,0 +1,10 @@ +0000002021820005 0000000000VILLA XXXXXXX SASU CCFRFRPP 00000000000 00000DI/SW180202/2459 2 +13024FR1234567890240924002304825 EUR0000000443390700010218VILLA XXXXXXX SASU 09240023048EUR 024 +2100010000 1000000000037000010218001010000TRANS : NMSC / INFO : ELYS PC ABONNEMENT 01021802401 0 +2200010000 0000000 0 1 +3100010001 001010000CONTRAT NO 123456789379 0 0 +2100020000 1000000000007400010218030370000TRANS : NCOM / INFO : TVA 20 0 01021802401 0 +2200020000 0000000 0 0 +8024FR1234567890240924002304825 EUR0000000443346300020218 1 +4 00010000 CLOSING AVAILABLE BALANCE C 180202 EUR 443346,3 0 +9 000007000000000044400000000000000000 2 diff --git a/coda/tests/test_parser.py b/coda/tests/test_parser.py index cafaae1..6b18598 100644 --- a/coda/tests/test_parser.py +++ b/coda/tests/test_parser.py @@ -203,3 +203,12 @@ def test_parse_methods(self): parser.parse('invalid_coda_content') ex = cm.exception eq_(ex.message, 'The given value is not a valid coda content') + + def test_foreign_account(self): + parser = Parser() + file_name = os.path.join(BASEPATH, "Coda_foreign_account.txt") + statements = parser.parse_file(file_name) + eq_(len(statements), 1) + st = statements[0] + eq_(st.acc_number, 'FR1234567890240924002304825') + eq_(st.currency, 'EUR')