def dados_boleto(self):
        journal = self.env['account.journal'].search([('code', '=', 'Inter')])
        dados = []
        myself = User(
            name=self.company_id.legal_name,
            identifier=misc.punctuation_rm(self.company_id.cnpj_cpf),
            bank=UserBank(
                bankId=journal.bank_account_id.bank_id.bic,
                branchCode=journal.bank_account_id.bra_number,
                accountNumber=journal.bank_account_id.acc_number,
                accountVerifier=journal.bank_account_id.acc_number_dig,
                bankName=journal.bank_account_id.bank_id.name
            ),
        )
        payer = User(
            name=self.partner_id.name,
            identifier=misc.punctuation_rm(self.partner_id.cnpj_cpf),
            email=self.partner_id.email,
            personType='FISICA' if self.partner_id.company_type == 'person' else 'JURIDICA',
            phone=caracteres_rm(self.partner_id.phone),
            address=UserAddress(
                streetLine1=self.partner_id.street,
                district=self.partner_id.district,
                city=self.partner_id.city_id.name,
                stateCode=self.partner_id.state_id.code,
                zipCode=misc.punctuation_rm(self.partner_id.zip),
                streetNumber=self.partner_id.number,
            )
        )

        slip = BoletoInter(
            sender=myself,
            amount=self.amount_total,
            payer=payer,
            issue_date=datetime.now(),
            identifier=misc.punctuation_rm(self.partner_id.cnpj_cpf),
            instructions=[
                journal.instrucao1,
                journal.instrucao2,
                journal.instrucao3,
                journal.instrucao4,
            ],
            multa=dict(
                codigoMulta=journal.codigo_multa,
                data=str(self.date_due + timedelta(days=journal.dia_carencia_multa)),
                valor=0 if journal.codigo_multa == 'PERCENTUAL' else journal.valor_multa,
                taxa=0 if journal.codigo_multa == 'VALORFIXO' else journal.taxa_multa
            ),
            mora=dict(
                codigoMora=journal.codigo_mora,
                data=str(self.date_due + timedelta(days=journal.dia_carencia_mora)),
                valor=0 if journal.codigo_mora == 'TAXAMENSAL' else journal.valor_mora,
                taxa=0 if journal.codigo_mora == 'VALORFIXO' else journal.taxa_mora
            ),
            due_date=self.date_due,
        )
        dados.append(slip)
        return dados
Exemplo n.º 2
0
 def _generate_bank_inter_boleto_data(self):
     dados = []
     myself = User(
         name=self.company_id.legal_name,
         identifier=misc.punctuation_rm(self.company_id.cnpj_cpf),
         bank=UserBank(
             bankId=self.company_partner_bank_id.bank_id.code_bc,
             branchCode=self.company_partner_bank_id.bra_number,
             accountNumber=self.company_partner_bank_id.acc_number,
             accountVerifier=self.company_partner_bank_id.acc_number_dig,
             bankName=self.company_partner_bank_id.bank_id.name,
         ),
     )
     for line in self.bank_line_ids:
         payer = User(
             name=line.partner_id.legal_name,
             identifier=misc.punctuation_rm(
                 line.partner_id.cnpj_cpf
             ),
             email=line.partner_id.email or '',
             personType=(
                 "FISICA" if line.partner_id.company_type == 'person'
                 else 'JURIDICA'),
             phone=misc.punctuation_rm(
                 line.partner_id.phone).replace(" ", ""),
             address=UserAddress(
                 streetLine1=line.partner_id.street or '',
                 district=line.partner_id.district or '',
                 city=line.partner_id.city_id.name or '',
                 stateCode=line.partner_id.state_id.code or '',
                 zipCode=misc.punctuation_rm(line.partner_id.zip),
                 streetNumber=line.partner_id.street_number,
             )
         )
         slip = BoletoInter(
             sender=myself,
             amount=line.amount_currency,
             payer=payer,
             issue_date=line.create_date,
             due_date=line.date,
             identifier=line.document_number,
             instructions=[
                 'TESTE 1',
                 'TESTE 2',
                 'TESTE 3',
                 'TESTE 4',
             ]
         )
         dados.append(slip)
     return dados
