Esempio n. 1
0
    def write(cls, *args):
        actions = iter(args)
        args = []
        for numbers, values in zip(actions, actions):
            values = values.copy()
            if values.get('type') == 'cbu' and 'number' in values:
                values['number'] = cbu.format(values['number'])
                values['number_compact'] = cbu.compact(values['number'])
            args.extend((numbers, values))

        super(AccountNumber, cls).write(*args)

        to_write = []
        for number in sum(args[::2], []):
            if number.type == 'cbu':
                formated_number = cbu.format(number.number)
                compacted_number = cbu.compact(number.number)
                if ((formated_number != number.number) or
                        (compacted_number != number.number_compact)):
                    to_write.extend(([number], {
                        'number': formated_number,
                        'number_compact': compacted_number,
                        }))
        if to_write:
            cls.write(*to_write)
Esempio n. 2
0
 def create(cls, vlist):
     vlist = [v.copy() for v in vlist]
     for values in vlist:
         if values.get('type') == 'cbu' and 'number' in values:
             values['number'] = cbu.format(values['number'])
             values['number_compact'] = cbu.compact(values['number'])
     return super(AccountNumber, cls).create(vlist)
Esempio n. 3
0
 def compact_cbu(self):
     return (cbu.compact(self.number) if self.type == 'cbu'
         else self.number)