mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MRG] Merged with prerequisite branch and resolved conflicts
This commit is contained in:
@@ -863,16 +863,13 @@ class res_partner_bank(orm.Model):
|
||||
if country.code in sepa.IBAN.countries:
|
||||
acc_number_fmt = sepa.BBAN(acc_number, country.code)
|
||||
if acc_number_fmt.valid:
|
||||
values['acc_number'] = str(acc_number_fmt)
|
||||
values['acc_number_domestic'] = str(acc_number_fmt)
|
||||
else:
|
||||
values['acc_number'] = acc_number
|
||||
result.update(warning(
|
||||
_('Invalid format'),
|
||||
_('The account number has the wrong format for %s')
|
||||
% country.name
|
||||
))
|
||||
else:
|
||||
values['acc_number'] = acc_number
|
||||
return result
|
||||
|
||||
def onchange_iban(
|
||||
|
||||
@@ -156,28 +156,55 @@ class transaction(models.mem_bank_transaction):
|
||||
The string consists of slash separated KEY/VALUE pairs,
|
||||
but the slash is allowed to and known to occur in VALUE as well!
|
||||
"""
|
||||
items = field[1:].split('/') # skip leading slash
|
||||
def _sepa_message(field, reason):
|
||||
return _(
|
||||
'unable to parse SEPA string: %s - %s' % (field, reason))
|
||||
|
||||
def _get_next_key(items, start):
|
||||
'''Find next key, starting from start, returns the key found,
|
||||
the start position in the array and the end position + 1'''
|
||||
known_keys = [
|
||||
'TRTP', 'IBAN', 'BIC', 'NAME', 'RTRN', 'EREF', 'SWOC',
|
||||
'REMI', 'ADDR', 'CPRP', 'CREF', 'CSID', 'ISDT', 'MARF',
|
||||
'NRTX', 'NRTXR', 'PREF', 'PURP', 'REFOB', 'RREF', 'RTYP',
|
||||
'SVCL', 'SWOD', 'BENM//ID', 'ORDP//ID', 'ORDP//RID',
|
||||
'ORIG//CSID', 'ORIG//MARF', 'ULTD//NAME', 'ULTD//ID',
|
||||
'ULTB//NAME', 'ULTB//ID'
|
||||
]
|
||||
items_len = len(items)
|
||||
start_index = start
|
||||
# Search until start after end of items
|
||||
while start_index < items_len:
|
||||
end_index = start_index + 1
|
||||
while end_index < items_len:
|
||||
key = '/'.join(items[start_index:end_index])
|
||||
if key in known_keys:
|
||||
return (key, start_index, end_index)
|
||||
end_index += 1
|
||||
start_index += 1
|
||||
return False
|
||||
|
||||
items = field[1:].split('/')
|
||||
assert len(items) > 1, _sepa_message(field, _('too few items'))
|
||||
sepa_dict = {}
|
||||
prev_key = False
|
||||
known_keys = ['TRTP', 'IBAN', 'BIC', 'NAME', 'RTRN', 'EREF',
|
||||
'SWOC', 'REMI', ]
|
||||
while items:
|
||||
if len(items) == 1:
|
||||
raise orm.except_orm(
|
||||
_('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 orm.except_orm(
|
||||
_('Error !'),
|
||||
_("unable to parse SEPA string: %s") % field)
|
||||
else:
|
||||
sepa_dict[key] = items.pop(0).strip()
|
||||
prev_key = key
|
||||
item_index = 0
|
||||
items_len = len(items)
|
||||
key_info = _get_next_key(items, item_index)
|
||||
assert key_info, _sepa_message(
|
||||
field, _('no key found for start %d') % item_index)
|
||||
assert key_info[1] == 0, _sepa_message(
|
||||
field, _('invalid data found before key %s') % key_info[0])
|
||||
while key_info:
|
||||
sepa_key = key_info[0]
|
||||
item_index = key_info[2]
|
||||
# Find where next key - if any - starts
|
||||
key_info = _get_next_key(items, item_index)
|
||||
value_end_index = (key_info and key_info[1]) or items_len
|
||||
sepa_value = (
|
||||
((value_end_index > item_index)
|
||||
and '/'.join(items[item_index:value_end_index]))
|
||||
or '')
|
||||
sepa_dict[sepa_key] = sepa_value
|
||||
return sepa_dict
|
||||
|
||||
def parse_type(field):
|
||||
|
||||
@@ -131,7 +131,7 @@ class payment_order(orm.Model):
|
||||
wizard_obj = self.pool.get(wizard_model)
|
||||
wizard_id = wizard_obj.create(cr, uid, {}, context)
|
||||
result = {
|
||||
'name': wizard_obj._description or 'Payment Order Export',
|
||||
'name': wizard_obj._description or _('Payment Order Export'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': wizard_model,
|
||||
|
||||
@@ -57,7 +57,7 @@ class payment_order_create(orm.TransientModel):
|
||||
# line2bank = line_obj.line2bank(cr, uid, line_ids, t, context)
|
||||
line2bank = line_obj.line2bank(
|
||||
cr, uid, line_ids, payment.mode.id, context)
|
||||
_today = datetime.utcnow().strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
_today = fields.date.context_today(self, cr, uid, context=context)
|
||||
### end account banking
|
||||
|
||||
## Finally populate the current payment with new lines:
|
||||
@@ -69,15 +69,17 @@ class payment_order_create(orm.TransientModel):
|
||||
### account_banking
|
||||
# date_to_pay = line.date_maturity
|
||||
date_to_pay = (
|
||||
line.date_maturity if line.date_maturity
|
||||
and line.date_maturity > _today else False)
|
||||
line.date_maturity
|
||||
if line.date_maturity and line.date_maturity > _today
|
||||
else False)
|
||||
### end account banking
|
||||
elif payment.date_prefered == 'fixed':
|
||||
### account_banking
|
||||
# date_to_pay = payment.date_planned
|
||||
date_to_pay = (
|
||||
payment.date_planned if payment.date_planned
|
||||
and payment.date_planned > _today else False)
|
||||
payment.date_planned
|
||||
if payment.date_planned and payment.date_planned > _today
|
||||
else False)
|
||||
### end account banking
|
||||
|
||||
### account_banking
|
||||
|
||||
Reference in New Issue
Block a user