banking-addons-team team mailing list archive
-
banking-addons-team team
-
Mailing list archive
-
Message #00391
[Merge] lp:~therp-nl/banking-addons/6.1_lp1117319_abnamro_sepa_line into lp:banking-addons
Ronald Portier (Therp) has proposed merging lp:~therp-nl/banking-addons/6.1_lp1117319_abnamro_sepa_line into lp:banking-addons.
Requested reviews:
Banking Addons Team (banking-addons-team)
Related bugs:
Bug #1117319 in Banking Addons: "Not all sepa lines are supported on bank import"
https://bugs.launchpad.net/banking-addons/+bug/1117319
For more details, see:
https://code.launchpad.net/~therp-nl/banking-addons/6.1_lp1117319_abnamro_sepa_line/+merge/146903
Make it possible to import abnamro statement files with extended sepa attributes in line.
--
https://code.launchpad.net/~therp-nl/banking-addons/6.1_lp1117319_abnamro_sepa_line/+merge/146903
Your team Banking Addons Team is requested to review the proposed merge of lp:~therp-nl/banking-addons/6.1_lp1117319_abnamro_sepa_line into lp:banking-addons.
=== modified file 'account_banking_nl_abnamro/abnamro.py'
--- account_banking_nl_abnamro/abnamro.py 2012-10-27 19:53:50 +0000
+++ account_banking_nl_abnamro/abnamro.py 2013-02-06 17:03:25 +0000
@@ -155,28 +155,51 @@
The string consists of slash separated KEY/VALUE pairs,
but the slash is allowed to and known to occur in VALUE as well!
"""
+ other_keys = [
+ 'ADDR', 'BIC', 'CPRP', 'CREF', 'CSID', 'ISDT', 'MARF', 'NRTX',
+ 'NRTXR', 'PREF', 'PURP', 'REFOB', 'RREF', 'RTYP', 'SVCL',
+ 'SWOD'
+ ]
+ # Patch keys with embedded double slashes, but first check,
+ # for performance reasons, wether this problem might occur at all.
+ if '//' in field:
+ patch_double_slash_keys = [
+ '/BENM//ID/', '/ORDP//ID/', '/ORDP//RID/', '/ORIG//CSID/',
+ '/ORIG//MARF/', '/ULTD//NAME/', '/ULTD//ID/',
+ '/ULTB//NAME/', '/ULTB//ID/'
+ ]
+ for pdsk in patch_double_slash_keys:
+ psdk_key = pdsk.replace('//', '~~')
+ field = field.replace(pdsk, psdk_key)
+ other_keys.append(psdk_key.replace('/', ''))
items = field[1:].split('/') # skip leading slash
sepa_dict = {}
- prev_key = False
known_keys = ['TRTP', 'IBAN', 'BIC', 'NAME', 'RTRN', 'EREF',
'SWOC', 'REMI', ]
+ # There should be at least two items, a key and a value,
+ # and the first item should be a valid key. (But it will be, as
+ # we only get here when field starts with /TRTP !!)
+ if len(items) < 2:
+ raise osv.except_osv(
+ _('Error !'),
+ _('unable to parse SEPA string: %s - %s') %
+ (field, _('too few items')))
+ sepa_key = items[0]
+ if not (sepa_key in known_keys or sepa_key in other_keys):
+ raise osv.except_osv(
+ _('Error !'),
+ _('unable to parse SEPA string: %s - %s') %
+ (field, _('First key %s unknown') % sepa_key))
+ sepa_values = None
while items:
- if len(items) == 1:
- raise osv.except_osv(
- _('Error !'),
- _("unable to parse SEPA string: %s") % field)
- key = items.pop(0)
- if key not in known_keys:
- # either an unknown key or a value containing a slash
- if prev_key:
- sepa_dict[prev_key] = sepa_dict[prev_key] + '/' + key
- else:
- raise osv.except_osv(
- _('Error !'),
- _("unable to parse SEPA string: %s") % field)
+ item = items.pop(0)
+ if item in known_keys or item in other_keys:
+ if not sepa_values is None:
+ sepa_dict[sepa_key] = '/'.join(sepa_values)
+ sepa_key = item
+ sepa_values = []
else:
- sepa_dict[key] = items.pop(0).strip()
- prev_key = key
+ sepa_values.append(item.strip())
return sepa_dict
def parse_type(field):
Follow ups