mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Use the SWIFT code as the default account code format
This commit is contained in:
@@ -202,11 +202,28 @@ class banking_export_hsbc_wizard(osv.osv_memory):
|
||||
'charges': paymul.CHARGES_PAYEE,
|
||||
}
|
||||
else:
|
||||
self.logger.notifyChannel('paymul', netsvc.LOG_INFO,'Unsupported Account: %s' % (oe_account.country_id.code))
|
||||
raise osv.except_osv(
|
||||
_('Error'),
|
||||
_('%s: only UK, US, Canada accounts and IBAN are supported') % (holder)
|
||||
self.logger.notifyChannel('paymul', netsvc.LOG_INFO,'SWIFT Account: %s' % (oe_account.country_id.code))
|
||||
split = oe_account.acc_number.split(' ', 2)
|
||||
if len(split) == 2:
|
||||
sortcode, accountno = split
|
||||
else:
|
||||
raise osv.except_osv(
|
||||
_('Error'),
|
||||
"Invalid %s account number '%s'" % (oe_account.country_id.code,oe_account.acc_number))
|
||||
paymul_account = paymul.SWIFTAccount(
|
||||
number=accountno,
|
||||
sortcode=sortcode,
|
||||
holder=holder,
|
||||
currency=currency,
|
||||
swiftcode=oe_account.bank.bic,
|
||||
country=oe_account.country_id.code,
|
||||
)
|
||||
transaction_kwargs = {
|
||||
'charges': paymul.CHARGES_PAYEE,
|
||||
}
|
||||
transaction_kwargs = {
|
||||
'charges': paymul.CHARGES_PAYEE,
|
||||
}
|
||||
|
||||
return paymul_account, transaction_kwargs
|
||||
|
||||
|
||||
@@ -224,6 +224,54 @@ class NorthAmericanAccount(UKAccount):
|
||||
self.institution_identification = self._set_account_ident()
|
||||
|
||||
|
||||
class SWIFTAccount(UKAccount):
|
||||
|
||||
def _set_account_ident(self):
|
||||
# Using the BIC/Swift Code
|
||||
return [self.bic, 25, 5, '', '', '']
|
||||
|
||||
def _set_sortcode(self, sortcode):
|
||||
self._sortcode = sortcode
|
||||
|
||||
def _get_sortcode(self):
|
||||
return self._sortcode
|
||||
|
||||
sortcode = property(_get_sortcode, _set_sortcode)
|
||||
|
||||
def _set_bic(self, bic):
|
||||
if not edifact_isalnum_size(bic, 8) and not edifact_isalnum_size(bic, 11):
|
||||
raise ValueError("Account BIC/Swift code must be 8 or 11 characters long: " +
|
||||
str(bic))
|
||||
self._bic = bic
|
||||
|
||||
def _get_bic(self):
|
||||
return self._bic
|
||||
|
||||
bic = property(_get_bic, _set_bic)
|
||||
|
||||
def _set_number(self, number):
|
||||
if not edifact_digits(number, mindigits=1):
|
||||
raise ValueError("Account number is invalid: " +
|
||||
str(number))
|
||||
|
||||
self._number = number
|
||||
|
||||
def _get_number(self):
|
||||
return self._number
|
||||
|
||||
number = property(_get_number, _set_number)
|
||||
|
||||
def __init__(self, number, holder, currency, sortcode, swiftcode, country, origin_country=None):
|
||||
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()
|
||||
|
||||
|
||||
class IBANAccount(HasCurrency):
|
||||
def _get_iban(self):
|
||||
return self._iban
|
||||
|
||||
Reference in New Issue
Block a user