Пример #1
0
def get_boleto_itau_109(faturas,remessa):
    listaDados = [] 
    for fatura in faturas:
        d = BoletoItau109()
        d.carteira = '109'  # Contrato firmado com o Banco Bradesco
        d.cedente = remessa['razao_social'].strip()
        d.cedente_documento = remessa['cnpj'].strip()

        d.cedente_endereco = "%(endereco)s-%(bairro)s-%(nome_cidade)s-%(uf)s-CEP:%(cep)s" % (remessa)
        d.agencia_cedente = remessa['numero_agencia']
        #d.conta_cedente = remessa['numero_conta']
        conta_cedente = remessa['numero_conta'].split('-')[0]
        
        d.conta_cedente = conta_cedente

        d.data_vencimento = fatura['vencimento_boleto']
        d.data_documento = fatura['data_processamento']
        d.data_processamento = fatura['data_processamento']

        #"{0:0.2f}".format(Decimal('119.41'))

        d.instrucoes = [
            "%(msg_multa)s%(msg_juros)s" % (fatura),
            remessa['instrucoes']
            ]
        if fatura['abatimento'] > 0:
            d.instrucoes.append("Conceder abatimento de R$ %s" % (format_value(fatura['abatimento'])))

        d.demonstrativo = [
            "- Serviço Transporte: RS %s " % (format_value(fatura['valor_fatura'])),
            "- Total R$ %s " % (format_value(fatura['valor_fatura']))
            ]

                
        d.valor_documento = format_value(fatura['valor_boleto'])
        d.especie_documento = "DS"             
        
        d.nosso_numero = fatura['numero_boleto']
        d.numero_documento = fatura['numero_fatura'][3:]
        d.sacado = [
            fatura['fatura_nome'] + ' - ' + fatura['fatura_cnpj'],
            "%(fatura_endereco)s - %(fatura_bairro)s" % (fatura),
            "%(fatura_cidade)s-%(fatura_uf)s - CEP: %(fatura_cep)s" %(fatura)
            ]
        listaDados.append(d)

    # Bradesco Formato carne - duas paginas por folha A4
    output = BytesIO()
    boleto = BoletoPDF(output)
    for i in range(len(listaDados)):
        boleto.drawBoleto(
            listaDados[i]
        )
        boleto.nextPage()    
    boleto.save()
                      
    pdf_out = output.getvalue()
    output.close()
    
    return make_response(pdf_out)
Пример #2
0
 def _get_valor_documento(self):
     if self._valor_documento is not None:
         #return "%.2f" % self._valor_documento
         return format_value(self._valor_documento)
Пример #3
0
 def _get_valor(self):
     if self._valor is not None:
         #return "%.2f" % self._valor
         return format_value(self._valor)