~banking-addons-team/banking-addons/6.1-dev

« back to all changes in this revision

Viewing changes to account_banking_uk_hsbc/wizard/paymul.py

  • Committer: James Jesudason
  • Date: 2012-03-22 12:07:57 UTC
  • Revision ID: james.jesudason@canonical.com-20120322120757-n93b5tw1bz5xjfoy
[FIX] Payments from a Canadian bank account need the HSBC 6-digit sort-code number

Show diffs side-by-side

added added

removed removed

Lines of Context:
183
183
        return account_ident
184
184
 
185
185
    def _set_sortcode(self, sortcode):
186
 
        if not edifact_digits(sortcode, 9):
187
 
            raise ValueError("Account routing number must be 9 digits long: " +
188
 
                             str(sortcode))
189
 
 
 
186
        if self.origin_country == 'CA' and self.is_origin_account:
 
187
            expected_digits = 6
 
188
        else:
 
189
            expected_digits = 9
 
190
        if not edifact_digits(sortcode, expected_digits):
 
191
            raise ValueError("Account routing number must be %d digits long: %s" %
 
192
                             (expected_digits, str(sortcode)))
190
193
        
191
194
        self._sortcode = sortcode
192
195
 
218
221
 
219
222
    number = property(_get_number, _set_number)
220
223
 
221
 
    def __init__(self, number, holder, currency, sortcode, swiftcode, country, origin_country=None):
 
224
    def __init__(self, number, holder, currency, sortcode, swiftcode, country, origin_country=None, is_origin_account=False):
 
225
        self.origin_country = origin_country
 
226
        self.is_origin_account = is_origin_account
222
227
        self.number = number
223
228
        self.holder = holder
224
229
        self.currency = currency
225
230
        self.sortcode = sortcode
226
231
        self.country = country
227
232
        self.bic = swiftcode
228
 
        self.origin_country = origin_country
229
233
        self.institution_identification = self._set_account_ident()
230
234
 
231
235
 
266
270
 
267
271
    number = property(_get_number, _set_number)
268
272
 
269
 
    def __init__(self, number, holder, currency, sortcode, swiftcode, country, origin_country=None):
 
273
    def __init__(self, number, holder, currency, sortcode, swiftcode, country, origin_country=None, is_origin_account=False):
 
274
        self.origin_country = origin_country
 
275
        self.is_origin_account = is_origin_account
270
276
        self.number = number
271
277
        self.holder = holder
272
278
        self.currency = currency
273
279
        self.sortcode = sortcode
274
280
        self.country = country
275
281
        self.bic = swiftcode
276
 
        self.origin_country = origin_country
277
282
        self.institution_identification = self._set_account_ident()
278
283
 
279
284