Exemplo n.º 3
0
    def setUp(self):
        certificado_cert = os.environ.get('certificado_inter_cert')
        certificado_key = os.environ.get('certificado_inter_key')

        self.api = ApiInter(cert=(certificado_cert, certificado_key),
                            conta_corrente='14054310')
        self.dados = []

        myself = User(
            name='KMEE INFORMATICA LTDA',
            identifier='23130935000198',
            bank=UserBank(bankId="341",
                          branchCode="1234",
                          accountNumber="33333",
                          accountVerifier="4",
                          bankName="BANCO ITAU SA"),
        )
        now = datetime.now()
        for i in range(3):
            payer = User(name="Sacado Teste",
                         identifier="26103754097",
                         email="*****@*****.**",
                         personType="FISICA",
                         phone="35988763663",
                         address=UserAddress(
                             streetLine1="Rua dos TESTES",
                             district="CENTRO",
                             city="SAO PAULO",
                             stateCode="SP",
                             zipCode="31327130",
                             streetNumber="15",
                         ))
            slip = BoletoInter(sender=myself,
                               amount_in_cents="100.00",
                               payer=payer,
                               issue_date=now,
                               due_date=now,
                               identifier="456" + str(i),
                               instructions=[
                                   'TESTE 1',
                                   'TESTE 2',
                                   'TESTE 3',
                                   'TESTE 4',
                               ])
            self.dados.append(slip)
Exemplo n.º 4
0
from unittest.case import TestCase
from febraban.cnab240.itau.charge import SegmentP
from febraban.cnab240.user import User, UserBank, UserAddress

user = User(
    name="JOHN SMITH",
    identifier="12345678901",
)

bank = UserBank(bankId="341",
                branchCode="1234",
                accountNumber="1234567",
                accountVerifier="8")

address = UserAddress(streetLine1="AV PAULISTA 1000",
                      city="SAO PAULO",
                      stateCode="SP",
                      zipCode="01310000")


class SegmentPTest(TestCase):
    def testSegmentPlengh(self):
        string = SegmentP().content
        self.assertEqual(len(string), 240)

    def testSegmentPdefaultValues(self):
        content = SegmentP().content
        self.assertEqual(content[3:7], "0001")
        self.assertEqual(content[7:8], "3")
        self.assertEqual(content[13:14], "P")
        self.assertEqual(content[15:17], "01")
# coding: utf-8

from febraban.cnab240.itau.sispag import DasPayment, File
from febraban.cnab240.itau.sispag.file.lot import Lot
from febraban.cnab240.libs.barCode import LineNumberO
from febraban.cnab240.user import User, UserAddress, UserBank


sender = User(
    name="YOUR COMPANY NAME HERE",
    identifier="12345678901234",
    bank=UserBank(
        bankId="341",
        branchCode="4321",
        accountNumber="12345678",
        accountVerifier="9"
    ),
    address=UserAddress(
        streetLine1="AV PAULISTA 1000",
        city="SAO PAULO",
        stateCode="SP",
        zipCode="01310000"
    )
)

lineNumbers = [
    "818300000000351237012007512320036434688123299220"
]

