Beispiel #1
0
 def agencia_conta(self):
     return "%s-%s / %s-%s" % (
         self.agencia,
         modulo11(self.agencia),
         self.conta,
         modulo11(self.conta)
     )
Beispiel #2
0
 def calculate_dv_barcode(self, line):
     resto2 = modulo11(line, 9, 1)
     if resto2 in [0, 1, 10]:
         dv = 1
     else:
         dv = 11 - resto2
     return dv
Beispiel #3
0
 def calculate_dv_barcode(self, line):
     resto2 = modulo11(line, 9, 1)
     if resto2 in [0, 1, 10]:
         dv = 1
     else:
         dv = 11 - resto2
     return dv
Beispiel #4
0
 def dv_nosso_numero(self):
     resto2 = modulo11(self.nosso_numero.split('-')[0], 9, 1)
     digito = 11 - resto2
     if digito == 10 or digito == 11:
         dv = 0
     else:
         dv = digito
     return dv
Beispiel #5
0
 def dv_nosso_numero(self):
     resto2 = modulo11(self.nosso_numero.split('-')[0], 9, 1)
     digito = 11 - resto2
     if digito == 10 or digito == 11:
         dv = 0
     else:
         dv = digito
     return dv
Beispiel #6
0
 def dv_nosso_numero(self):
     resto2 = modulo11(self.nosso_numero, 7, 1)
     digito = 11 - resto2
     if digito == 10:
         dv = 'P'
     elif digito == 11:
         dv = 0
     else:
         dv = digito
     return dv
Beispiel #7
0
 def dv_nosso_numero(self):
     resto2 = modulo11(self.nosso_numero, 7, 1)
     digito = 11 - resto2
     if digito == 10:
         dv = 'P'
     elif digito == 11:
         dv = 0
     else:
         dv = digito
     return dv
Beispiel #8
0
    def campo_livre(self):
        conta = self.formata_numero(self.conta, 7)
        dv_nosso_numero = modulo11(self.nosso_numero)

        return '%s%s00000%s%s%s%s' % (self.fixo,
                                      conta,
                                      self.nosso_numero,
                                      dv_nosso_numero,
                                      self.ios,
                                      self.carteira)
Beispiel #9
0
    def validate_field(cls, field):
        if ' ' in field:
            raise BoletoException(_('The field cannot have spaces'))
        if '.' in field or ',' in field:
            raise BoletoException(_('The field cannot have dots of commas'))
        dv = None
        if '-' in field:
            if field.count('-') != 1:
                raise BoletoException(_('More than one hyphen found'))
            field, dv = field.split('-', 1)
            if not dv:
                raise BoletoException(_('Verifier digit cannot be empty'))
        try:
            int(field)
        except ValueError:
            raise BoletoException(_('Account needs to be a number'))

        if dv and cls.validate_field_dv is not None:
            func = cls.validate_field_func
            if func == 'modulo11':
                ret = modulo11(field)
            elif func == 'modulo10':
                ret = modulo10(field)
            else:
                ret = None

            if dv.lower() in [cls.validate_field_dv]:
                # FIXME: Is it correct that the rest of 0 is
                #        the same as 10?
                if ret == 0:
                    pass
                elif (ret is not None and
                      str(ret) != dv.lower() and
                      ret < 10):
                    raise BoletoException(_('Invalid verifier digit'))
            else:
                try:
                    dv = int(dv)
                except ValueError:
                    raise BoletoException(
                        _('Verifier digit must be a number or %s') %
                        cls.validate_field_dv)

                if ret is not None and ret != dv:
                    raise BoletoException(_('Invalid verifier digit'))
Beispiel #10
0
    def validate_field(cls, field):
        if ' ' in field:
            raise BoletoException(_('The field cannot have spaces'))
        if '.' in field or ',' in field:
            raise BoletoException(_('The field cannot have dots of commas'))
        dv = None
        if '-' in field:
            if field.count('-') != 1:
                raise BoletoException(_('More than one hyphen found'))
            field, dv = field.split('-', 1)
            if not dv:
                raise BoletoException(_('Verifier digit cannot be empty'))
        try:
            int(field)
        except ValueError:
            raise BoletoException(_('Account needs to be a number'))

        if dv and cls.validate_field_dv is not None:
            func = cls.validate_field_func
            if func == 'modulo11':
                ret = modulo11(field)
            elif func == 'modulo10':
                ret = modulo10(field)
            else:
                ret = None

            if dv.lower() in [cls.validate_field_dv]:
                # FIXME: Is it correct that the rest of 0 is
                #        the same as 10?
                if ret == 0:
                    pass
                elif (ret is not None and str(ret) != dv.lower() and ret < 10):
                    raise BoletoException(_('Invalid verifier digit'))
            else:
                try:
                    dv = int(dv)
                except ValueError:
                    raise BoletoException(
                        _('Verifier digit must be a number or %s') %
                        cls.validate_field_dv)

                if ret is not None and ret != dv:
                    raise BoletoException(_('Invalid verifier digit'))
Beispiel #11
0
    def campo_livre(self):
        conta = self.formata_numero(self.conta, 7)
        dv_nosso_numero = modulo11(self.nosso_numero)

        return '%s%s00000%s%s%s%s' % (self.fixo, conta, self.nosso_numero,
                                      dv_nosso_numero, self.ios, self.carteira)
Beispiel #12
0
 def format_nosso_numero(self):
     return "00000%s-%s" % (self.nosso_numero, modulo11(self.nosso_numero))
Beispiel #13
0
def validate_invoice_key(key):
    if len(key) != 44:
        return False

    return int(key[-1]) == modulo11(key[:-1])
Beispiel #14
0
 def dv_nosso_numero(self):
     return modulo11(self.nosso_numero)
Beispiel #15
0
 def agencia_conta(self):
     return "%s-%s / %s-%s" % (self.agencia, modulo11(
         self.agencia), self.conta, modulo11(self.conta))
Beispiel #16
0
 def codigo_dv_banco(self):
     num = '%03d' % (self.bank_number, )
     cod = "%s-%s" % (num, modulo11(num))
     return cod
Beispiel #17
0
 def codigo_dv_banco(self):
     num = '%03d' % (self.bank_number, )
     cod = "%s-%s" % (num, modulo11(num))
     return cod
Beispiel #18
0
 def dv_nosso_numero(self):
     return modulo11(self.nosso_numero)
Beispiel #19
0
def validate_invoice_key(key):
    if len(key) != 44:
        return False

    return int(key[-1]) == modulo11(key[:-1])
Beispiel #20
0
 def format_nosso_numero(self):
     return "00000%s-%s" % (
         self.nosso_numero,
         modulo11(self.nosso_numero))