@@ -97,8 +97,11 @@ def parse(self, line):
9797 if len (line ) > self .size and len (line .strip ()) <= self .size :
9898 line = line [:self .size ]
9999 if len (line ) != self .size :
100- raise ParsingError ("Invalid line: >%s<. the len should be %s"
101- "instead of %s" % (line , self .size , len (line )))
100+ if self ._code == '05' and len (line ) == 78 :
101+ line += ' ' * 42
102+ else :
103+ raise ParsingError ("Invalid line: >%s<. the len should be %s"
104+ "instead of %s" % (line , self .size , len (line )))
102105 match = self .re .match (line )
103106 # re check
104107 if match is None :
@@ -125,15 +128,15 @@ class ParserContent01(Parser):
125128 _regex = [
126129 ('record_code' , '(01)' , 2 ),
127130 ('bank_code' , G_N , 5 ),
128- ('_1' , G__ , 4 ),
131+ ('_1' , G_AN_ , 4 ),
129132 ('desk_code' , G_N , 5 ),
130133 ('currency_code' , G_A_ , 3 ),
131134 ('nb_of_dec' , G_N_ , 1 ),
132135 ('_2' , G__ , 1 ),
133136 ('account_nb' , G_AN , 11 ),
134137 ('_3' , G__ , 2 ),
135138 ('prev_date' , G_N , 6 ),
136- ('_4' , G__ , 50 ),
139+ ('_4' , G_ALL , 50 ),
137140 ('prev_amount' , G_AMT , 14 ),
138141 ('_5' , G_ALL , 16 ),
139142 ]
@@ -194,7 +197,7 @@ class ParserContent05(Parser):
194197 ('account_nb' , G_AN , 11 ),
195198 ('operation_code' , G_AN , 2 ),
196199 ('operation_date' , G_N , 6 ),
197- ('_2' , G__ , 5 ),
200+ ('_2' , G_N_ , 5 ),
198201 ('qualifier' , G_AN , 3 ),
199202 ('additional_info' , G_ALL , 70 ),
200203 ('_3' , G__ , 2 ),
@@ -212,17 +215,17 @@ class ParserContent07(Parser):
212215 _regex = [
213216 ('record_code' , '(07)' , 2 ),
214217 ('bank_code' , G_N , 5 ),
215- ('_1' , G__ , 4 ),
218+ ('_1' , G_AN_ , 4 ),
216219 ('desk_code' , G_N , 5 ),
217220 ('currency_code' , G_A_ , 3 ),
218221 ('nb_of_dec' , G_N_ , 1 ),
219222 ('_2' , G__ , 1 ),
220223 ('account_nb' , G_AN , 11 ),
221224 ('_3' , G__ , 2 ),
222225 ('next_date' , G_N , 6 ),
223- ('_4' , G__ , 50 ),
226+ ('_4' , G_ALL , 50 ),
224227 ('next_amount' , G_AMT , 14 ),
225- ('_5' , G__ , 16 ),
228+ ('_5' , G_ALL , 16 ),
226229 ]
227230
228231 def _post (self , res ):
@@ -354,7 +357,7 @@ def _post(self, res):
354357 res = super (ParserMMO , self )._post (res )
355358 res ['equivalent_amount' ] = float (res ['equivalent_amount' ])\
356359 / float (res ['nb_of_dec_amount' ])
357- if res ['exchange_rate' ]:
360+ if res ['exchange_rate' ] and float ( res [ 'nb_of_dec_exchange_rate' ]) > 0 :
358361 res ['exchange_rate' ]= float (res ['exchange_rate' ])\
359362 / float (res ['nb_of_dec_exchange_rate' ])
360363 return res
0 commit comments