mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MRG] Merged with main development branch
This commit is contained in:
@@ -1135,8 +1135,9 @@ class res_partner_bank(osv.osv):
|
||||
Create dual function IBAN account for SEPA countries
|
||||
'''
|
||||
if vals['state'] == 'iban':
|
||||
iban = vals.get('acc_number',False) or vals.get('acc_number_domestic',False)
|
||||
vals['acc_number'], vals['acc_number_domestic'] = (
|
||||
self._correct_IBAN(vals['acc_number']))
|
||||
self._correct_IBAN(iban))
|
||||
return self._founder.create(cursor, uid, vals, context)
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
@@ -1426,7 +1427,9 @@ class res_partner_bank(osv.osv):
|
||||
)
|
||||
|
||||
_constraints = [
|
||||
(check_iban, _("The IBAN number doesn't seem to be correct"), ["acc_number"])
|
||||
# Cannot have this as a constraint as it is rejecting valid numbers from GB and DE
|
||||
# It works much better without this constraint!
|
||||
#(check_iban, _("The IBAN number doesn't seem to be correct"), ["acc_number"])
|
||||
]
|
||||
|
||||
res_partner_bank()
|
||||
|
||||
@@ -1857,6 +1857,7 @@ class account_bank_statement_line(osv.osv):
|
||||
'date': st_line.date,
|
||||
'date_due': st_line.date,
|
||||
'period_id': period_id,
|
||||
'payment_rate_currency_id':to_curr_id,
|
||||
}
|
||||
|
||||
# Define the voucher line
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
##############################################################################
|
||||
{
|
||||
'name': 'HSBC Account Banking',
|
||||
'version': '0.4',
|
||||
'version': '0.5',
|
||||
'license': 'AGPL-3',
|
||||
'author': 'credativ Ltd',
|
||||
'website': 'http://www.credativ.co.uk',
|
||||
@@ -45,7 +45,7 @@
|
||||
This module adds above import/export filter to the account_banking module.
|
||||
All business logic is in account_banking module.
|
||||
|
||||
Initial release of this module was co-sponsored by canonical.
|
||||
Initial release of this module was co-sponsored by Canonical.
|
||||
''',
|
||||
'active': False,
|
||||
'installable': True,
|
||||
|
||||
@@ -106,7 +106,7 @@ class payment_line(osv.osv):
|
||||
info = ''
|
||||
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
partner = line.order_id.mode.bank_id
|
||||
partner = line.bank_id
|
||||
|
||||
name = partner.owner_name or partner.partner_id.name
|
||||
st = partner.street and partner.street or ''
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_banking_hsbc_clientid","banking.hsbc.clientid","model_banking_hsbc_clientid","account_payment.group_account_payment",1,1,1,1
|
||||
|
||||
"access_banking_export_hsbc","banking.export.hsbc","model_banking_export_hsbc","account_payment.group_account_payment",1,1,1,1
|
||||
|
||||
|
@@ -139,7 +139,7 @@ class banking_export_hsbc_wizard(osv.osv_memory):
|
||||
return super(banking_export_hsbc_wizard, self).create(
|
||||
cursor, uid, wizard_data, context)
|
||||
|
||||
def _create_account(self, oe_account):
|
||||
def _create_account(self, oe_account, origin_country=None, is_origin_account=False):
|
||||
currency = None # let the receiving bank select the currency from the batch
|
||||
holder = oe_account.owner_name or oe_account.partner_id.name
|
||||
self.logger.info('Create account %s' % (holder))
|
||||
@@ -191,7 +191,8 @@ class banking_export_hsbc_wizard(osv.osv_memory):
|
||||
currency=currency,
|
||||
swiftcode=oe_account.bank.bic,
|
||||
country=oe_account.country_id.code,
|
||||
#origin_country=origin_country
|
||||
origin_country=origin_country,
|
||||
is_origin_account=is_origin_account
|
||||
)
|
||||
transaction_kwargs = {
|
||||
'charges': paymul.CHARGES_PAYEE,
|
||||
@@ -237,7 +238,7 @@ class banking_export_hsbc_wizard(osv.osv_memory):
|
||||
)
|
||||
|
||||
self.logger.info('====')
|
||||
dest_account, transaction_kwargs = self._create_account(line.bank_id)
|
||||
dest_account, transaction_kwargs = self._create_account(line.bank_id, line.order_id.mode.bank_id.country_id.code)
|
||||
|
||||
means = {'ACH or EZONE': paymul.MEANS_ACH_OR_EZONE,
|
||||
'Faster Payment': paymul.MEANS_FASTER_PAYMENT,
|
||||
@@ -278,7 +279,7 @@ class banking_export_hsbc_wizard(osv.osv_memory):
|
||||
try:
|
||||
self.logger.info('Source - %s (%s) %s' % (payment_orders[0].mode.bank_id.partner_id.name, payment_orders[0].mode.bank_id.acc_number, payment_orders[0].mode.bank_id.country_id.code))
|
||||
src_account = self._create_account(
|
||||
payment_orders[0].mode.bank_id,
|
||||
payment_orders[0].mode.bank_id, payment_orders[0].mode.bank_id.country_id.code, is_origin_account=True
|
||||
)[0]
|
||||
except ValueError as exc:
|
||||
raise osv.except_osv(
|
||||
|
||||
@@ -183,10 +183,13 @@ class NorthAmericanAccount(UKAccount):
|
||||
return account_ident
|
||||
|
||||
def _set_sortcode(self, sortcode):
|
||||
if not edifact_digits(sortcode, 9):
|
||||
raise ValueError("Account routing number must be 9 digits long: " +
|
||||
str(sortcode))
|
||||
|
||||
if self.origin_country == 'CA' and self.is_origin_account:
|
||||
expected_digits = 6
|
||||
else:
|
||||
expected_digits = 9
|
||||
if not edifact_digits(sortcode, expected_digits):
|
||||
raise ValueError("Account routing number must be %d digits long: %s" %
|
||||
(expected_digits, str(sortcode)))
|
||||
|
||||
self._sortcode = sortcode
|
||||
|
||||
@@ -218,14 +221,15 @@ class NorthAmericanAccount(UKAccount):
|
||||
|
||||
number = property(_get_number, _set_number)
|
||||
|
||||
def __init__(self, number, holder, currency, sortcode, swiftcode, country, origin_country=None):
|
||||
def __init__(self, number, holder, currency, sortcode, swiftcode, country, origin_country=None, is_origin_account=False):
|
||||
self.origin_country = origin_country
|
||||
self.is_origin_account = is_origin_account
|
||||
self.number = number
|
||||
self.holder = holder
|
||||
self.currency = currency
|
||||
self.sortcode = sortcode
|
||||
self.country = country
|
||||
self.bic = swiftcode
|
||||
self.origin_country = origin_country
|
||||
self.institution_identification = self._set_account_ident()
|
||||
|
||||
|
||||
@@ -266,14 +270,15 @@ class SWIFTAccount(UKAccount):
|
||||
|
||||
number = property(_get_number, _set_number)
|
||||
|
||||
def __init__(self, number, holder, currency, sortcode, swiftcode, country, origin_country=None):
|
||||
def __init__(self, number, holder, currency, sortcode, swiftcode, country, origin_country=None, is_origin_account=False):
|
||||
self.origin_country = origin_country
|
||||
self.is_origin_account = is_origin_account
|
||||
self.number = number
|
||||
self.holder = holder
|
||||
self.currency = currency
|
||||
self.sortcode = sortcode
|
||||
self.country = country
|
||||
self.bic = swiftcode
|
||||
self.origin_country = origin_country
|
||||
self.institution_identification = self._set_account_ident()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user