From d4cf87ad92ef99321583aac2292af488b6b9f215 Mon Sep 17 00:00:00 2001 From: Gabriel Cardoso de Faria Date: Fri, 11 Sep 2020 17:07:22 -0300 Subject: [PATCH] [ADD] DAS, ISS and Utility Payment --- cnab_erpbrasil_febraban/febraban/cnab.py | 55 ++++++++++++++++++------ 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/cnab_erpbrasil_febraban/febraban/cnab.py b/cnab_erpbrasil_febraban/febraban/cnab.py index 89658ad14aec..00bc124e5ea4 100644 --- a/cnab_erpbrasil_febraban/febraban/cnab.py +++ b/cnab_erpbrasil_febraban/febraban/cnab.py @@ -12,6 +12,12 @@ import codecs from unidecode import unidecode +from febraban.cnab240.itau.sispag import \ + Transfer, DasPayment, IssPayment, UtilityPayment, 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 + _logger = logging.getLogger(__name__) @@ -34,9 +40,6 @@ def gerar_remessa(order): cnab_type = order.payment_mode_id.payment_method_id.code if cnab_type == '240': - from febraban.cnab240.itau.sispag import Transfer, File - from febraban.cnab240.itau.sispag.file.lot import Lot - from febraban.cnab240.user import User, UserAddress, UserBank sender = User( name=order.company_id.legal_name.upper(), identifier=order.company_id.cnpj_cpf.replace( @@ -66,7 +69,8 @@ def gerar_remessa(order): lot.setSender(sender) lot.setHeaderLotType( kind=order.service_type, # Tipo de pagamento - Fornecedores - method=order.release_form # TED - Outra titularidade + method=order.release_form_itau or + order.release_form # TED - Outra titularidade ) for line in order.bank_line_ids: @@ -83,15 +87,40 @@ def gerar_remessa(order): ) ) - payment = Transfer() - payment.setSender(sender) - payment.setReceiver(receiver) - payment.setAmountInCents(str(int(line.amount_currency * 100))) - payment.setScheduleDate(line.date.strftime('%d%m%Y')) - payment.setInfo( - reason="10" # Crédito em Conta Corrente - ) - payment.setIdentifier("ID%s" % line.own_number) + if order.release_form_itau == "41": + payment = Transfer() + payment.setSender(sender) + payment.setReceiver(receiver) + payment.setAmountInCents(str(int(line.amount_currency * 100))) + payment.setScheduleDate(line.date.strftime('%d%m%Y')) + payment.setInfo( + reason="10" # Crédito em Conta Corrente + ) + payment.setIdentifier("ID%s" % line.own_number) + elif order.release_form_itau == "91": + payment = DasPayment() + payment.setPayment( + sender=sender, + scheduleDate=line.date.strftime('%d%m%Y'), + identifier="ID%s" % line.own_number, + lineNumber=LineNumberO(line.communication) + ) + elif order.release_form_itau == "19": + payment = IssPayment() + payment.setPayment( + sender=sender, + scheduleDate=line.date.strftime('%d%m%Y'), + identifier="ID%s" % line.own_number, + lineNumber=LineNumberO(line.communication) + ) + elif order.release_form_itau == "13": + payment = UtilityPayment() + payment.setPayment( + sender=sender, + scheduleDate=line.date.strftime('%d%m%Y'), + identifier="ID%s" % line.own_number, + lineNumber=LineNumberO(line.communication) + ) lot.add(register=payment) file.addLot(lot)