Skip to content

Commit

Permalink
Merge 6c8da2f into 91d89b5
Browse files Browse the repository at this point in the history
  • Loading branch information
lmignon committed Feb 6, 2018
2 parents 91d89b5 + 6c8da2f commit 2b7530d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
14 changes: 7 additions & 7 deletions coda/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down 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 2b7530d

Please sign in to comment.