コード例 #1
0
ファイル: boleto.py プロジェクト: LeonamSilva/stoq
 def dac_nosso_numero(self):
     agencia = self.agencia.split('-')[0]
     conta = self.conta.split('-')[0]
     return modulo10(agencia +
                     conta +
                     self.carteira +
                     self.nosso_numero)
コード例 #2
0
ファイル: boleto.py プロジェクト: LeonamSilva/stoq
 def campo_livre(self):
     agencia = self.agencia.split('-')[0]
     conta = self.conta.split('-')[0]
     return "%3s%8s%1s%4s%5s%1s%3s" % (
         self.carteira,
         self.nosso_numero,
         self.dac_nosso_numero,
         agencia,
         conta,
         modulo10(agencia + conta),
         '000'
     )
コード例 #3
0
ファイル: boleto.py プロジェクト: hackedbellini/stoq
    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'))
コード例 #4
0
ファイル: boleto.py プロジェクト: pauloscarin1972/stoq
    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'))
コード例 #5
0
ファイル: boleto.py プロジェクト: pauloscarin1972/stoq
 def digitao_cobranca(self):
     num = "%s%s%s" % (self.nosso_numero, self.agencia, self.conta)
     return modulo10(num)
コード例 #6
0
ファイル: boleto.py プロジェクト: pauloscarin1972/stoq
 def campo_livre(self):
     agencia = self.agencia.split('-')[0]
     conta = self.conta.split('-')[0]
     return "%3s%8s%1s%4s%5s%1s%3s" % (
         self.carteira, self.nosso_numero, self.dac_nosso_numero, agencia,
         conta, modulo10(agencia + conta), '000')
コード例 #7
0
ファイル: boleto.py プロジェクト: pauloscarin1972/stoq
 def dv_agencia_conta(self):
     agencia = self.agencia.split('-')[0]
     conta = self.conta.split('-')[0]
     return modulo10(agencia + conta)
コード例 #8
0
ファイル: boleto.py プロジェクト: pauloscarin1972/stoq
 def dac_nosso_numero(self):
     agencia = self.agencia.split('-')[0]
     conta = self.conta.split('-')[0]
     return modulo10(agencia + conta + self.carteira + self.nosso_numero)
コード例 #9
0
ファイル: boleto.py プロジェクト: pauloscarin1972/stoq
 def monta_campo(campo):
     campo_dv = "%s%s" % (campo, modulo10(campo))
     return "%s.%s" % (campo_dv[0:5], campo_dv[5:])
コード例 #10
0
ファイル: boleto.py プロジェクト: LeonamSilva/stoq
 def digitao_cobranca(self):
     num = "%s%s%s" % (self.nosso_numero,
                       self.agencia,
                       self.conta)
     return modulo10(num)
コード例 #11
0
ファイル: boleto.py プロジェクト: LeonamSilva/stoq
 def agencia_conta(self):
     agencia = self.agencia.split('-')[0]
     conta = self.conta.split('-')[0]
     return '%s / %s-%s' % (agencia,
                            conta,
                            modulo10(agencia + conta))
コード例 #12
0
ファイル: boleto.py プロジェクト: LeonamSilva/stoq
 def monta_campo(campo):
     campo_dv = "%s%s" % (campo, modulo10(campo))
     return "%s.%s" % (campo_dv[0:5], campo_dv[5:])
コード例 #13
0
 def agencia_conta(self):
     agencia = self.agencia.split('-')[0]
     conta = self.conta.split('-')[0]
     return '%s / %s-%s' % (agencia, conta, modulo10(agencia + conta))
コード例 #14
0
ファイル: boleto.py プロジェクト: hackedbellini/stoq
 def dv_agencia_conta(self):
     agencia = self.agencia.split('-')[0]
     conta = self.conta.split('-')[0]
     return modulo10(agencia + conta)