[IMP] account_banking: moved check on SEPA countries from iban.__init__ to

iban.valid to ease tests
This commit is contained in:
Pieter J. Kersten
2010-02-12 19:04:33 +01:00
parent b26ec7eda5
commit 8c1decb163
2 changed files with 3 additions and 6 deletions

View File

@@ -277,12 +277,8 @@ class IBAN(str):
Sanity check: don't offer extensions unless the base is sound.
'''
super(IBAN, self).__init__()
# Rearrange position of country code and check digits
if self.countrycode not in self.countries:
self.BBAN_format = self.unknown_BBAN_format
raise Warning, \
'Don\'t know how to format BBAN for country %s' % \
self.countrycode
else:
self.BBAN_format = self.BBAN_formats[self.countrycode]
@@ -326,7 +322,8 @@ class IBAN(str):
Check if the string + check digits deliver a valid checksum
'''
_buffer = self[4:] + self[:4]
return int(base36_to_base10str(_buffer)) % 97 == 1
return self.countrycode in self.countries and \
int(base36_to_base10str(_buffer)) % 97 == 1
def __repr__(self):
'''

View File

@@ -24,7 +24,6 @@ import pooler
import base64
from datetime import datetime, date, timedelta
from account_banking import sepa
#from osv import osv
from tools.translate import _
#import pdb; pdb.set_trace()
import clieop
@@ -298,6 +297,7 @@ def _create_clieop(self, cursor, uid, data, context):
kwargs['messages'] = [line.communication2]
other_account_nr = line.bank_id.acc_number
iban = sepa.IBAN(other_account_nr)
# Is this an IBAN account?
if iban.valid:
if iban.countrycode != 'NL':
raise wizard.except_wizard(