Skip to content

Commit

Permalink
[IMP] support foreign account number
Browse files Browse the repository at this point in the history
  • Loading branch information
lmignon committed Feb 6, 2018
1 parent 40ba7b4 commit 5a866c6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
6 changes: 3 additions & 3 deletions coda/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ')
Expand Down
10 changes: 10 additions & 0 deletions coda/tests/Coda_foreign_account.txt
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions coda/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

0 comments on commit 5a866c6

Please sign in to comment.