from unittest.case import TestCase from febraban.cnab240.itau.charge import SegmentP, SegmentQ, SegmentR from febraban.cnab240.user import User, UserBank, UserAddress bank = UserBank(bankId="341", branchCode="1234", accountNumber="1234567", accountVerifier="8") address = UserAddress(streetLine1="AV PAULISTA 1000", city="SAO PAULO", stateCode="SP", zipCode="01310000") payer = User( name="ARYA STARK", identifier="12345678901", ) guarantor = User(name="SACADOR", identifier="09876543210") class CancelTest(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")
from febraban.cnab240.user import User, UserBank, UserAddress from febraban.cnab240.v30.slip.segmentQ import SegmentQ user = User( name="JOHN SMITH", identifier="12345678901", ) bank = UserBank(bankId="341", branchCode="1234", accountNumber="1234567", accountVerifier="8") address = UserAddress(streetName="AV PAULISTA", number="1000", city="SAO PAULO", state="SP", zipcode="01310000") class SegmentQTest(TestCase): def testSegmentQlengh(self): string = SegmentQ().content self.assertEqual(len(string), 240) def testSegmentQdefaultValues(self): content = SegmentQ().content self.assertEqual(content[3:7], "0001") self.assertEqual(content[7:8], "3") self.assertEqual(content[13:14], "Q") self.assertEqual(content[15:17], "01")
# 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)
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
myself = User( name="YOUR COMPANY NAME", identifier="123456789012345", bank=UserBank( bankId="341", branchCode="1234", accountNumber="33333", accountVerifier="4", bankName="BANCO ITAU SA" ), address=UserAddress( streetName="AV PAULISTA", number="1000", complement="CJ 601", city="SAO PAULO", state="SP", zipcode="01310000" ) ) payer = User( name="PAYER NAME", identifier="12345678901", address=UserAddress( streetName="AV PAULISTA", number="1000", district="BELA VISTA", city="SAO PAULO", state="SP", zipcode="01310000"