mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[FIX] Backport 8.0 improvements in ING mt940 parsing.
This commit is contained in:
committed by
Ronald Portier
parent
64d9663af0
commit
d37a803383
@@ -11,11 +11,12 @@
|
||||
This addon imports the structured MT940 format as offered by the Dutch ING
|
||||
bank.
|
||||
""",
|
||||
"category": "Account Banking",
|
||||
"depends": [
|
||||
'category': 'Account Banking',
|
||||
'depends': [
|
||||
'account_banking_mt940',
|
||||
],
|
||||
"auto_install": False,
|
||||
"installable": True,
|
||||
"application": False,
|
||||
'images': [], # Satisfy travis
|
||||
'auto_install': False,
|
||||
'installable': True,
|
||||
'application': False,
|
||||
}
|
||||
|
||||
@@ -22,8 +22,10 @@ class IngMT940Parser(MT940, parser):
|
||||
code = 'INT_MT940_STRUC'
|
||||
|
||||
tag_61_regex = re.compile(
|
||||
r'^(?P<date>\d{6})(?P<sign>[CD])(?P<amount>\d+,\d{2})N(?P<type>.{3})'
|
||||
r'(?P<reference>\w{1,16})')
|
||||
r'^(?P<date>\d{6})(?P<line_date>\d{0,4})'
|
||||
r'(?P<sign>[CD])(?P<amount>\d+,\d{2})N(?P<type>.{3})'
|
||||
r'(?P<reference>\w{1,50})'
|
||||
)
|
||||
|
||||
def create_transaction(self, cr):
|
||||
return transaction()
|
||||
@@ -41,7 +43,10 @@ class IngMT940Parser(MT940, parser):
|
||||
|
||||
def handle_tag_61(self, cr, data):
|
||||
super(IngMT940Parser, self).handle_tag_61(cr, data)
|
||||
parsed_data = self.tag_61_regex.match(data).groupdict()
|
||||
re_61 = self.tag_61_regex.match(data)
|
||||
if not re_61:
|
||||
raise ValueError("Cannot parse %s" % data)
|
||||
parsed_data = re_61.groupdict()
|
||||
self.current_transaction.transferred_amount = \
|
||||
(-1 if parsed_data['sign'] == 'D' else 1) * str2float(
|
||||
parsed_data['amount'])
|
||||
|
||||
Reference in New Issue
Block a user