file = File()
file.setSender(sender)
Exemplo n.º 6
0
    def _generate_bank_inter_boleto_data(self):

        dados = []
        myself = User(
            name=self.company_id.l10n_br_legal_name,
            identifier=misc.punctuation_rm(self.company_id.l10n_br_cnpj_cpf),
            bank=UserBank(
                bankId=self.payment_mode_id.fixed_journal_id.bank_id.code_bc,
                branchCode=self.payment_mode_id.fixed_journal_id.bank_account_id.bra_number,
                accountNumber=self.payment_mode_id.fixed_journal_id.bank_account_id.acc_number,
                accountVerifier=self.payment_mode_id.fixed_journal_id.bank_account_id.acc_number_dig,
                bankName=self.payment_mode_id.fixed_journal_id.bank_id.name,
            ),
        )
        #raise ValidationError(f"{self.company_id.l10n_br_legal_name} {misc.punctuation_rm(self.company_id.l10n_br_cnpj_cpf)} {self.payment_mode_id.fixed_journal_id.bank_id.code_bc} {self.payment_mode_id.fixed_journal_id.bank_account_id.bra_number} {self.payment_mode_id.fixed_journal_id.bank_account_id.acc_number} {self.payment_mode_id.fixed_journal_id.bank_account_id.acc_number_dig} {self.payment_mode_id.fixed_journal_id.bank_id.name} ")
        for moveline in self.receivable_move_line_ids:
        #if 1:
            payer = User(
                #name=moveline.partner_id.l10n_br_legal_name,
                name=moveline.partner_id.l10n_br_legal_name or moveline.partner_id.name,
                identifier=misc.punctuation_rm(
                    moveline.partner_id.l10n_br_cnpj_cpf
                ),
                email=moveline.partner_id.email or '',
                personType=(
                    "FISICA" if moveline.partner_id.company_type == 'person'
                    else 'JURIDICA'),
                phone=misc.punctuation_rm(
                    moveline.partner_id.phone).replace(" ", "")[2:],
                address=UserAddress(
                    streetLine1=moveline.partner_id.street or '',
                    district=moveline.partner_id.l10n_br_district or '',
                    city=moveline.partner_id.city_id.name or '',
                    stateCode=moveline.partner_id.state_id.code or '',
                    zipCode=misc.punctuation_rm(moveline.partner_id.zip),
                    streetNumber=moveline.partner_id.l10n_br_number,
                )
            )
            #raise ValidationError(f"{moveline.partner_id.l10n_br_legal_name} {moveline.partner_id.l10n_br_cnpj_cpf} {moveline.partner_id.email} {moveline.partner_id.company_type} {moveline.partner_id.phone} {moveline.partner_id.street} {moveline.partner_id.l10n_br_district} {moveline.partner_id.city_id.name} {moveline.partner_id.state_id.code} {moveline.partner_id.zip} {moveline.partner_id.l10n_br_number} ")
            _instructions = str(self.invoice_payment_term_id.note).split('\n')
            invoice_payment_term_id = self.invoice_payment_term_id
            codigoMora = invoice_payment_term_id.interst_mode
            mora_valor = invoice_payment_term_id.interst_value if codigoMora == 'VALORDIA' else 0
            mora_taxa  = invoice_payment_term_id.interst_value if codigoMora == 'TAXAMENSAL' else 0
            data_mm = (moveline.date_maturity +  timedelta(days=1)).strftime('%Y-%m-%d') if not codigoMora == 'ISENTO' else ''
            codigoMulta = invoice_payment_term_id.fine_mode
            multa_valor = invoice_payment_term_id.fine_value if codigoMulta == 'VALORFIXO' else 0
            multa_taxa  = invoice_payment_term_id.fine_value if codigoMulta == 'PERCENTUAL' else 0
            mora = dict(
                codigoMora=codigoMora,
                valor=mora_valor,
                taxa=mora_taxa,
                data=data_mm
                )
            multa = dict(
                codigoMulta=codigoMulta,
                valor=multa_valor,
                taxa=multa_taxa,
                data=data_mm
                )

            slip = BoletoInter(
                sender=myself,
                #amount=moveline.amount_currency,
                amount=moveline.amount_residual,
                payer=payer,
                issue_date=moveline.date,
                due_date=moveline.date_maturity,
                identifier=moveline.move_name,
                mora=mora,
                multa=multa,
                #identifier='999999999999999',
                instructions=_instructions,
            )
            #raise ValidationError(f"{moveline.amount_residual} {moveline.create_date} {moveline.date} {moveline.move_name} ")
            dados.append(slip)
        return dados
# coding: utf-8

from datetime import datetime
from febraban.cnab240.itau.charge import Slip, File
from febraban.cnab240.user import User, UserAddress, UserBank

myself = User(name="YOUR COMPANY NAME",
              identifier="123456789012345",
              bank=UserBank(bankId="341",
                            branchCode="1234",
                            accountNumber="33333",
                            accountVerifier="4",
                            bankName="BANCO ITAU SA"),
              address=UserAddress(streetLine1="AV PAULISTA 1000",
                                  streetLine2="CJ 601",
                                  city="SAO PAULO",
                                  stateCode="SP",
                                  zipCode="01310000"))

payer = User(name="PAYER NAME",
             identifier="12345678901",
             address=UserAddress(streetLine1="AV PAULISTA 1000",
                                 district="BELA VISTA",
                                 city="SAO PAULO",
                                 stateCode="SP",
                                 zipCode="01310000"))
now = datetime.now()

file = File()
file.setSender(myself)
file.setIssueDate(now)