mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
7.0 uk hsbc import improvements (#115)
* [IMP] hsbc mt940: ACH is a payment order type * [FIX] hsbc mt940: Also include first info line in transaction description * [IMP] hsbc mt940: Convert empty (NONREF) reference to blank * [FIX] hsbc mt940: Allow ampersand character in alphanumeric fields Although this is not mentioned in the official spec, it was found in files generated by UK HSBC where a remote bank account name contained an ampersand.
This commit is contained in:
committed by
Pedro M. Baeza
parent
8e63c287b7
commit
aaf3c86b8f
@@ -45,13 +45,13 @@ class transaction(models.mem_bank_transaction):
|
||||
'value_date': 'valuedate',
|
||||
'local_currency': 'currency',
|
||||
'transfer_type': 'bookingcode',
|
||||
'reference': 'custrefno',
|
||||
'message': 'furtherinfo'
|
||||
}
|
||||
|
||||
type_map = {
|
||||
'NTRF': bt.ORDER,
|
||||
'NMSC': bt.ORDER,
|
||||
'NACH': bt.ORDER,
|
||||
'NPAY': bt.PAYMENT_BATCH,
|
||||
'NCHK': bt.CHECK,
|
||||
}
|
||||
@@ -67,6 +67,10 @@ class transaction(models.mem_bank_transaction):
|
||||
|
||||
self.transferred_amount = record2float(record, 'amount')
|
||||
|
||||
ref = record.get('custrefno')
|
||||
if ref and ref != 'NONREF':
|
||||
self.reference = ref
|
||||
|
||||
# Set the transfer type based on the bookingcode
|
||||
if record.get('bookingcode', 'ignore') in self.type_map:
|
||||
self.transfer_type = self.type_map[record['bookingcode']]
|
||||
@@ -151,7 +155,7 @@ class statement(models.mem_bank_statement):
|
||||
record[k]
|
||||
for k in (
|
||||
'infoline{0}'.format(i)
|
||||
for i in range(2, 5)
|
||||
for i in range(1, 5)
|
||||
)
|
||||
if k in record
|
||||
))
|
||||
|
||||
@@ -35,7 +35,10 @@ class HSBCParser(object):
|
||||
|
||||
def __init__(self):
|
||||
recparse = dict()
|
||||
patterns = {'ebcdic': r"\w/\?:\(\).,'+{} -"}
|
||||
# Allowed characters. The list was originally taken from HSBC's
|
||||
# spec, but the ampersand character was found out in the wild in
|
||||
# the customer account name
|
||||
patterns = {'ebcdic': r"\w/\?:\(\).,'+{} &-"}
|
||||
|
||||
# MT940 header
|
||||
recparse["20"] = r":(?P<recordid>20):(?P<transref>.{1,16})"
|
||||
|
||||
Reference in New Issue
Block a user