├── .gitignore ├── .travis.yml ├── LICENSE ├── MANIFEST.in ├── README.rst ├── bin ├── html_pyboleto_sample.py ├── pdf_pyboleto_in_memory_sample.py └── pdf_pyboleto_sample.py ├── docs ├── Makefile ├── _static │ └── .gitignore ├── _templates │ └── layout.html ├── conf.py ├── index.rst ├── make.bat ├── modules.rst ├── pyboleto.bank.rst ├── pyboleto.django.rst └── pyboleto.rst ├── pyboleto ├── __init__.py ├── bank │ ├── __init__.py │ ├── bancodobrasil.py │ ├── banrisul.py │ ├── bradesco.py │ ├── caixa.py │ ├── caixa_sigcb.py │ ├── cecred.py │ ├── hsbc.py │ ├── itau.py │ ├── santander.py │ ├── sicoob.py │ └── sicredi.py ├── data.py ├── html.py ├── media │ ├── logo_bancobradesco.jpg │ ├── logo_bancocaixa.jpg │ ├── logo_bancohsbc.jpg │ ├── logo_bancoreal.jpg │ ├── logo_banrisul.jpg │ ├── logo_bb.jpg │ ├── logo_cecred.jpg │ ├── logo_itau.jpg │ ├── logo_santander.png │ ├── logo_sicoob.jpg │ └── logo_sicredi.png ├── pdf.py └── templates │ ├── head.html │ ├── recibo_caixa.html │ └── recibo_sacado.html ├── requirements.txt ├── setup.cfg ├── setup.py ├── specs ├── BancoDoBrasil │ └── Doc5175Bloqueto.pdf ├── BancoReal │ ├── COBRANCA_240_POSICOES.pdf │ └── COBRANCA_CARNES_400_POSICOES.pdf ├── Bradesco │ ├── Boleto_formulas_layout_bradesco.doc │ ├── Layout Cobranca e Boleto Completo BRADESCO_ATUALIZADO.pdf │ ├── Layout_Bradesco_ArqRetorno.pdf │ └── Manual_BRADESCO.PDF ├── Caixa │ ├── CEF-SIGCB.doc │ ├── CEF-SINCO Cnab240.pdf │ ├── CNAB240_SINCO.pdf │ ├── Caixa Economica Federal - Cobranca.doc │ ├── Codigo_Barras_Bloquetos_Cobranca_sem_Registro_SINCO.pdf │ ├── Manual Codigo de Barras.doc │ └── Manual_CAIXA.PDF ├── Febraban │ ├── layout240V0803.pdf │ └── layoutRecebimentoCodigoBarrasv28052004.pdf ├── HSBC │ ├── cnr240-remessa.pdf │ ├── cnr240.pdf │ ├── cnrbarra.pdf │ ├── cnrremes.pdf │ ├── cnrretor.pdf │ ├── cob240.pdf │ ├── cob400_jan.pdf │ └── cobbarra.pdf ├── Itau │ └── cobranca_cnab240.pdf ├── Santander │ └── Layout de Cobrança - Código de Barras Santander Setembro 2012 v 2 3.pdf ├── Sicoob │ └── Layout Sicoob.xls └── Sicredi │ ├── manual-cnab-240.pdf │ └── manual-cnab-400.pdf └── tests ├── __init__.py ├── html ├── BoletoBB-expected.html ├── BoletoBanrisul-expected.html ├── BoletoBradesco-expected.html ├── BoletoCaixa-expected.html ├── BoletoHsbc-expected.html ├── BoletoHsbcComRegistro-expected.html ├── BoletoItau-expected.html ├── BoletoSantander-expected.html ├── BoletoSicoob-expected.html └── BoletoSicredi-expected.html ├── test_banco_banrisul.py ├── test_banco_bradesco.py ├── test_banco_caixa.py ├── test_banco_do_brasil.py ├── test_banco_hsbc.py ├── test_banco_hsbc_com_registro.py ├── test_banco_itau.py ├── test_banco_santander.py ├── test_banco_sicoob.py ├── test_banco_sicredi.py ├── testutils.py └── xml ├── BoletoBB-expected.xml ├── BoletoBanrisul-expected.xml ├── BoletoBradesco-expected.xml ├── BoletoCaixa-expected.xml ├── BoletoHsbc-expected.xml ├── BoletoHsbcComRegistro-expected.xml ├── BoletoItau-expected.xml ├── BoletoSantander-expected.xml ├── BoletoSicoob-expected.xml ├── BoletoSicredi-expected.xml ├── Triplo-BoletoBB-expected.xml ├── Triplo-BoletoBanrisul-expected.xml ├── Triplo-BoletoBradesco-expected.xml ├── Triplo-BoletoCaixa-expected.xml ├── Triplo-BoletoHsbc-expected.xml ├── Triplo-BoletoHsbcComRegistro-expected.xml ├── Triplo-BoletoItau-expected.xml ├── Triplo-BoletoSantander-expected.xml ├── Triplo-BoletoSicoob-expected.xml └── Triplo-BoletoSicredi-expected.xml /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[co] 2 | 3 | *.swp 4 | .DS_Store 5 | .eggs 6 | .tox 7 | .coverage.* 8 | */__pycache__ 9 | 10 | # Packages 11 | *.egg 12 | *.egg-info 13 | dist 14 | build 15 | eggs 16 | parts 17 | var 18 | sdist 19 | develop-eggs 20 | docs/_build/* 21 | .installed.cfg 22 | 23 | # Installer logs 24 | pip-log.txt 25 | 26 | # Unit test / coverage reports 27 | .coverage 28 | .tox 29 | 30 | #Translations 31 | *.mo 32 | 33 | #Mr Developer 34 | .mr.developer.cfg 35 | venv 36 | 37 | .cache 38 | .pytest_cache 39 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - '3.6' 4 | before_install: 5 | - sudo apt-get update 6 | - sudo apt-get install poppler-utils 7 | virtual_env: 8 | system_site_packages: true 9 | install: 10 | - pip install --upgrade pip 11 | - pip install -r requirements.txt 12 | script: pytest --cov=pyboleto 13 | after_success: coveralls 14 | deploy: 15 | provider: pypi 16 | user: trustcode 17 | on: 18 | branch: master3 19 | password: 20 | secure: lwd9y+aZKEHwl66Ozv4pa41DK1bh0p3tPV0HM2GDzELTAgtbg5+2BhNqAzQOisgjb99Y4HVQxxFsFtDQo6DL1ze3kuMyrJ7+3uzeX/FpEYqlw/ufb+pfCc0wdy3LsVJFH7pFhD4F45WGFnaJkg3OSCX5YTz9CfEwKDdDMVG6O0tXmyALsfU2rLnM5FoQwV/l5lGDaXO17s9mO02L8kUh68nnrJ6y5CzjOj+K/uuHzSDUIkocauQzdwzw6A1mYtxEYu3uOL1osv/Bb3aHSPd9W8Jp6VBfM21aakZxnROHsNO0g2HEXUju8TUL7XmrOu9llJc9gBG6Iv0p98UoXzQCpiJ8BS9kcbCBQ4lrWbtAUz91Ql+Jmu8CZoq8sCuPypoLp+3iQcTwkKcZTguw7lPQTT1fXR6aA44zxra0miujFDTDdKnHjTHGDNagZd03oq9ciq6ObZXl9N2o/CIymi+ApmpEojG8Ufb/qXVp1VuIllw88wI6w0NG3u2KWQm6qjFg5MGPsA5YvGxZAO6pUT+FBJ/+l3dfA97pg7YgP9Pk/21+ie/5LCOBmbZ7ufQZrrL9mcRsJvSRJMHV+eKrtkt/yvr49os+/HLZpzW9ghO6F+O93BazqsVfTSBffxpSRT1iY9yQu6fNltypCoV52BweqQugF9BpZgUZefgyzhiHFQ8= 21 | distributions: bdist_wheel 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, Eduardo Cereto Carvalho and contributors. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | 13 | Neither the name of Eduardo Cereto Carvalho nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without 15 | specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 19 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst 2 | include LICENSE 3 | recursive-include pyboleto/media * 4 | recursive-include pyboleto/templates * 5 | recursive-include tests * 6 | include bin/pdf_pyboleto_sample.py 7 | include bin/html_pyboleto_sample.py 8 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | python-boleto - Fork mantido por Trustcode 3 | ======== 4 | 5 | .. image:: https://travis-ci.org/Trust-Code/python-boleto.svg?branch=master3 6 | :target: https://travis-ci.org/Trust-Code/python-boleto 7 | 8 | .. image:: https://coveralls.io/repos/github/Trust-Code/python-boleto/badge.svg?branch=master3 9 | :target: https://coveralls.io/github/Trust-Code/python-boleto?branch=master3 10 | 11 | .. image:: https://landscape.io/github/Trust-Code/python-boleto/master3/landscape.svg?style=flat 12 | :target: https://landscape.io/github/Trust-Code/python-boleto/master3 13 | :alt: Code Health 14 | 15 | .. image:: https://badge.fury.io/py/python3-boleto.svg 16 | :target: https://badge.fury.io/py/python3-boleto 17 | 18 | 19 | .. _pyboleto-synopsis: 20 | 21 | python-boleto é um projeto python para gerar boletos de cobrança. 22 | 23 | O projeto original pode ser encontrado aqui: 24 | https://github.com/eduardocereto/pyboleto 25 | 26 | 27 | .. contents:: 28 | :local: 29 | 30 | .. _pyboleto-implemented-bank: 31 | 32 | Bancos implementados 33 | ================= 34 | 35 | Você pode ajudar criando códigos para mais bancos ou imprimir e testar as implementações já existentes. 36 | 37 | Por enquanto, são essas que temos. 38 | 39 | +----------------------+----------------+-----------------+------------+ 40 | | **Banco** | **Carteira /** | **Implementado**| **Testado**| 41 | | | **Convenio** | | | 42 | +======================+================+=================+============+ 43 | | **Banco do Brasil** | 18 | Yes | Yes | 44 | +----------------------+----------------+-----------------+------------+ 45 | | **Banrisul** | x | Yes | Yes | 46 | +----------------------+----------------+-----------------+------------+ 47 | | **Bradesco** | 06, 03 | Yes | Yes | 48 | +----------------------+----------------+-----------------+------------+ 49 | | **Caixa Economica** | SR | Yes | No | 50 | +----------------------+----------------+-----------------+------------+ 51 | | **HSBC** | CNR, CSB | Yes | No | 52 | +----------------------+----------------+-----------------+------------+ 53 | | **Itau** | 157 | Yes | Yes | 54 | +----------------------+----------------+-----------------+------------+ 55 | | **Itau** | 175, 174, 178, | Yes | No | 56 | | | 104, 109 | | | 57 | +----------------------+----------------+-----------------+------------+ 58 | | **Santander** | 102 | Yes | Yes | 59 | +----------------------+----------------+-----------------+------------+ 60 | | **Santander** | 101, 201 | Yes | No | 61 | +----------------------+----------------+-----------------+------------+ 62 | | **Sicoob** | 1 | Yes | Yes | 63 | +----------------------+----------------+-----------------+------------+ 64 | | **Sicredi** | 1 | Yes | Yes | 65 | +----------------------+----------------+-----------------+------------+ 66 | | **Cecred** | 1 | Yes | Yes | 67 | +----------------------+----------------+-----------------+------------+ 68 | 69 | .. _pyboleto-docs: 70 | 71 | Documentation 72 | ============= 73 | 74 | 75 | .. _pyboleto-installation: 76 | 77 | Installation 78 | ============ 79 | 80 | Você pode instalar o pyboleto através do Python Package Index (PyPI) 81 | ou instalando diretamente da fonte. 82 | 83 | Para instalar usando o pip,:: 84 | 85 | $ pip3 install python3-boleto 86 | 87 | 88 | .. _pyboleto-installing-from-source: 89 | 90 | Baixando e instalando da fonte 91 | -------------------------------------- 92 | 93 | Baixe a última versão do pyboleto em 94 | http://pypi.python.org/pypi/python-boleto/ 95 | 96 | Você pode instalar utilizando os seguintes passos,:: 97 | 98 | $ tar xvfz python-boleto-0.0.0.tar.gz 99 | $ cd python-boleto-0.0.0 100 | $ python setup.py build 101 | # python setup.py install # as root 102 | 103 | .. _pyboleto-installing-from-hg: 104 | 105 | Utilizando a versão de desenvolvimento 106 | ----------------------------- 107 | 108 | Você pode clonar o repositório usando o seguinte comando:: 109 | 110 | $ git clone https://github.com/Trust-Code/python-boleto.git 111 | 112 | .. _pyboleto-unittests: 113 | 114 | Executando unittests 115 | =================== 116 | Você irá precisar do setuptools ou do distribute para executar os testes. Provavelmente já deve ter instalado um ou o outro. Irá precisar também do `pdftohtml`_.:: 117 | 118 | $ cd pyboleto 119 | $ python setup.py test 120 | 121 | 122 | .. _pdftohtml: http://poppler.freedesktop.org/ 123 | 124 | .. _pyboleto-license: 125 | 126 | License 127 | ======= 128 | 129 | Este software é licenciado sob a `New BSD License`. Veja o arquivo 130 | ``LICENSE`` na raiz do projeto para ler o texto completo. 131 | .. vim:tw=0:sw=4:et 132 | -------------------------------------------------------------------------------- /bin/html_pyboleto_sample.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import sys 4 | 5 | from pyboleto.bank.bancodobrasil import BoletoBB 6 | from pyboleto.bank.bradesco import BoletoBradesco 7 | from pyboleto.bank.caixa import BoletoCaixa 8 | from pyboleto.bank.itau import BoletoItau 9 | from pyboleto.bank.real import BoletoReal 10 | from pyboleto.bank.santander import BoletoSantander 11 | from pyboleto.html import BoletoHTML 12 | import datetime 13 | 14 | 15 | if sys.version_info < (3,): 16 | from pyboleto.pdf import BoletoPDF 17 | 18 | 19 | def get_data_bb(): 20 | listaDados = [] 21 | for i in range(2): 22 | d = BoletoBB(7, 2) 23 | d.nosso_numero = '87654' 24 | d.numero_documento = '27.030195.10' 25 | d.convenio = '7777777' 26 | d.especie_documento = 'DM' 27 | 28 | d.carteira = '18' 29 | d.cedente = 'Empresa ACME LTDA' 30 | d.cedente_documento = "102.323.777-01" 31 | d.cedente_endereco = "Rua Acme, 123 - Centro - Sao Paulo/SP - \ 32 | CEP: 12345-678" 33 | d.agencia_cedente = '9999' 34 | d.conta_cedente = '99999' 35 | 36 | d.data_vencimento = datetime.date(2010, 3, 27) 37 | d.data_documento = datetime.date(2010, 2, 12) 38 | d.data_processamento = datetime.date(2010, 2, 12) 39 | 40 | d.instrucoes = [ 41 | "- Linha 1", 42 | "- Sr Caixa, cobrar multa de 2% após o vencimento", 43 | "- Receber até 10 dias após o vencimento", 44 | ] 45 | d.demonstrativo = [ 46 | "- Serviço Teste R$ 5,00", 47 | "- Total R$ 5,00", 48 | ] 49 | d.valor_documento = 255.00 50 | 51 | d.sacado = [ 52 | "Cliente Teste %d" % (i + 1), 53 | "Rua Desconhecida, 00/0000 - Não Sei - Cidade - Cep. 00000-000", 54 | "" 55 | ] 56 | listaDados.append(d) 57 | return listaDados 58 | 59 | 60 | def get_data_real(): 61 | listaDados = [] 62 | for i in range(2): 63 | d = BoletoReal() 64 | d.carteira = '57' # Contrato firmado com o Banco Real 65 | d.cedente = 'Empresa ACME LTDA' 66 | d.cedente_documento = "102.323.777-01" 67 | d.cedente_endereco = "Rua Acme, 123 - Centro - Sao Paulo/SP - \ 68 | CEP: 12345-678" 69 | d.agencia_cedente = '0531' 70 | d.conta_cedente = '5705853' 71 | 72 | d.data_vencimento = datetime.date(2010, 3, 27) 73 | d.data_documento = datetime.date(2010, 2, 12) 74 | d.data_processamento = datetime.date(2010, 2, 12) 75 | 76 | d.instrucoes = [ 77 | "- Linha 1", 78 | "- Sr Caixa, cobrar multa de 2% após o vencimento", 79 | "- Receber até 10 dias após o vencimento", 80 | ] 81 | d.demonstrativo = [ 82 | "- Serviço Teste R$ 5,00", 83 | "- Total R$ 5,00", 84 | ] 85 | d.valor_documento = 5.00 86 | 87 | d.nosso_numero = "%d" % (i + 2) 88 | d.numero_documento = "%d" % (i + 2) 89 | d.sacado = [ 90 | "Cliente Teste %d" % (i + 1), 91 | "Rua Desconhecida, 00/0000 - Não Sei - Cidade - Cep. 00000-000", 92 | "" 93 | ] 94 | listaDados.append(d) 95 | return listaDados 96 | 97 | 98 | def get_data_bradesco(): 99 | listaDados = [] 100 | for i in range(2): 101 | d = BoletoBradesco() 102 | d.carteira = '06' # Contrato firmado com o Banco Bradesco 103 | d.cedente = 'Empresa ACME LTDA' 104 | d.cedente_documento = "102.323.777-01" 105 | d.cedente_endereco = "Rua Acme, 123 - Centro - Sao Paulo/SP - \ 106 | CEP: 12345-678" 107 | d.agencia_cedente = '0278-0' 108 | d.conta_cedente = '43905-3' 109 | 110 | d.data_vencimento = datetime.date(2011, 1, 25) 111 | d.data_documento = datetime.date(2010, 2, 12) 112 | d.data_processamento = datetime.date(2010, 2, 12) 113 | 114 | d.instrucoes = [ 115 | "- Linha 1", 116 | "- Sr Caixa, cobrar multa de 2% após o vencimento", 117 | "- Receber até 10 dias após o vencimento", 118 | ] 119 | d.demonstrativo = [ 120 | "- Serviço Teste R$ 5,00", 121 | "- Total R$ 5,00", 122 | ] 123 | d.valor_documento = 2158.41 124 | 125 | d.nosso_numero = "1112011668" 126 | d.numero_documento = "1112011668" 127 | d.sacado = [ 128 | "Cliente Teste %d" % (i + 1), 129 | "Rua Desconhecida, 00/0000 - Não Sei - Cidade - \ 130 | Cep. 00000-000", 131 | "" 132 | ] 133 | listaDados.append(d) 134 | return listaDados 135 | 136 | 137 | def get_data_santander(): 138 | listaDados = [] 139 | for i in range(2): 140 | d = BoletoSantander() 141 | d.agencia_cedente = '1333' 142 | d.conta_cedente = '0707077' 143 | d.data_vencimento = datetime.date(2012, 7, 22) 144 | d.data_documento = datetime.date(2012, 7, 17) 145 | d.data_processamento = datetime.date(2012, 7, 17) 146 | d.valor_documento = 2952.95 147 | d.nosso_numero = '1234567' 148 | d.numero_documento = '12345' 149 | d.ios = '0' 150 | 151 | d.cedente = 'Empresa ACME LTDA' 152 | d.cedente_documento = "102.323.777-01" 153 | d.cedente_endereco = "Rua Acme, 123 - Centro - Sao Paulo/SP - \ 154 | CEP: 12345-678" 155 | 156 | d.instrucoes = [ 157 | "- Linha 1", 158 | "- Sr Caixa, cobrar multa de 2% após o vencimento", 159 | "- Receber até 10 dias após o vencimento", 160 | ] 161 | d.demonstrativo = [ 162 | "- Serviço Teste R$ 5,00", 163 | "- Total R$ 5,00", 164 | ] 165 | d.valor_documento = 255.00 166 | 167 | d.sacado = [ 168 | "Cliente Teste %d" % (i + 1), 169 | "Rua Desconhecida, 00/0000 - Não Sei - Cidade - Cep. 00000-000", 170 | "" 171 | ] 172 | listaDados.append(d) 173 | return listaDados 174 | 175 | 176 | def get_data_caixa(): 177 | listaDados = [] 178 | for i in range(2): 179 | d = BoletoCaixa() 180 | d.carteira = 'SR' # Contrato firmado com o Banco Bradesco 181 | d.cedente = 'Empresa ACME LTDA' 182 | d.cedente_documento = "102.323.777-01" 183 | d.cedente_endereco = "Rua Acme, 123 - Centro - Sao Paulo/SP - \ 184 | CEP: 12345-678" 185 | d.agencia_cedente = '1565' 186 | d.conta_cedente = '414-3' 187 | 188 | d.data_vencimento = datetime.date(2010, 3, 27) 189 | d.data_documento = datetime.date(2010, 2, 12) 190 | d.data_processamento = datetime.date(2010, 2, 12) 191 | 192 | d.instrucoes = [ 193 | "- Linha 1", 194 | "- Sr Caixa, cobrar multa de 2% após o vencimento", 195 | "- Receber até 10 dias após o vencimento", 196 | ] 197 | d.demonstrativo = [ 198 | "- Serviço Teste R$ 5,00", 199 | "- Total R$ 5,00", 200 | ] 201 | d.valor_documento = 255.00 202 | 203 | d.nosso_numero = "8019525086" 204 | d.numero_documento = "8019525086" 205 | d.sacado = [ 206 | "Cliente Teste %d" % (i + 1), 207 | "Rua Desconhecida, 00/0000 - Não Sei - Cidade - Cep. 00000-000", 208 | "" 209 | ] 210 | listaDados.append(d) 211 | return listaDados 212 | 213 | 214 | def get_data_itau(): 215 | listaDados = [] 216 | for i in range(2): 217 | d = BoletoItau() 218 | d.nosso_numero = '87654' 219 | d.numero_documento = '27.030195.10' 220 | 221 | d.carteira = '18' 222 | d.cedente = 'Empresa ACME LTDA' 223 | d.cedente_documento = "102.323.777-01" 224 | d.cedente_endereco = "Rua Acme, 123 - Centro - Sao Paulo/SP - \ 225 | CEP: 12345-678" 226 | d.agencia_cedente = '9999' 227 | d.conta_cedente = '99999' 228 | 229 | d.data_vencimento = datetime.date(2010, 3, 27) 230 | d.data_documento = datetime.date(2010, 2, 12) 231 | d.data_processamento = datetime.date(2010, 2, 12) 232 | 233 | d.instrucoes = [ 234 | "- Linha 1", 235 | "- Sr Caixa, cobrar multa de 2% após o vencimento", 236 | "- Receber até 10 dias após o vencimento", 237 | ] 238 | d.demonstrativo = [ 239 | "- Serviço Teste R$ 5,00", 240 | "- Total R$ 5,00", 241 | ] 242 | d.valor_documento = 255.00 243 | 244 | d.sacado = [ 245 | "Cliente Teste %d" % (i + 1), 246 | "Rua Desconhecida, 00/0000 - Não Sei - Cidade - Cep. 00000-000", 247 | "" 248 | ] 249 | listaDados.append(d) 250 | return listaDados 251 | 252 | 253 | def print_all(): 254 | banks = { 255 | # "itau": "Itau", 256 | "bb": "Banco do Brasil", 257 | "caixa": "Caixa", 258 | "real": "Real", 259 | "santander": "Santander", 260 | "bradesco": "Bradesco", 261 | } 262 | for bank in banks: 263 | print("Gerando boleto para o banco " + banks[bank]) 264 | data_func_name = "get_data_" + bank 265 | data_func = eval(data_func_name) 266 | boleto_datas = data_func() 267 | if sys.version_info < (3,): 268 | boleto_PDF = BoletoPDF('boleto-' + bank + '-normal-teste.pdf') 269 | boleto_HTML = BoletoHTML('boleto-' + bank + '-normal-teste.html') 270 | for boleto_data in boleto_datas: 271 | if sys.version_info < (3,): 272 | boleto_PDF.drawBoleto(boleto_data) 273 | boleto_PDF.nextPage() 274 | boleto_PDF.save() 275 | boleto_HTML.drawBoleto(boleto_data) 276 | boleto_HTML.nextPage() 277 | boleto_HTML.save() 278 | 279 | 280 | if __name__ == "__main__": 281 | print_all() 282 | -------------------------------------------------------------------------------- /bin/pdf_pyboleto_in_memory_sample.py: -------------------------------------------------------------------------------- 1 | import pyboleto 2 | from pyboleto.bank.sicredi import BoletoSicredi 3 | from pyboleto.pdf import BoletoPDF 4 | import datetime 5 | 6 | d = BoletoSicredi() 7 | d.aceite = 'Sim' 8 | d.especie_documento = 'DI' 9 | d.carteira = '1' 10 | d.posto = '08' 11 | 12 | d.cedente = 'Empresa ACME LTDA' 13 | d.cedente_documento = "102.323.777-01" 14 | d.cedente_endereco = ("Rua Acme, 123 - " + 15 | "Centro - Sao Paulo/SP - " + 16 | "CEP: 12345-678") 17 | d.agencia_cedente = '9999' 18 | d.conta_cedente = '99999' 19 | 20 | # buscar dados do wk 21 | d.data_vencimento = datetime.date(2018, 1, 25) 22 | d.data_documento = datetime.date(2017, 11, 24) 23 | d.data_processamento = datetime.date(2017, 11, 24) 24 | d.valor_documento = 90.75 25 | d.nosso_numero = '18324121' 26 | d.numero_documento = '33287-1/12' 27 | 28 | d.instrucoes = [ 29 | "- Linha 1", 30 | "- Sr Caixa, cobrar multa de 2% apos o vencimento", 31 | "- Receber ate 10 dias apos o vencimento", 32 | ] 33 | 34 | d.demonstrativo = [ 35 | "- Servico Teste R$ 5,00", 36 | "- Total R$ 5,00", 37 | ] 38 | 39 | d.valor_documento = 255.00 40 | 41 | d.sacado = [ 42 | "Cliente Teste", 43 | "Rua Desconhecida, 00/0000 - Nao Sei - Cidade - Cep. 00000-000", 44 | "" 45 | ] 46 | 47 | import io 48 | buf = io.BytesIO() 49 | 50 | boleto = BoletoPDF(buf) 51 | boleto.drawBoleto(d) 52 | boleto.nextPage() 53 | boleto.save() 54 | 55 | pdf_buffer = buf.getbuffer() 56 | file = open("boleto_buffer.pdf", "wb") 57 | file.write(pdf_buffer) 58 | 59 | -------------------------------------------------------------------------------- /bin/pdf_pyboleto_sample.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import pyboleto 4 | from pyboleto.bank.real import BoletoReal 5 | from pyboleto.bank.bradesco import BoletoBradesco 6 | from pyboleto.bank.caixa import BoletoCaixa 7 | from pyboleto.bank.bancodobrasil import BoletoBB 8 | from pyboleto.bank.santander import BoletoSantander 9 | from pyboleto.pdf import BoletoPDF 10 | import datetime 11 | 12 | 13 | def print_bb(): 14 | listaDados = [] 15 | for i in range(2): 16 | d = BoletoBB(7, 2) 17 | d.nosso_numero = '87654' 18 | d.numero_documento = '27.030195.10' 19 | d.convenio = '7777777' 20 | d.especie_documento = 'DM' 21 | 22 | d.carteira = '18' 23 | d.cedente = 'Empresa ACME LTDA' 24 | d.cedente_documento = "102.323.777-01" 25 | d.cedente_endereco = ("Rua Acme, 123 - " + 26 | "Centro - Sao Paulo/SP - " + 27 | "CEP: 12345-678") 28 | d.agencia_cedente = '9999' 29 | d.conta_cedente = '99999' 30 | 31 | d.data_vencimento = datetime.date(2010, 3, 27) 32 | d.data_documento = datetime.date(2010, 2, 12) 33 | d.data_processamento = datetime.date(2010, 2, 12) 34 | 35 | d.instrucoes = [ 36 | "- Linha 1", 37 | "- Sr Caixa, cobrar multa de 2% após o vencimento", 38 | "- Receber até 10 dias após o vencimento", 39 | ] 40 | d.demonstrativo = [ 41 | "- Serviço Teste R$ 5,00", 42 | "- Total R$ 5,00", 43 | ] 44 | d.valor_documento = 255.00 45 | 46 | d.sacado = [ 47 | "Cliente Teste %d" % (i + 1), 48 | "Rua Desconhecida, 00/0000 - Não Sei - Cidade - Cep. 00000-000", 49 | "" 50 | ] 51 | listaDados.append(d) 52 | 53 | boleto = BoletoPDF('boleto-bb-formato-normal-teste.pdf') 54 | for i in range(len(listaDados)): 55 | boleto.drawBoleto(listaDados[i]) 56 | boleto.nextPage() 57 | boleto.save() 58 | 59 | 60 | def print_real(): 61 | listaDadosReal = [] 62 | for i in range(2): 63 | d = BoletoReal() 64 | d.carteira = '57' # Contrato firmado com o Banco Real 65 | d.cedente = 'Empresa ACME LTDA' 66 | d.cedente_documento = "102.323.777-01" 67 | d.cedente_endereco = ("Rua Acme, 123 - Centro - Sao Paulo/SP - " + 68 | "CEP: 12345-678") 69 | d.agencia_cedente = '0531' 70 | d.conta_cedente = '5705853' 71 | 72 | d.data_vencimento = datetime.date(2010, 3, 27) 73 | d.data_documento = datetime.date(2010, 2, 12) 74 | d.data_processamento = datetime.date(2010, 2, 12) 75 | 76 | d.instrucoes = [ 77 | "- Linha 1", 78 | "- Sr Caixa, cobrar multa de 2% após o vencimento", 79 | "- Receber até 10 dias após o vencimento", 80 | ] 81 | d.demonstrativo = [ 82 | "- Serviço Teste R$ 5,00", 83 | "- Total R$ 5,00", 84 | ] 85 | d.valor_documento = 5.00 86 | 87 | d.nosso_numero = "%d" % (i + 2) 88 | d.numero_documento = "%d" % (i + 2) 89 | d.sacado = [ 90 | "Cliente Teste %d" % (i + 1), 91 | "Rua Desconhecida, 00/0000 - Não Sei - Cidade - Cep. 00000-000", 92 | "" 93 | ] 94 | listaDadosReal.append(d) 95 | 96 | # Real Formato normal - uma pagina por folha A4 97 | boleto = BoletoPDF('boleto-real-formato-normal-teste.pdf') 98 | for i in range(len(listaDadosReal)): 99 | boleto.drawBoleto(listaDadosReal[i]) 100 | boleto.nextPage() 101 | boleto.save() 102 | 103 | 104 | def print_bradesco(): 105 | listaDadosBradesco = [] 106 | for i in range(2): 107 | d = BoletoBradesco() 108 | d.carteira = '06' # Contrato firmado com o Banco Bradesco 109 | d.cedente = 'Empresa ACME LTDA' 110 | d.cedente_documento = "102.323.777-01" 111 | d.cedente_endereco = ("Rua Acme, 123 - Centro - Sao Paulo/SP - " + 112 | "CEP: 12345-678") 113 | d.agencia_cedente = '0278-0' 114 | d.conta_cedente = '43905-3' 115 | 116 | d.data_vencimento = datetime.date(2011, 1, 25) 117 | d.data_documento = datetime.date(2010, 2, 12) 118 | d.data_processamento = datetime.date(2010, 2, 12) 119 | 120 | d.instrucoes = [ 121 | "- Linha 1", 122 | "- Sr Caixa, cobrar multa de 2% após o vencimento", 123 | "- Receber até 10 dias após o vencimento", 124 | ] 125 | d.demonstrativo = [ 126 | "- Serviço Teste R$ 5,00", 127 | "- Total R$ 5,00", 128 | ] 129 | d.valor_documento = 2158.41 130 | 131 | d.nosso_numero = "1112011668" 132 | d.numero_documento = "1112011668" 133 | d.sacado = [ 134 | "Cliente Teste %d" % (i + 1), 135 | "Rua Desconhecida, 00/0000 - Não Sei - Cidade - Cep. 00000-000", 136 | "" 137 | ] 138 | listaDadosBradesco.append(d) 139 | 140 | # Bradesco Formato carne - duas paginas por folha A4 141 | boleto = BoletoPDF('boleto-bradesco-formato-carne-teste.pdf', True) 142 | for i in range(0, len(listaDadosBradesco), 2): 143 | boleto.drawBoletoCarneDuplo( 144 | listaDadosBradesco[i], 145 | listaDadosBradesco[i + 1] 146 | ) 147 | boleto.nextPage() 148 | boleto.save() 149 | 150 | # Bradesco Formato normal - uma pagina por folha A4 151 | boleto = BoletoPDF('boleto-bradesco-formato-normal-teste.pdf') 152 | for i in range(len(listaDadosBradesco)): 153 | boleto.drawBoleto(listaDadosBradesco[i]) 154 | boleto.nextPage() 155 | boleto.save() 156 | 157 | 158 | def print_santander(): 159 | listaDadosSantander = [] 160 | for i in range(2): 161 | d = BoletoSantander() 162 | d.agencia_cedente = '1333' 163 | d.conta_cedente = '0707077' 164 | d.data_vencimento = datetime.date(2012, 7, 22) 165 | d.data_documento = datetime.date(2012, 7, 17) 166 | d.data_processamento = datetime.date(2012, 7, 17) 167 | d.valor_documento = 2952.95 168 | d.nosso_numero = '1234567' 169 | d.numero_documento = '12345' 170 | d.ios = '0' 171 | 172 | d.cedente = 'Empresa ACME LTDA' 173 | d.cedente_documento = "102.323.777-01" 174 | d.cedente_endereco = ("Rua Acme, 123 - Centro - Sao Paulo/SP - " + 175 | "CEP: 12345-678") 176 | 177 | d.instrucoes = [ 178 | "- Linha 1", 179 | "- Sr Caixa, cobrar multa de 2% após o vencimento", 180 | "- Receber até 10 dias após o vencimento", 181 | ] 182 | d.demonstrativo = [ 183 | "- Serviço Teste R$ 5,00", 184 | "- Total R$ 5,00", 185 | ] 186 | d.valor_documento = 255.00 187 | 188 | d.sacado = [ 189 | "Cliente Teste %d" % (i + 1), 190 | "Rua Desconhecida, 00/0000 - Não Sei - Cidade - Cep. 00000-000", 191 | "" 192 | ] 193 | listaDadosSantander.append(d) 194 | 195 | # Caixa Formato normal - uma pagina por folha A4 196 | boleto = BoletoPDF('boleto-santander-formato-normal-teste.pdf') 197 | for i in range(len(listaDadosSantander)): 198 | boleto.drawBoleto(listaDadosSantander[i]) 199 | boleto.nextPage() 200 | boleto.save() 201 | 202 | 203 | def print_caixa(): 204 | listaDadosCaixa = [] 205 | for i in range(2): 206 | d = BoletoCaixa() 207 | d.carteira = 'SR' # Contrato firmado com o Banco Bradesco 208 | d.cedente = 'Empresa ACME LTDA' 209 | d.cedente_documento = "102.323.777-01" 210 | d.cedente_endereco = ("Rua Acme, 123 - Centro - Sao Paulo/SP - " + 211 | "CEP: 12345-678") 212 | d.agencia_cedente = '1565' 213 | d.conta_cedente = '414-3' 214 | 215 | d.data_vencimento = datetime.date(2010, 3, 27) 216 | d.data_documento = datetime.date(2010, 2, 12) 217 | d.data_processamento = datetime.date(2010, 2, 12) 218 | 219 | d.instrucoes = [ 220 | "- Linha 1", 221 | "- Sr Caixa, cobrar multa de 2% após o vencimento", 222 | "- Receber até 10 dias após o vencimento", 223 | ] 224 | d.demonstrativo = [ 225 | "- Serviço Teste R$ 5,00", 226 | "- Total R$ 5,00", 227 | ] 228 | d.valor_documento = 255.00 229 | 230 | d.nosso_numero = "8019525086" 231 | d.numero_documento = "8019525086" 232 | d.sacado = [ 233 | "Cliente Teste %d" % (i + 1), 234 | "Rua Desconhecida, 00/0000 - Não Sei - Cidade - Cep. 00000-000", 235 | "" 236 | ] 237 | listaDadosCaixa.append(d) 238 | 239 | # Caixa Formato normal - uma pagina por folha A4 240 | boleto = BoletoPDF('boleto-caixa-formato-carne-teste.pdf', True) 241 | for i in range(0, len(listaDadosCaixa), 2): 242 | boleto.drawBoletoCarneDuplo( 243 | listaDadosCaixa[i], 244 | listaDadosCaixa[i + 1] 245 | ) 246 | boleto.nextPage() 247 | boleto.save() 248 | 249 | # Caixa Formato normal - uma pagina por folha A4 250 | boleto = BoletoPDF('boleto-caixa-formato-normal-teste.pdf') 251 | for i in range(len(listaDadosCaixa)): 252 | boleto.drawBoleto(listaDadosCaixa[i]) 253 | boleto.nextPage() 254 | boleto.save() 255 | 256 | 257 | def print_itau(): 258 | pass 259 | 260 | 261 | def print_all(): 262 | print("Pyboleto version: %s" % pyboleto.__version__) 263 | print("----------------------------------") 264 | print(" Printing Example Boletos ") 265 | print("----------------------------------") 266 | 267 | print("Banco do Brasil") 268 | print_bb() 269 | 270 | print("Bradesco") 271 | print_bradesco() 272 | 273 | # print "Itau" 274 | # print_itau() 275 | 276 | print("Caixa") 277 | print_caixa() 278 | 279 | print("Real") 280 | print_real() 281 | 282 | print("Santander") 283 | print_santander() 284 | 285 | print("----------------------------------") 286 | print("Ok") 287 | 288 | 289 | if __name__ == "__main__": 290 | print_all() 291 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | # the i18n builder cannot share the environment and doctrees with the others 15 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 16 | 17 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 18 | 19 | help: 20 | @echo "Please use \`make ' where is one of" 21 | @echo " html to make standalone HTML files" 22 | @echo " dirhtml to make HTML files named index.html in directories" 23 | @echo " singlehtml to make a single large HTML file" 24 | @echo " pickle to make pickle files" 25 | @echo " json to make JSON files" 26 | @echo " htmlhelp to make HTML files and a HTML help project" 27 | @echo " qthelp to make HTML files and a qthelp project" 28 | @echo " devhelp to make HTML files and a Devhelp project" 29 | @echo " epub to make an epub" 30 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 31 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 32 | @echo " text to make text files" 33 | @echo " man to make manual pages" 34 | @echo " texinfo to make Texinfo files" 35 | @echo " info to make Texinfo files and run them through makeinfo" 36 | @echo " gettext to make PO message catalogs" 37 | @echo " changes to make an overview of all changed/added/deprecated items" 38 | @echo " linkcheck to check all external links for integrity" 39 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 40 | 41 | clean: 42 | -rm -rf $(BUILDDIR)/* 43 | 44 | html: 45 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 48 | 49 | dirhtml: 50 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 51 | @echo 52 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 53 | 54 | singlehtml: 55 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 56 | @echo 57 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 58 | 59 | pickle: 60 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 61 | @echo 62 | @echo "Build finished; now you can process the pickle files." 63 | 64 | json: 65 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 66 | @echo 67 | @echo "Build finished; now you can process the JSON files." 68 | 69 | htmlhelp: 70 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 71 | @echo 72 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 73 | ".hhp project file in $(BUILDDIR)/htmlhelp." 74 | 75 | qthelp: 76 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 77 | @echo 78 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 79 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 80 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/pyboleto.qhcp" 81 | @echo "To view the help file:" 82 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/pyboleto.qhc" 83 | 84 | devhelp: 85 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 86 | @echo 87 | @echo "Build finished." 88 | @echo "To view the help file:" 89 | @echo "# mkdir -p $$HOME/.local/share/devhelp/pyboleto" 90 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/pyboleto" 91 | @echo "# devhelp" 92 | 93 | epub: 94 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 95 | @echo 96 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 97 | 98 | latex: 99 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 100 | @echo 101 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 102 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 103 | "(use \`make latexpdf' here to do that automatically)." 104 | 105 | latexpdf: 106 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 107 | @echo "Running LaTeX files through pdflatex..." 108 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 109 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 110 | 111 | text: 112 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 113 | @echo 114 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 115 | 116 | man: 117 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 118 | @echo 119 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 120 | 121 | texinfo: 122 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 123 | @echo 124 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 125 | @echo "Run \`make' in that directory to run these through makeinfo" \ 126 | "(use \`make info' here to do that automatically)." 127 | 128 | info: 129 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 130 | @echo "Running Texinfo files through makeinfo..." 131 | make -C $(BUILDDIR)/texinfo info 132 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 133 | 134 | gettext: 135 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 136 | @echo 137 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 138 | 139 | changes: 140 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 141 | @echo 142 | @echo "The overview file is in $(BUILDDIR)/changes." 143 | 144 | linkcheck: 145 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 146 | @echo 147 | @echo "Link check complete; look for any errors in the above output " \ 148 | "or in $(BUILDDIR)/linkcheck/output.txt." 149 | 150 | doctest: 151 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 152 | @echo "Testing of doctests in the sources finished, look at the " \ 153 | "results in $(BUILDDIR)/doctest/output.txt." 154 | -------------------------------------------------------------------------------- /docs/_static/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /docs/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "!layout.html" %} 2 | 3 | {%- block extrahead %} 4 | {{ super() }} 5 | 18 | {% endblock %} 19 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # pyboleto documentation build configuration file, created by 4 | # sphinx-quickstart on Thu Jul 5 02:10:50 2012. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys 15 | import os 16 | 17 | # from django.conf import settings 18 | # settings.configure() 19 | 20 | # If extensions (or modules to document with autodoc) are in another directory, 21 | # add these directories to sys.path here. If the directory is relative to the 22 | # documentation root, use os.path.abspath to make it absolute, like shown here. 23 | sys.path.insert(0, os.path.abspath('../')) 24 | 25 | # import pyboleto 26 | 27 | # -- General configuration ---------------------------------------------------- 28 | 29 | # If your documentation needs a minimal Sphinx version, state it here. 30 | # needs_sphinx = '1.0' 31 | 32 | # Add any Sphinx extension module names here, as strings. They can be extension 33 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 34 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage', 35 | 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', 36 | ] 37 | 38 | # Add any paths that contain templates here, relative to this directory. 39 | templates_path = ['_templates'] 40 | 41 | # The suffix of source filenames. 42 | source_suffix = '.rst' 43 | 44 | # The encoding of source files. 45 | # source_encoding = 'utf-8-sig' 46 | 47 | # The master toctree document. 48 | master_doc = 'index' 49 | 50 | # General information about the project. 51 | project = u'pyboleto' 52 | copyright = u'2012-2016, Eduardo Cereto Carvalho' 53 | 54 | # The version info for the project you're documenting, acts as replacement for 55 | # |version| and |release|, also used in various other places throughout the 56 | # built documents. 57 | # 58 | # The short X.Y version. 59 | version = __import__('pyboleto').__version__ 60 | # The full version, including alpha/beta/rc tags. 61 | release = __import__('pyboleto').__version__ 62 | 63 | # The language for content autogenerated by Sphinx. Refer to documentation 64 | # for a list of supported languages. 65 | language = 'pt_BR' 66 | 67 | # There are two options for replacing |today|: either, you set today to some 68 | # non-false value, then it is used: 69 | # today = '' 70 | # Else, today_fmt is used as the format for a strftime call. 71 | # today_fmt = '%B %d, %Y' 72 | 73 | # List of patterns, relative to source directory, that match files and 74 | # directories to ignore when looking for source files. 75 | exclude_patterns = ['_build'] 76 | 77 | # The reST default role (used for this markup: `text`) to use for all documents 78 | # default_role = None 79 | 80 | # If true, '()' will be appended to :func: etc. cross-reference text. 81 | # add_function_parentheses = True 82 | 83 | # If true, the current module name will be prepended to all description 84 | # unit titles (such as .. function::). 85 | # add_module_names = True 86 | 87 | # If true, sectionauthor and moduleauthor directives will be shown in the 88 | # output. They are ignored by default. 89 | # show_authors = False 90 | 91 | # The name of the Pygments (syntax highlighting) style to use. 92 | pygments_style = 'tango' 93 | 94 | # A list of ignored prefixes for module index sorting. 95 | # modindex_common_prefix = [] 96 | 97 | 98 | # -- Options for HTML output -------------------------------------------------- 99 | 100 | # The theme to use for HTML and HTML Help pages. See the documentation for 101 | # a list of builtin themes. 102 | html_theme = 'default' 103 | 104 | # Theme options are theme-specific and customize the look and feel of a theme 105 | # further. For a list of options available for each theme, see the 106 | # documentation. 107 | html_theme_options = { 108 | 'collapsiblesidebar': True, 109 | } 110 | 111 | # Add any paths that contain custom themes here, relative to this directory. 112 | # html_theme_path = [] 113 | 114 | # The name for this set of Sphinx documents. If None, it defaults to 115 | # " v documentation". 116 | # html_title = None 117 | 118 | # A shorter title for the navigation bar. Default is the same as html_title. 119 | # html_short_title = None 120 | 121 | # The name of an image file (relative to this directory) to place at the top 122 | # of the sidebar. 123 | # html_logo = None 124 | 125 | # The name of an image file (within the static path) to use as favicon of the 126 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 127 | # pixels large. 128 | # html_favicon = None 129 | 130 | # Add any paths that contain custom static files (such as style sheets) here, 131 | # relative to this directory. They are copied after the builtin static files, 132 | # so a file named "default.css" will overwrite the builtin "default.css". 133 | html_static_path = ['_static'] 134 | 135 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 136 | # using the given strftime format. 137 | # html_last_updated_fmt = '%b %d, %Y' 138 | 139 | # If true, SmartyPants will be used to convert quotes and dashes to 140 | # typographically correct entities. 141 | # html_use_smartypants = True 142 | 143 | # Custom sidebar templates, maps document names to template names. 144 | # html_sidebars = {} 145 | 146 | # Additional templates that should be rendered to pages, maps page names to 147 | # template names. 148 | # html_additional_pages = {} 149 | 150 | # If false, no module index is generated. 151 | # html_domain_indices = True 152 | 153 | # If false, no index is generated. 154 | # html_use_index = True 155 | 156 | # If true, the index is split into individual pages for each letter. 157 | # html_split_index = False 158 | 159 | # If true, links to the reST sources are added to the pages. 160 | # html_show_sourcelink = True 161 | 162 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 163 | # html_show_sphinx = True 164 | 165 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 166 | # html_show_copyright = True 167 | 168 | # If true, an OpenSearch description file will be output, and all pages will 169 | # contain a tag referring to it. The value of this option must be the 170 | # base URL from which the finished HTML is served. 171 | # html_use_opensearch = '' 172 | 173 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 174 | # html_file_suffix = None 175 | 176 | # Output file base name for HTML help builder. 177 | htmlhelp_basename = 'pyboletodoc' 178 | 179 | 180 | # -- Options for LaTeX output ------------------------------------------------- 181 | 182 | latex_elements = { 183 | # The paper size ('letterpaper' or 'a4paper'). 184 | 'papersize': 'a4paper', 185 | 186 | # The font size ('10pt', '11pt' or '12pt'). 187 | # 'pointsize': '10pt', 188 | 189 | # Additional stuff for the LaTeX preamble. 190 | # 'preamble': '', 191 | } 192 | 193 | # Grouping the document tree into LaTeX files. List of tuples 194 | # (source start file, target name, title, author, documentclass [howto/manual]) 195 | latex_documents = [ 196 | ('index', 'pyboleto.tex', u'Documentação pyboleto', 197 | u'Eduardo Cereto Carvalho', 'manual'), 198 | ] 199 | 200 | # The name of an image file (relative to this directory) to place at the top of 201 | # the title page. 202 | # latex_logo = None 203 | 204 | # For "manual" documents, if this is true, then toplevel headings are parts, 205 | # not chapters. 206 | # latex_use_parts = False 207 | 208 | # If true, show page references after internal links. 209 | # latex_show_pagerefs = False 210 | 211 | # If true, show URL addresses after external links. 212 | # latex_show_urls = False 213 | 214 | # Documents to append as an appendix to all manuals. 215 | # latex_appendices = [] 216 | 217 | # If false, no module index is generated. 218 | latex_domain_indices = False 219 | 220 | 221 | # -- Options for manual page output ------------------------------------------- 222 | 223 | # One entry per manual page. List of tuples 224 | # (source start file, name, description, authors, manual section). 225 | man_pages = [ 226 | ('index', 'pyboleto', u'pyboleto Documentation', 227 | [u'Eduardo Cereto Carvalho'], 1) 228 | ] 229 | 230 | # If true, show URL addresses after external links. 231 | # man_show_urls = False 232 | 233 | 234 | # -- Options for Texinfo output ----------------------------------------------- 235 | 236 | # Grouping the document tree into Texinfo files. List of tuples 237 | # (source start file, target name, title, author, 238 | # dir menu entry, description, category) 239 | texinfo_documents = [ 240 | ('index', 241 | 'pyboleto', u'pyboleto Documentation', 242 | u'Eduardo Cereto Carvalho', 243 | 'pyboleto', 244 | u'Biblioteca para geração de boletos bancários', 245 | 'Miscellaneous'), 246 | ] 247 | 248 | # Documents to append as an appendix to all manuals. 249 | # texinfo_appendices = [] 250 | 251 | # If false, no module index is generated. 252 | # texinfo_domain_indices = True 253 | 254 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 255 | # texinfo_show_urls = 'footnote' 256 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. pyboleto documentation master file, created by 2 | sphinx-quickstart on Thu Jul 5 02:10:50 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Bem vindo a documentação do pyboleto! 7 | ===================================== 8 | 9 | Conteúdo: 10 | 11 | .. toctree:: 12 | :maxdepth: 4 13 | 14 | pyboleto 15 | 16 | 17 | 18 | Índices e tabelas 19 | ================= 20 | 21 | * :ref:`genindex` 22 | * :ref:`modindex` 23 | * :ref:`search` 24 | 25 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. linkcheck to check all external links for integrity 37 | echo. doctest to run all doctests embedded in the documentation if enabled 38 | goto end 39 | ) 40 | 41 | if "%1" == "clean" ( 42 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 43 | del /q /s %BUILDDIR%\* 44 | goto end 45 | ) 46 | 47 | if "%1" == "html" ( 48 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 49 | if errorlevel 1 exit /b 1 50 | echo. 51 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 52 | goto end 53 | ) 54 | 55 | if "%1" == "dirhtml" ( 56 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 57 | if errorlevel 1 exit /b 1 58 | echo. 59 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 60 | goto end 61 | ) 62 | 63 | if "%1" == "singlehtml" ( 64 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 68 | goto end 69 | ) 70 | 71 | if "%1" == "pickle" ( 72 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished; now you can process the pickle files. 76 | goto end 77 | ) 78 | 79 | if "%1" == "json" ( 80 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished; now you can process the JSON files. 84 | goto end 85 | ) 86 | 87 | if "%1" == "htmlhelp" ( 88 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can run HTML Help Workshop with the ^ 92 | .hhp project file in %BUILDDIR%/htmlhelp. 93 | goto end 94 | ) 95 | 96 | if "%1" == "qthelp" ( 97 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 98 | if errorlevel 1 exit /b 1 99 | echo. 100 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 101 | .qhcp project file in %BUILDDIR%/qthelp, like this: 102 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\pyboleto.qhcp 103 | echo.To view the help file: 104 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\pyboleto.ghc 105 | goto end 106 | ) 107 | 108 | if "%1" == "devhelp" ( 109 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 110 | if errorlevel 1 exit /b 1 111 | echo. 112 | echo.Build finished. 113 | goto end 114 | ) 115 | 116 | if "%1" == "epub" ( 117 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 118 | if errorlevel 1 exit /b 1 119 | echo. 120 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 121 | goto end 122 | ) 123 | 124 | if "%1" == "latex" ( 125 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 129 | goto end 130 | ) 131 | 132 | if "%1" == "text" ( 133 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The text files are in %BUILDDIR%/text. 137 | goto end 138 | ) 139 | 140 | if "%1" == "man" ( 141 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 145 | goto end 146 | ) 147 | 148 | if "%1" == "texinfo" ( 149 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 150 | if errorlevel 1 exit /b 1 151 | echo. 152 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 153 | goto end 154 | ) 155 | 156 | if "%1" == "gettext" ( 157 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 158 | if errorlevel 1 exit /b 1 159 | echo. 160 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 161 | goto end 162 | ) 163 | 164 | if "%1" == "changes" ( 165 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 166 | if errorlevel 1 exit /b 1 167 | echo. 168 | echo.The overview file is in %BUILDDIR%/changes. 169 | goto end 170 | ) 171 | 172 | if "%1" == "linkcheck" ( 173 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 174 | if errorlevel 1 exit /b 1 175 | echo. 176 | echo.Link check complete; look for any errors in the above output ^ 177 | or in %BUILDDIR%/linkcheck/output.txt. 178 | goto end 179 | ) 180 | 181 | if "%1" == "doctest" ( 182 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 183 | if errorlevel 1 exit /b 1 184 | echo. 185 | echo.Testing of doctests in the sources finished, look at the ^ 186 | results in %BUILDDIR%/doctest/output.txt. 187 | goto end 188 | ) 189 | 190 | :end 191 | -------------------------------------------------------------------------------- /docs/modules.rst: -------------------------------------------------------------------------------- 1 | pyboleto 2 | ======== 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | pyboleto 8 | -------------------------------------------------------------------------------- /docs/pyboleto.bank.rst: -------------------------------------------------------------------------------- 1 | bank Package 2 | ============ 3 | 4 | :mod:`bank` Package 5 | ------------------- 6 | 7 | .. automodule:: pyboleto.bank 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | 12 | :mod:`bancodobrasil` Module 13 | --------------------------- 14 | 15 | .. automodule:: pyboleto.bank.bancodobrasil 16 | :members: 17 | :undoc-members: 18 | :show-inheritance: 19 | 20 | :mod:`banrisul` Module 21 | ---------------------- 22 | 23 | .. automodule:: pyboleto.bank.banrisul 24 | :members: 25 | :undoc-members: 26 | :show-inheritance: 27 | 28 | :mod:`bradesco` Module 29 | ---------------------- 30 | 31 | .. automodule:: pyboleto.bank.bradesco 32 | :members: 33 | :undoc-members: 34 | :show-inheritance: 35 | 36 | :mod:`caixa` Module 37 | ------------------- 38 | 39 | .. automodule:: pyboleto.bank.caixa 40 | :members: 41 | :undoc-members: 42 | :show-inheritance: 43 | 44 | :mod:`hsbc` Module 45 | ------------------ 46 | 47 | .. automodule:: pyboleto.bank.hsbc 48 | :members: 49 | :undoc-members: 50 | :show-inheritance: 51 | 52 | :mod:`itau` Module 53 | ------------------ 54 | 55 | .. automodule:: pyboleto.bank.itau 56 | :members: 57 | :undoc-members: 58 | :show-inheritance: 59 | 60 | :mod:`real` Module 61 | ------------------ 62 | 63 | .. automodule:: pyboleto.bank.real 64 | :members: 65 | :undoc-members: 66 | :show-inheritance: 67 | 68 | :mod:`santander` Module 69 | ------------------ 70 | 71 | .. automodule:: pyboleto.bank.santander 72 | :members: 73 | :undoc-members: 74 | :show-inheritance: 75 | 76 | -------------------------------------------------------------------------------- /docs/pyboleto.django.rst: -------------------------------------------------------------------------------- 1 | django Package 2 | ============== 3 | 4 | :mod:`admin` Module 5 | ------------------- 6 | 7 | .. automodule:: pyboleto.django.admin 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | 12 | :mod:`models` Module 13 | -------------------- 14 | 15 | .. automodule:: pyboleto.django.models 16 | :members: 17 | :undoc-members: 18 | :show-inheritance: 19 | 20 | :mod:`views` Module 21 | ------------------- 22 | 23 | .. automodule:: pyboleto.django.views 24 | :members: 25 | :undoc-members: 26 | :show-inheritance: 27 | 28 | -------------------------------------------------------------------------------- /docs/pyboleto.rst: -------------------------------------------------------------------------------- 1 | pyboleto Package 2 | ================ 3 | 4 | :mod:`pyboleto` Package 5 | ----------------------- 6 | 7 | .. automodule:: pyboleto.__init__ 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | 12 | :mod:`data` Module 13 | ------------------ 14 | 15 | .. automodule:: pyboleto.data 16 | :members: 17 | :undoc-members: 18 | :show-inheritance: 19 | 20 | :mod:`pdf` Module 21 | ----------------- 22 | 23 | .. automodule:: pyboleto.pdf 24 | :members: 25 | :undoc-members: 26 | :show-inheritance: 27 | 28 | :mod:`html` Module 29 | ------------------ 30 | 31 | .. automodule:: pyboleto.html 32 | :members: 33 | :undoc-members: 34 | :show-inheritance: 35 | 36 | Subpackages 37 | ----------- 38 | 39 | .. toctree:: 40 | 41 | pyboleto.bank 42 | pyboleto.django 43 | 44 | -------------------------------------------------------------------------------- /pyboleto/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '1.0.7' 2 | -------------------------------------------------------------------------------- /pyboleto/bank/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from ..data import BoletoException 3 | BANCOS_IMPLEMENTADOS = { 4 | '001': 'bancodobrasil.BoletoBB', 5 | '041': 'banrisul.BoletoBanrisul', 6 | '237': 'bradesco.BoletoBradesco', 7 | '104': 'caixa.BoletoCaixa', 8 | '399': 'hsbc.BoletoHsbc', 9 | '341': 'itau.BoletoItau', 10 | '356': 'real.BoletoReal', 11 | '033': 'santander.BoletoSantander', 12 | '748': 'sicredi.BoletoSicredi', 13 | '756': 'sicoob.BoletoSicoob', 14 | '0851': 'cecred.BoletoCecred', 15 | } 16 | 17 | 18 | def get_class_for_codigo(banco_codigo): 19 | """Retorna a classe que implementa o banco 20 | 21 | :param banco_codigo: 22 | :type banco_codigo: string 23 | :return: Classo do Banco subclasse de :class:`pyboleto.data.BoletoData` 24 | :rtype: :class:`pyboleto.data.BoletoData` 25 | """ 26 | try: 27 | banco = BANCOS_IMPLEMENTADOS[banco_codigo].split('.') 28 | except KeyError: 29 | raise BoletoException 30 | 31 | mod = __import__('pyboleto.bank.' + banco[0], 32 | globals(), locals(), [banco[1]]) 33 | 34 | return getattr(mod, banco[1]) 35 | -------------------------------------------------------------------------------- /pyboleto/bank/bancodobrasil.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Boleto for Banco do Brasil 4 | """ 5 | # -*- coding: utf-8 -*- 6 | from pyboleto.data import BoletoData, CustomProperty 7 | 8 | ''' 9 | /* 10 | ################################################# 11 | - Convenio de 4 digitos 12 | Nosso número: pode ser de até 7 dígitos 13 | - Convenio de 6 digitos 14 | Nosso número: 15 | de 1 a 99999 para opção de até 5 dígitos 16 | de 1 a 99999999999999999 para opção de até 17 dígitos 17 | - Convenio de 7 digitos 18 | Nosso número: pode ser até 10 dígitos (Carteiras 16 e 18) 19 | - Convenio de 8 digitos 20 | Nosso número: pode ser até 9 dígitos 21 | ################################################# 22 | */ 23 | ''' 24 | 25 | 26 | class BoletoBB(BoletoData): 27 | ''' 28 | Gera Dados necessários para criação de boleto para o Banco do Brasil 29 | ''' 30 | 31 | agencia_cedente = CustomProperty('agencia_cedente', 4) 32 | conta_cedente = CustomProperty('conta_cedente', 8) 33 | 34 | def __init__(self, format_convenio, format_nnumero): 35 | ''' 36 | Construtor para boleto do Banco deo Brasil 37 | 38 | Args: 39 | format_convenio Formato do convenio 4, 6, 7 ou 8 40 | format_nnumero Formato nosso numero 1 ou 2 41 | (apenas para convenio 6) 42 | ''' 43 | super(BoletoBB, self).__init__() 44 | 45 | self.codigo_banco = "001" 46 | self.carteira = 18 47 | self.logo_image = "logo_bb.jpg" 48 | 49 | # Size of convenio 4, 6, 7 or 8 50 | self.format_convenio = format_convenio 51 | 52 | # Nosso Numero format. 1 or 2 53 | # Used only for convenio=6 54 | # 1: Nosso Numero with 5 positions 55 | # 2: Nosso Numero with 17 positions 56 | self.format_nnumero = format_nnumero 57 | 58 | self._convenio = "" 59 | self._nosso_numero = "" 60 | self.local_pagamento = 'Pagável em qualquer banco até o vencimento. \ 61 | Após, atualize o boleto no site bb.com.br' 62 | 63 | def format_nosso_numero(self): 64 | if self.format_convenio == 7: 65 | return '{:.7}'.format(self.convenio.zfill(7)) + '{:.10}'.format( 66 | self.nosso_numero) 67 | else: 68 | return "%s%s-%s" % ( 69 | self.convenio, 70 | self.nosso_numero, 71 | self.dv_nosso_numero 72 | ) 73 | 74 | # Nosso numero (sem dv) sao 11 digitos 75 | def _get_nosso_numero(self): 76 | return self._nosso_numero 77 | 78 | def _set_nosso_numero(self, val): 79 | val = str(val) 80 | if self.format_convenio == 4: 81 | nn = val.zfill(7) 82 | elif self.format_convenio == 6: 83 | if self.format_nnumero == 1: 84 | nn = val.zfill(5) 85 | elif self.format_nnumero == 2: 86 | nn = val.zfill(17) 87 | elif self.format_convenio == 7: 88 | nn = val.zfill(10) 89 | elif self.format_convenio == 8: 90 | nn = val.zfill(9) 91 | self._nosso_numero = nn 92 | 93 | nosso_numero = property(_get_nosso_numero, _set_nosso_numero) 94 | 95 | def _get_convenio(self): 96 | return self._convenio 97 | 98 | def _set_convenio(self, val): 99 | self._convenio = str(val).ljust(self.format_convenio, '0') 100 | convenio = property(_get_convenio, _set_convenio) 101 | 102 | @property 103 | def agencia_conta_cedente(self): 104 | return "%s-%s / %s-%s" % ( 105 | self.agencia_cedente, 106 | self.modulo11(self.agencia_cedente), 107 | self.conta_cedente, 108 | self.modulo11(self.conta_cedente) 109 | ) 110 | 111 | @property 112 | def dv_nosso_numero(self): 113 | ''' 114 | This function uses a modified version of modulo11 115 | ''' 116 | num = self.convenio + self.nosso_numero 117 | base = 2 118 | fator = 9 119 | soma = 0 120 | for c in reversed(num): 121 | soma += int(c) * fator 122 | if fator == base: 123 | fator = 10 124 | fator -= 1 125 | r = soma % 11 126 | if r == 10: 127 | return 'X' 128 | return r 129 | 130 | @property 131 | def campo_livre(self): 132 | if self.format_convenio == 4: 133 | content = "%s%s%s%s%s" % (self.convenio, 134 | self.nosso_numero, 135 | self.agencia_cedente, 136 | self.conta_cedente, 137 | self.carteira[:2]) 138 | elif self.format_convenio in (7, 8): 139 | content = "000000%s%s%s" % (self.convenio, 140 | self.nosso_numero, 141 | self.carteira[:2]) 142 | elif self.format_convenio == 6: 143 | if self.format_nnumero == 1: 144 | content = "%s%s%s%s%s" % (self.convenio, 145 | self.nosso_numero, 146 | self.agencia_cedente, 147 | self.conta_cedente, 148 | self.carteira[:2]) 149 | if self.format_nnumero == 2: 150 | content = "%s%s%s" % (self.convenio, 151 | self.nosso_numero, 152 | '21') # numero do serviço 153 | 154 | return content 155 | -------------------------------------------------------------------------------- /pyboleto/bank/banrisul.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyboleto.data import BoletoData, CustomProperty 3 | 4 | 5 | class BoletoBanrisul(BoletoData): 6 | conta_cedente = CustomProperty('conta_cedente', 6) 7 | nosso_numero = CustomProperty('nosso_numero', 8) 8 | 9 | def __init__(self): 10 | BoletoData.__init__(self) 11 | self.codigo_banco = "041" 12 | self.logo_image = "logo_banrisul.jpg" 13 | 14 | @property 15 | def campo_livre(self): 16 | content = '21%04d%07d%08d40' % (int(self.agencia_cedente), 17 | int(self.conta_cedente), 18 | int(self.nosso_numero)) 19 | return '%s%s' % (content, self._dv_campo_livre(content)) 20 | 21 | # From http://jrimum.org/bopepo/browser/trunk/src/br/com/nordestefomento/ 22 | # jrimum/bopepo/campolivre/AbstractCLBanrisul.java 23 | def _dv_campo_livre(self, campo_livre): 24 | dv = self.modulo10(campo_livre) 25 | while True: 26 | restoMod11 = self.modulo11(campo_livre + str(dv), 7, 1) 27 | if restoMod11 != 1: 28 | break 29 | dv += 1 30 | dv %= 10 31 | 32 | return str(dv) + str(11 - restoMod11) 33 | -------------------------------------------------------------------------------- /pyboleto/bank/bradesco.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pyboleto.bank.bradesco 4 | ~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Lógica para boletos do banco Bradesco. 7 | 8 | :copyright: © 2011 - 2012 by Eduardo Cereto Carvalho 9 | :license: BSD, see LICENSE for more details. 10 | 11 | """ 12 | from pyboleto.data import BoletoData, CustomProperty 13 | 14 | 15 | class BoletoBradesco(BoletoData): 16 | ''' 17 | Gera Dados necessários para criação de boleto para o banco Bradesco 18 | ''' 19 | 20 | nosso_numero = CustomProperty('nosso_numero', 11) 21 | agencia_cedente = CustomProperty('agencia_cedente', 4) 22 | conta_cedente = CustomProperty('conta_cedente', 7) 23 | 24 | def __init__(self): 25 | super(BoletoBradesco, self).__init__() 26 | 27 | self.codigo_banco = "237" 28 | self.logo_image = "logo_bancobradesco.jpg" 29 | self.carteira = '06' 30 | self.local_pagamento = 'Pagável Preferencialmente ' +\ 31 | 'na Rede Bradesco ou Bradesco Expresso.' 32 | 33 | def format_nosso_numero(self): 34 | return "%s/%s-%s" % ( 35 | self.carteira, 36 | self.nosso_numero, 37 | self.dv_nosso_numero 38 | ) 39 | 40 | @property 41 | def dv_nosso_numero(self): 42 | resto2 = self.modulo11(self.carteira + self.nosso_numero, 7, 1) 43 | digito = 11 - resto2 44 | if digito == 10: 45 | dv = 'P' 46 | elif digito == 11: 47 | dv = 0 48 | else: 49 | dv = digito 50 | return dv 51 | 52 | @property 53 | def campo_livre(self): 54 | content = '{0:.4}{1:.2}{2:.11}{3:.7}{4:.1}'.format( 55 | self.agencia_cedente.split('-')[0], 56 | self.carteira.zfill(2), 57 | self.nosso_numero.zfill(11), 58 | self.conta_cedente.split('-')[0], 59 | '0' 60 | ) 61 | return content 62 | -------------------------------------------------------------------------------- /pyboleto/bank/caixa.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyboleto.data import BoletoData, CustomProperty 3 | 4 | 5 | class BoletoCaixa(BoletoData): 6 | ''' 7 | Gera Dados necessários para criação de boleto para o banco Caixa 8 | Economica Federal 9 | 10 | ''' 11 | agencia_cedente = CustomProperty('agencia_cedente', 4) 12 | conta_cedente = CustomProperty('conta_cedente', 6) 13 | codigo_beneficiario = CustomProperty('codigo_beneficiario', 6) 14 | ''' 15 | Este numero tem o inicio fixo 16 | Carteira SR: 80, 81 ou 82 17 | Carteira CR: 90 (Confirmar com gerente qual usar) 18 | 19 | ''' 20 | nosso_numero = CustomProperty('nosso_numero', 10) 21 | 22 | def __init__(self): 23 | super(BoletoCaixa, self).__init__() 24 | 25 | self.codigo_banco = "104" 26 | self.local_pagamento = "Preferencialmente nas Casas Lotéricas e \ 27 | Agências da Caixa" 28 | self.logo_image = "logo_bancocaixa.jpg" 29 | 30 | @property 31 | def agencia_conta_cedente(self): 32 | return "%s/%s-%s" % (self.agencia_cedente, self.codigo_beneficiario, 33 | self.modulo11(self.codigo_beneficiario)) 34 | 35 | @property 36 | def dv_nosso_numero(self): 37 | numero = "%1s4%15s" % (self.carteira, self.nosso_numero.zfill(15)) 38 | return self.modulo11(numero) 39 | 40 | @property 41 | def campo_livre(self): 42 | nosso_numero_completo = self.format_nosso_numero() 43 | content = "%6s%1s%3s%1s%3s%1s%9s" % ( 44 | self.codigo_beneficiario, 45 | self.modulo11(self.codigo_beneficiario), 46 | nosso_numero_completo[2:5], 47 | self.carteira, 48 | nosso_numero_completo[5:8], 49 | '4', # Beneficiário emite, 50 | nosso_numero_completo[8:17], 51 | ) 52 | return "%s%s" % (content, self.modulo11(content)) 53 | 54 | def format_nosso_numero(self): 55 | content = "%1s4%15s-%1s" % ( 56 | self.carteira, 57 | self.nosso_numero.zfill(15), 58 | self.dv_nosso_numero, 59 | ) 60 | return content 61 | -------------------------------------------------------------------------------- /pyboleto/bank/caixa_sigcb.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyboleto.data import BoletoData, CustomProperty 3 | 4 | 5 | class BoletoCaixaSigcb(BoletoData): 6 | ''' 7 | Gera Dados necessários para criação de boleto para o banco Caixa 8 | Economica Federal 9 | ''' 10 | 11 | agencia_cedente = CustomProperty('agencia_cedente', 4) 12 | conta_cedente = CustomProperty('conta_cedente', 6) 13 | nosso_numero = CustomProperty('nosso_numero', 17) 14 | 15 | def __init__(self): 16 | super(BoletoCaixaSigcb, self).__init__() 17 | 18 | self.codigo_banco = "104" 19 | self.local_pagamento = ("Preferencialmente nas Casas Lotéricas e " 20 | "Agências da Caixa") 21 | self.logo_image = "logo_bancocaixa.jpg" 22 | 23 | @property 24 | def campo_livre(self): # 24 digits 25 | content = "%6s%1s%3s%1s%3s%1s%9s" % ( 26 | self.conta_cedente.split('-')[0], 27 | self.modulo11(self.conta_cedente.split('-')[0]), 28 | self.nosso_numero[2:5], 29 | self.nosso_numero[0:1], 30 | self.nosso_numero[5:8], 31 | self.nosso_numero[1:2], 32 | self.nosso_numero[8:17] 33 | ) 34 | dv_content = self.modulo11(content) 35 | 36 | return "%24s%1s" % (content, dv_content) 37 | 38 | def format_nosso_numero(self): 39 | return self.nosso_numero 40 | -------------------------------------------------------------------------------- /pyboleto/bank/cecred.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import re 4 | from pyboleto.data import BoletoData, CustomProperty 5 | 6 | 7 | class BoletoCecred(BoletoData): 8 | '''Implementa Boleto Cecred 9 | 10 | Gera Dados necessários para criação de boleto para o banco Cecred 11 | ''' 12 | 13 | agencia_cedente = CustomProperty('agencia_cedente', 4) 14 | conta_cedente = CustomProperty('conta_cedente', 6) 15 | codigo_beneficiario = CustomProperty('codigo_beneficiario', 6) 16 | nosso_numero = CustomProperty('nosso_numero', 9) 17 | 18 | carteira = CustomProperty('carteira', 1) 19 | 20 | def __init__(self): 21 | super(BoletoCecred, self).__init__() 22 | 23 | self.codigo_banco = "085" 24 | self.logo_image = "logo_cecred.jpg" 25 | self.especie_documento = 'DM' 26 | self.label_cedente = 'Agência/Código Beneficiário' 27 | self.local_pagamento = 'Pagável Preferencialmente nas Cooperativas '\ 28 | 'do sistema Cecred. Após venc. somente na cooperativa' 29 | 30 | @property 31 | def codigo_dv_banco(self): 32 | return self.codigo_banco + '-1' 33 | 34 | def format_nosso_numero(self): 35 | return "%s%s" % (re.sub('[^0-9]', '', self.conta_cedente), 36 | self.nosso_numero) 37 | 38 | @property 39 | def campo_livre(self): 40 | content = "%6s%8s%9s%2s" % (self.codigo_beneficiario.zfill(6), 41 | re.sub('[^0-9]', '', self.conta_cedente), 42 | self.nosso_numero[ 43 | len( 44 | self.nosso_numero.zfill(9)) - 9:], 45 | self.carteira.zfill(2)) 46 | return content 47 | -------------------------------------------------------------------------------- /pyboleto/bank/hsbc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyboleto.data import BoletoData, CustomProperty 3 | 4 | 5 | class BoletoHsbc(BoletoData): 6 | ''' 7 | Gera Dados necessários para criação de boleto para o banco HSBC 8 | ''' 9 | 10 | numero_documento = CustomProperty('numero_documento', 13) 11 | 12 | def __init__(self): 13 | super(BoletoHsbc, self).__init__() 14 | 15 | self.codigo_banco = "399" 16 | self.logo_image = "logo_bancohsbc.jpg" 17 | self.carteira = 'CNR' 18 | 19 | def format_nosso_numero(self): 20 | nosso_numero = self.nosso_numero 21 | # Primeiro DV 22 | nosso_numero += str(self.modulo11(nosso_numero)) 23 | # Cobrança com vencimento = 4 24 | nosso_numero += "4" 25 | # Segundo DV 26 | sum_params = int(nosso_numero) + int(self.conta_cedente) 27 | sum_params += int(self.data_vencimento.strftime('%d%m%y')) 28 | sum_params = str(sum_params) 29 | nosso_numero += str(self.modulo11(sum_params)) 30 | return nosso_numero 31 | 32 | @property 33 | def data_vencimento_juliano(self): 34 | data_vencimento = str(self.data_vencimento.timetuple().tm_yday) 35 | data_vencimento += str(self.data_vencimento.year)[-1:] 36 | return data_vencimento.zfill(4) 37 | 38 | @property 39 | def campo_livre(self): 40 | content = "%7s%13s%4s2" % (self.conta_cedente, 41 | self.nosso_numero, 42 | self.data_vencimento_juliano) 43 | return content 44 | 45 | 46 | class BoletoHsbcComRegistro(BoletoData): 47 | ''' 48 | Gera Dados necessários para criação de boleto para o banco HSBC 49 | com registro 50 | ''' 51 | # Nosso numero (sem dv) sao 10 digitos 52 | nosso_numero = CustomProperty('nosso_numero', 10) 53 | 54 | def __init__(self): 55 | super(BoletoHsbcComRegistro, self).__init__() 56 | 57 | self.codigo_banco = "399" 58 | self.logo_image = "logo_bancohsbc.jpg" 59 | self.carteira = 'CSB' 60 | self.especie_documento = 'PD' 61 | 62 | @property 63 | def dv_nosso_numero(self): 64 | resto = self.modulo11(self.nosso_numero, 7, 1) 65 | if resto == 0 or resto == 1: 66 | return 0 67 | else: 68 | return 11 - resto 69 | 70 | @property 71 | def campo_livre(self): 72 | content = "%10s%1s%4s%7s001" % (self.nosso_numero, 73 | self.dv_nosso_numero, 74 | self.agencia_cedente.split('-')[0], 75 | self.conta_cedente.split('-')[0]) 76 | return content 77 | -------------------------------------------------------------------------------- /pyboleto/bank/itau.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyboleto.data import BoletoData, CustomProperty 3 | 4 | 5 | class BoletoItau(BoletoData): 6 | '''Implementa Boleto Itaú 7 | 8 | Gera Dados necessários para criação de boleto para o banco Itau 9 | Todas as carteiras com excessão das que utilizam 15 dígitos: (106,107, 10 | 195,196,198) 11 | ''' 12 | 13 | # Nosso numero (sem dv) com 8 digitos 14 | nosso_numero = CustomProperty('nosso_numero', 8) 15 | # Conta (sem dv) com 5 digitos 16 | conta_cedente = CustomProperty('conta_cedente', 5) 17 | # Agência (sem dv) com 4 digitos 18 | agencia_cedente = CustomProperty('agencia_cedente', 4) 19 | carteira = CustomProperty('carteira', 3) 20 | 21 | def __init__(self): 22 | super(BoletoItau, self).__init__() 23 | 24 | self.codigo_banco = "341" 25 | self.logo_image = "logo_itau.jpg" 26 | self.especie_documento = 'DM' 27 | self.local_pagamento = 'Até o vencimento, preferencialmente no Itaú. ' +\ 28 | 'Após o vencimento, somente no Itaú ' 29 | 30 | @property 31 | def dv_nosso_numero(self): 32 | composto = "%4s%5s%3s%8s" % (self.agencia_cedente, self.conta_cedente, 33 | self.carteira, self.nosso_numero) 34 | return self.modulo10(composto) 35 | 36 | @property 37 | def dv_agencia_conta_cedente(self): 38 | agencia_conta = "%s%s" % (self.agencia_cedente, self.conta_cedente) 39 | return self.modulo10(agencia_conta) 40 | 41 | @property 42 | def agencia_conta_cedente(self): 43 | return "%s/%s-%s" % (self.agencia_cedente, self.conta_cedente, 44 | self.conta_cedente_dv) 45 | 46 | def format_nosso_numero(self): 47 | return "%3s/%8s-%1s" % (self.carteira, self.nosso_numero, 48 | self.dv_nosso_numero) 49 | 50 | @property 51 | def campo_livre(self): 52 | content = "%3s%8s%1s%4s%5s%1s%3s" % (self.carteira, 53 | self.nosso_numero, 54 | self.dv_nosso_numero, 55 | self.agencia_cedente, 56 | self.conta_cedente, 57 | self.conta_cedente_dv, 58 | '000' 59 | ) 60 | return content 61 | -------------------------------------------------------------------------------- /pyboleto/bank/santander.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pyboleto.bank.santander 4 | ~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Lógica para boletos do banco Santander. 7 | Carteira ``'101'`` Com Registro 8 | Carteira ``'102'`` Sem Registro 9 | Carteira ``'201'`` Penhor Rápido Com Registro 10 | 11 | Baseado no projeto `BoletoPHP ` 12 | 13 | :copyright: © 2011 - 2012 by Eduardo Cereto Carvalho 14 | :license: BSD, see LICENSE for more details. 15 | 16 | """ 17 | from pyboleto.data import BoletoData, CustomProperty 18 | 19 | 20 | class BoletoSantander(BoletoData): 21 | 22 | ''' 23 | Gera Dados necessários para criação de boleto para o banco Santander 24 | ''' 25 | 26 | nosso_numero = CustomProperty('nosso_numero', 12) 27 | 28 | #: Também chamado de "ponto de venda" 29 | agencia_cedente = CustomProperty('agencia_cedente', 4) 30 | 31 | #: Também chamdo de código do cedente, se for uma conta de 9 dígitos 32 | #: ignorar os 2 primeiros 33 | conta_cedente = CustomProperty('conta_cedente', 7) 34 | 35 | def __init__(self): 36 | super(BoletoSantander, self).__init__() 37 | 38 | self.codigo_banco = "033" 39 | self.logo_image = "logo_santander.png" 40 | self.carteira = '102' 41 | # IOS - somente para Seguradoras (Se 7% informar 7, limitado 9%) 42 | # Demais clientes usar 0 (zero) 43 | self.ios = "0" 44 | 45 | def format_nosso_numero(self): 46 | return "%s-%s" % ( 47 | self.nosso_numero, 48 | self._dv_nosso_numero() 49 | ) 50 | 51 | def _dv_nosso_numero(self): 52 | return str(self.modulo11(self.nosso_numero, 9, 0)) 53 | 54 | @property 55 | def campo_livre(self): 56 | content = "".join([ 57 | '9', 58 | self.conta_cedente[-7:], 59 | self.nosso_numero, 60 | self._dv_nosso_numero(), 61 | self.ios, 62 | self.carteira, 63 | ]) 64 | return content 65 | 66 | @property 67 | def agencia_conta_cedente(self): 68 | return "%s/%s" % (self.agencia_cedente, self.conta_cedente[-7:]) 69 | -------------------------------------------------------------------------------- /pyboleto/bank/sicoob.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyboleto.data import BoletoData, CustomProperty 3 | 4 | 5 | class BoletoSicoob(BoletoData): 6 | '''Implementa Boleto Sicoob 7 | 8 | Gera Dados necessários para criação de boleto para o banco Sicoob 9 | ''' 10 | 11 | agencia_cedente = CustomProperty('agencia_cedente', 4) 12 | conta_cedente = CustomProperty('conta_cedente', 6) 13 | codigo_beneficiario = CustomProperty('codigo_beneficiario', 7) 14 | nosso_numero = CustomProperty('nosso_numero', 7) 15 | 16 | carteira = CustomProperty('carteira', 1) 17 | 18 | def __init__(self): 19 | super(BoletoSicoob, self).__init__() 20 | 21 | self.codigo_banco = "756" 22 | self.logo_image = "logo_sicoob.jpg" 23 | self.especie_documento = 'DM' 24 | self.label_cedente = 'Coop Contr/Cód Beneficiário' 25 | self.local_pagamento = 'Pagável Preferencialmente nas Cooperativas ' +\ 26 | 'da Rede Sicoob ou Qualquer Banco até o Vencimento.' 27 | 28 | @property 29 | def modalidade(self): 30 | return '01' if self.carteira == '1' else '03' 31 | 32 | @property 33 | def dv_nosso_numero(self): 34 | composto = "%4s%10s%7s" % (self.agencia_cedente, 35 | self.codigo_beneficiario.zfill(10), 36 | self.nosso_numero) 37 | constante = '319731973197319731973' 38 | soma = 0 39 | for i in range(21): 40 | soma += int(composto[i]) * int(constante[i]) 41 | resto = soma % 11 42 | return '0' if (resto == 1 or resto == 0) else 11 - resto 43 | 44 | @property 45 | def agencia_conta_cedente(self): 46 | return "%s/%s" % (self.agencia_cedente, self.codigo_beneficiario) 47 | 48 | def format_nosso_numero(self): 49 | return "%8s-%1s" % (self.nosso_numero, 50 | self.dv_nosso_numero) 51 | 52 | @property 53 | def codigo_dv_banco(self): 54 | return self.codigo_banco 55 | 56 | @property 57 | def campo_livre(self): 58 | content = "%1s%4s%2s%7s%7s%1s%3s" % (self.carteira, 59 | self.agencia_cedente.strip(), 60 | self.modalidade, 61 | self.codigo_beneficiario, 62 | self.nosso_numero[:7], 63 | self.dv_nosso_numero, 64 | '001') 65 | return content 66 | -------------------------------------------------------------------------------- /pyboleto/bank/sicredi.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyboleto.data import BoletoData, CustomProperty 3 | 4 | 5 | class BoletoSicredi(BoletoData): 6 | ''' 7 | Gera Dados necessários para criação de boleto para o Banco Sicredi 8 | ''' 9 | agencia_cedente = CustomProperty('agencia_cedente', 4) 10 | conta_cedente = CustomProperty('conta_cedente', 5) 11 | posto = CustomProperty('posto', 2) 12 | carteira = CustomProperty('carteira', 1) 13 | # Nosso numero (sem dv) com 8 digitos 14 | # AA/BXXXXX-DV 15 | # Pag. 6 manual cnab 400 16 | nosso_numero = CustomProperty('nosso_numero', 8) 17 | 18 | def __init__(self): 19 | ''' 20 | Construtor para boleto do Banco Sicredi 21 | 22 | Args: 23 | format_convenio Formato do convenio 6, 7 ou 8 24 | format_nnumero Formato nosso numero 1 ou 2 25 | ''' 26 | super(BoletoSicredi, self).__init__() 27 | 28 | self.codigo_banco = "748" 29 | self.local_pagamento = u'Pagável prefencialmente nas Coop. de Crédito Sicredi' 30 | self.logo_image = "logo_sicredi.png" 31 | 32 | def format_ano(self): 33 | ano = str(self.data_vencimento.strftime('%y')) 34 | ano = ano.zfill(2) 35 | return ano 36 | 37 | @property 38 | def dv_nosso_numero(self): 39 | composto = "%s%s%s%s" % (self.agencia_cedente, self.posto, self.conta_cedente, 40 | self.nosso_numero) 41 | composto = self.modulo11(composto) 42 | return composto 43 | 44 | def format_nosso_numero(self): 45 | return "%s/%s-%s" % (self.nosso_numero[:2], self.nosso_numero[2:], 46 | self.dv_nosso_numero) 47 | @property 48 | def campo_livre(self): 49 | content = "1%s%s%s%s%s%s%s" % (self.carteira, 50 | self.nosso_numero, 51 | self.dv_nosso_numero, 52 | self.agencia_cedente, 53 | self.posto, 54 | self.conta_cedente, 55 | '10' 56 | ) 57 | content += str(self.modulo11(content)) 58 | return content 59 | 60 | -------------------------------------------------------------------------------- /pyboleto/html.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pyboleto.html 4 | ~~~~~~~~~~~~~ 5 | 6 | Classe Responsável por fazer o output do boleto em html. 7 | 8 | :copyright: © 2012 by Artur Felipe de Sousa 9 | :license: BSD, see LICENSE for more details. 10 | 11 | """ 12 | import os 13 | import string 14 | import sys 15 | import codecs 16 | import base64 17 | 18 | from itertools import chain 19 | if sys.version_info < (3,): 20 | from itertools import zip_longest as zip_longest 21 | zip_longest # chamando para evitar erro de nao uso do zip_longest 22 | else: 23 | from itertools import zip_longest 24 | 25 | DIGITS = [ 26 | ['n', 'n', 'w', 'w', 'n'], 27 | ['w', 'n', 'n', 'n', 'w'], 28 | ['n', 'w', 'n', 'n', 'w'], 29 | ['w', 'w', 'n', 'n', 'n'], 30 | ['n', 'n', 'w', 'n', 'w'], 31 | ['w', 'n', 'w', 'n', 'n'], 32 | ['n', 'w', 'w', 'n', 'n'], 33 | ['n', 'n', 'n', 'w', 'w'], 34 | ['w', 'n', 'n', 'w', 'n'], 35 | ['n', 'w', 'n', 'w', 'n'], 36 | ] 37 | 38 | 39 | class BoletoHTML(object): 40 | """Geração do Boleto em HTML 41 | 42 | Esta classe é responsável por imprimir o boleto em HTML. 43 | Outras classes podem ser implementadas no futuro com a mesma interface, 44 | para fazer output em LaTeX, etc ... 45 | 46 | Esta classe pode imprimir boletos em formato de carnê (2 boletos por 47 | página) ou em formato de folha cheia. 48 | 49 | :param file_descr: Um arquivo ou *file-like* class. 50 | :param landscape: Formato da folha. Usar ``True`` para boleto 51 | tipo carnê. 52 | 53 | """ 54 | 55 | def __init__(self, file_descr, landscape=False): 56 | # Tamanhos em px 57 | self.width = 750 58 | self.widthCanhoto = 0 59 | self.fontSizeTitle = 9 60 | self.heightLine = 27 61 | self.fontSizeValue = 12 62 | self.title = 'Boleto bancário' 63 | self.fileDescr = file_descr 64 | 65 | if landscape: 66 | raise NotImplementedError('Em desenvolvimento...') 67 | else: 68 | tpl = string.Template(self._load_template('head.html')) 69 | self.html = tpl.substitute(title=self.title, width=self.width, 70 | font_size_value=self.fontSizeValue, 71 | height_line=self.heightLine, 72 | font_size_title=self.fontSizeTitle) 73 | 74 | def _load_template(self, template): 75 | pyboleto_dir = os.path.dirname(os.path.abspath(__file__)) 76 | template_path = os.path.join(pyboleto_dir, 'templates', template) 77 | with open(template_path, 'r', encoding='utf-8') as tpl: 78 | template_content = tpl.read() 79 | return template_content 80 | 81 | def _load_image(self, logo_image): 82 | pyboleto_dir = os.path.dirname(os.path.abspath(__file__)) 83 | image_path = os.path.join(pyboleto_dir, 'media', logo_image) 84 | return image_path 85 | 86 | def _drawReciboSacado(self, boletoDados): 87 | """Imprime o Recibo do Sacado para modelo de página inteira 88 | 89 | :param boletoDados: Objeto com os dados do boleto a ser preenchido. 90 | Deve ser subclasse de :class:`pyboleto.data.BoletoData` 91 | :type boletoDados: :class:`pyboleto.data.BoletoData` 92 | 93 | """ 94 | tpl = string.Template(self._load_template('recibo_sacado.html')) 95 | tpl_data = {} 96 | 97 | # Cabeçalho 98 | tpl_data['logo_img'] = '' 99 | if boletoDados.logo_image: 100 | img = codecs.open( 101 | self._load_image(boletoDados.logo_image), mode='rb') 102 | aux = img.read() 103 | aux = base64.b64encode(aux) 104 | img_base64 = 'data:image/jpeg;base64,{0}'.format(aux.decode()) 105 | tpl_data['logo_img'] = img_base64 106 | tpl_data['codigo_dv_banco'] = boletoDados.codigo_dv_banco 107 | 108 | # Corpo 109 | tpl_data['cedente'] = boletoDados.cedente 110 | tpl_data['agencia_conta_cedente'] = boletoDados.agencia_conta_cedente 111 | tpl_data['cedente_documento'] = boletoDados.cedente_documento 112 | 113 | data_vencimento = boletoDados.data_vencimento 114 | tpl_data['data_vencimento'] = data_vencimento.strftime('%d/%m/%Y') 115 | tpl_data['sacado'] = boletoDados.sacado[0] 116 | tpl_data['nosso_numero_format'] = boletoDados.format_nosso_numero() 117 | tpl_data['numero_documento'] = boletoDados.numero_documento 118 | 119 | data_documento = boletoDados.data_documento 120 | tpl_data['data_documento'] = data_documento.strftime('%d/%m/%Y') 121 | tpl_data['cedente_endereco'] = boletoDados.cedente_endereco 122 | 123 | valor_doc = self._formataValorParaExibir(boletoDados.valor_documento) 124 | tpl_data['valor_documento'] = valor_doc 125 | 126 | # Demonstrativo 127 | tpl_data['demonstrativo'] = '' 128 | for dm in boletoDados.demonstrativo: 129 | tpl_data['demonstrativo'] += '

{0}

'.format(dm) 130 | 131 | self.html += tpl.substitute(tpl_data) 132 | 133 | def _drawHorizontalCorteLine(self): 134 | self.html += '
' 135 | 136 | def _drawReciboCaixa(self, boletoDados): 137 | """Imprime o Recibo do Caixa 138 | 139 | :param boletoDados: Objeto com os dados do boleto a ser preenchido. 140 | Deve ser subclasse de :class:`pyboleto.data.BoletoData` 141 | :type boletoDados: :class:`pyboleto.data.BoletoData` 142 | 143 | """ 144 | tpl = string.Template(self._load_template('recibo_caixa.html')) 145 | tpl_data = {} 146 | 147 | # Cabeçalho 148 | tpl_data['logo_img'] = '' 149 | if boletoDados.logo_image: 150 | img = codecs.open( 151 | self._load_image(boletoDados.logo_image), mode='rb') 152 | aux = img.read() 153 | aux = base64.b64encode(aux) 154 | img_base64 = 'data:image/jpeg;base64,{0}'.format(aux.decode()) 155 | tpl_data['logo_img'] = img_base64 156 | tpl_data['codigo_dv_banco'] = boletoDados.codigo_dv_banco 157 | tpl_data['linha_digitavel'] = boletoDados.linha_digitavel 158 | 159 | # Corpo 160 | data_vencimento = boletoDados.data_vencimento 161 | tpl_data['data_vencimento'] = data_vencimento.strftime('%d/%m/%Y') 162 | 163 | # value em unicode em data.py 164 | if isinstance(boletoDados.local_pagamento, str): 165 | tpl_data['local_pagamento'] = boletoDados.local_pagamento 166 | else: 167 | tpl_data['local_pagamento'] = boletoDados.local_pagamento.decode() 168 | tpl_data['cedente'] = boletoDados.cedente 169 | tpl_data['agencia_conta_cedente'] = boletoDados.agencia_conta_cedente 170 | 171 | data_documento = boletoDados.data_documento 172 | tpl_data['data_documento'] = data_documento.strftime('%d/%m/%Y') 173 | tpl_data['numero_documento'] = boletoDados.numero_documento 174 | tpl_data['especie_documento'] = boletoDados.especie_documento 175 | tpl_data['aceite'] = boletoDados.aceite 176 | 177 | data_process = boletoDados.data_processamento 178 | tpl_data['data_processamento'] = data_process.strftime('%d/%m/%Y') 179 | tpl_data['nosso_numero_format'] = boletoDados.format_nosso_numero() 180 | tpl_data['carteira'] = boletoDados.carteira 181 | tpl_data['especie'] = boletoDados.especie 182 | tpl_data['quantidade'] = boletoDados.quantidade 183 | 184 | valor = self._formataValorParaExibir(boletoDados.valor) 185 | tpl_data['valor'] = valor 186 | 187 | valor_doc = self._formataValorParaExibir(boletoDados.valor_documento) 188 | tpl_data['valor_documento'] = valor_doc 189 | 190 | # Instruções 191 | tpl_data['instrucoes'] = '' 192 | for instrucao in boletoDados.instrucoes: 193 | tpl_data['instrucoes'] += '

{0}

'.format(instrucao) 194 | 195 | # Rodapé 196 | tpl_data['sacado_info'] = '' 197 | for linha_sacado in boletoDados.sacado: 198 | tpl_data['sacado_info'] += '

{0}

'.format(linha_sacado) 199 | 200 | # Código de barras 201 | tpl_data['barcode'] = self._codigoBarraI25(boletoDados.barcode) 202 | 203 | self.html += tpl.substitute(tpl_data) 204 | 205 | def drawBoletoCarneDuplo(self, boletoDados1, boletoDados2=None): 206 | """Imprime um boleto tipo carnê com 2 boletos por página. 207 | 208 | :param boletoDados1: Objeto com os dados do boleto a ser preenchido. 209 | Deve ser subclasse de :class:`pyboleto.data.BoletoData` 210 | :param boletoDados2: Objeto com os dados do boleto a ser preenchido. 211 | Deve ser subclasse de :class:`pyboleto.data.BoletoData` 212 | :type boletoDados1: :class:`pyboleto.data.BoletoData` 213 | :type boletoDados2: :class:`pyboleto.data.BoletoData` 214 | 215 | """ 216 | raise NotImplementedError('Em desenvolvimento') 217 | 218 | def drawBoleto(self, boletoDados): 219 | """Imprime Boleto Convencional 220 | 221 | Você pode chamar este método diversas vezes para criar um arquivo com 222 | várias páginas, uma por boleto. 223 | 224 | :param boletoDados: Objeto com os dados do boleto a ser preenchido. 225 | Deve ser subclasse de :class:`pyboleto.data.BoletoData` 226 | :type boletoDados: :class:`pyboleto.data.BoletoData` 227 | """ 228 | self._drawReciboSacado(boletoDados) 229 | self._drawHorizontalCorteLine() 230 | self._drawReciboCaixa(boletoDados) 231 | self._drawHorizontalCorteLine() 232 | 233 | def nextPage(self): 234 | """Força início de nova página""" 235 | self.html += '
' 236 | 237 | def save(self): 238 | """Fecha boleto e constroi o arquivo""" 239 | self.html += '
' 240 | if hasattr(self.fileDescr, 'write'): 241 | self.fileDescr.write(self.html) 242 | else: 243 | with open(self.fileDescr, 'w') as fd: 244 | fd.write(self.html) 245 | 246 | def _formataValorParaExibir(self, nfloat): 247 | if nfloat: 248 | txt = nfloat 249 | txt = txt.replace('.', ',') 250 | else: 251 | txt = "" 252 | return txt 253 | 254 | def _codigoBarraI25(self, code): 255 | """Imprime Código de barras otimizado para boletos 256 | http://en.wikipedia.org/wiki/Interleaved_2_of_5 257 | """ 258 | digits = ['n', 'n s', 'n', 'n s'] 259 | 260 | if len(code) % 2 != 0: 261 | code = '0' + code 262 | 263 | for digt1, digt2 in self._grouper(2, code): 264 | digt1_repr = DIGITS[int(digt1)] 265 | digt2_repr = [x + ' s' for x in DIGITS[int(digt2)]] 266 | digits.extend(chain(*list(zip(digt1_repr, digt2_repr)))) 267 | 268 | digits.extend(['w', 'n s', 'n']) 269 | 270 | result = [] 271 | for digit in digits: 272 | result.append(''.format(digit)) 273 | 274 | return ''.join(result) 275 | 276 | def _grouper(self, n, iterable, fillvalue=None): 277 | """grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx""" 278 | args = [iter(iterable)] * n 279 | return zip_longest(fillvalue=fillvalue, *args) 280 | -------------------------------------------------------------------------------- /pyboleto/media/logo_bancobradesco.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/pyboleto/media/logo_bancobradesco.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_bancocaixa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/pyboleto/media/logo_bancocaixa.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_bancohsbc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/pyboleto/media/logo_bancohsbc.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_bancoreal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/pyboleto/media/logo_bancoreal.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_banrisul.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/pyboleto/media/logo_banrisul.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_bb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/pyboleto/media/logo_bb.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_cecred.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/pyboleto/media/logo_cecred.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_itau.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/pyboleto/media/logo_itau.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_santander.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/pyboleto/media/logo_santander.png -------------------------------------------------------------------------------- /pyboleto/media/logo_sicoob.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/pyboleto/media/logo_sicoob.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_sicredi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/pyboleto/media/logo_sicredi.png -------------------------------------------------------------------------------- /pyboleto/templates/head.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ${title} 5 | 6 | 50 | 51 | 52 |
53 | -------------------------------------------------------------------------------- /pyboleto/templates/recibo_caixa.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 8 | 11 | 12 | 13 | 14 |
9 |
${codigo_dv_banco}
10 |
${linha_digitavel}
15 | 16 | 17 | 18 | 21 | 24 | 25 | 26 | 29 | 33 | 34 | 35 | 38 | 41 | 44 | 47 | 50 | 53 | 54 | 55 | 58 | 61 | 64 | 67 | 70 | 73 | 74 | 75 | 81 | 84 | 85 | 86 | 89 | 90 | 91 | 94 | 95 | 96 | 99 | 100 | 101 | 104 | 105 | 106 |
19 |
Local de pagamento
${local_pagamento} 20 |
22 |
Vencimento
${data_vencimento} 23 |
27 |
Cedente
${cedente} 28 |
30 |
Agência/Código cedente
31 | ${agencia_conta_cedente} 32 |
36 |
Data do documento
${data_documento} 37 |
39 |
N. do documento
${numero_documento} 40 |
42 |
Espécie doc
${especie_documento} 43 |
45 |
Aceite
${aceite} 46 |
48 |
Data processamento
${data_processamento} 49 |
51 |
Nosso número
${nosso_numero_format} 52 |
56 |
Uso do banco
57 |
59 |
Carteira
${carteira} 60 |
62 |
Espécie
${especie} 63 |
65 |
Quantidade
${quantidade} 66 |
68 |
Valor
${valor} 69 |
71 |
(=) Valor documento
${valor_documento} 72 |
76 |
Instruções 77 | (Todas as informações deste bloqueto são de exclusiva 78 | responsabilidade do cedente)
79 |
${instrucoes}
80 |
82 |
(-) Descontos/Abatimentos
${valor_desconto} 83 |
87 |
(-) Outras deduções
88 |
92 |
(+) Mora/Multa
93 |
97 |
(+) Outros acréscimos
98 |
102 |
(=) Valor cobrado
${valor_cobrado} 103 |
107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 117 | 120 | 121 | 122 | 125 | 128 | 129 | 130 |
Sacado
${sacado_info}
115 |
Sacador / Avalista
116 |
118 |
Código de baixa
119 |
123 |
${barcode}
124 |
126 |
Autenticação Mecânica / Ficha de Compensação
127 |
131 |
132 | -------------------------------------------------------------------------------- /pyboleto/templates/recibo_sacado.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 8 | 11 | 12 | 13 | 14 |
9 |
${codigo_dv_banco}
10 |
Recibo do Sacado
15 | 16 | 17 | 18 | 22 | 26 | 29 | 32 | 33 | 34 | 37 | 40 | 43 | 46 | 47 | 48 | 51 | 54 | 55 | 56 |
19 |
Cedente
20 | ${cedente} 21 |
23 |
Agência/Código Cedente
24 | ${agencia_conta_cedente} 25 |
27 |
CPF/CNPJ Cedente
${cedente_documento} 28 |
30 |
Vencimento
${data_vencimento} 31 |
35 |
Sacado
${sacado} 36 |
38 |
Nosso Número
${nosso_numero_format} 39 |
41 |
N. do documento
${numero_documento} 42 |
44 |
Data Documento
${data_documento} 45 |
49 |
Endereço Cedente
${cedente_endereco} 50 |
52 |
Valor Documento
${valor_documento} 53 |
57 |
58 |
59 |
Demonstrativo
60 |
${demonstrativo}
61 |
62 |
63 |
Autenticação Mecânica
64 |
65 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | coveralls 2 | reportlab 3 | pytest 4 | pytest-cov 5 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [build_sphinx] 2 | source-dir = docs/ 3 | build-dir = docs/_build 4 | all_files = 1 5 | 6 | [upload_sphinx] 7 | upload-dir = docs/_build/html 8 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import os 4 | import re 5 | 6 | from setuptools import setup, find_packages 7 | 8 | 9 | def read(fname): 10 | return open(os.path.join(os.path.dirname(__file__), fname)).read() 11 | 12 | 13 | def get_version(package): 14 | """Return package version as listed in `__version__` in `__init__.py`.""" 15 | init_py = open(os.path.join(os.path.dirname(__file__), 16 | package, '__init__.py'), 17 | 'r').read() 18 | return re.search("^__version__ = ['\"]([^'\"]+)['\"]", 19 | init_py, re.MULTILINE 20 | ).group(1) 21 | 22 | setup( 23 | name='python3-boleto', 24 | version=get_version('pyboleto'), 25 | author='Trust-Code', 26 | author_email='suporte@trustcode.com.br', 27 | url='https://github.com/Trust-Code/python-boleto', 28 | packages=find_packages(), 29 | package_data={ 30 | '': ['LICENSE'], 31 | 'pyboleto': ['media/*.jpg', 'media/*.png', 'templates/*.html'], 32 | 'tests': ['xml/*.xml'] 33 | }, 34 | zip_safe=False, 35 | provides=[ 36 | 'pyboleto' 37 | ], 38 | license='BSD', 39 | description='Python Library to create "boletos de cobrança bancária" for \ 40 | several Brazilian banks', 41 | long_description=read('README.rst'), 42 | download_url='http://pypi.python.org/pypi/pyboleto', 43 | scripts=[ 44 | 'bin/html_pyboleto_sample.py', 45 | 'bin/pdf_pyboleto_sample.py' 46 | ], 47 | classifiers=[ 48 | 'Development Status :: 4 - Beta', 49 | 'Operating System :: OS Independent', 50 | 'Intended Audience :: Developers', 51 | 'Intended Audience :: Financial and Insurance Industry', 52 | 'Operating System :: OS Independent', 53 | 'License :: OSI Approved :: BSD License', 54 | 'Natural Language :: Portuguese (Brazilian)', 55 | 'Programming Language :: Python', 56 | 'Programming Language :: Python :: 3.6', 57 | 'Programming Language :: Python :: 3.5', 58 | 'Programming Language :: Python :: 3.4', 59 | 'Topic :: Office/Business :: Financial', 60 | 'Topic :: Software Development :: Libraries :: Python Modules', 61 | 'Framework :: Django', 62 | ], 63 | platforms='any', 64 | test_suite='tests.alltests.suite', 65 | install_requires=[ 66 | 'reportlab' 67 | ], 68 | tests_require=[ 69 | 'pylint', 70 | 'tox', 71 | 'coverage', 72 | 'pep8', 73 | 'sphinx-pypi-upload', 74 | 'sphinx' 75 | ] 76 | ) 77 | -------------------------------------------------------------------------------- /specs/BancoDoBrasil/Doc5175Bloqueto.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/BancoDoBrasil/Doc5175Bloqueto.pdf -------------------------------------------------------------------------------- /specs/BancoReal/COBRANCA_240_POSICOES.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/BancoReal/COBRANCA_240_POSICOES.pdf -------------------------------------------------------------------------------- /specs/BancoReal/COBRANCA_CARNES_400_POSICOES.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/BancoReal/COBRANCA_CARNES_400_POSICOES.pdf -------------------------------------------------------------------------------- /specs/Bradesco/Boleto_formulas_layout_bradesco.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Bradesco/Boleto_formulas_layout_bradesco.doc -------------------------------------------------------------------------------- /specs/Bradesco/Layout Cobranca e Boleto Completo BRADESCO_ATUALIZADO.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Bradesco/Layout Cobranca e Boleto Completo BRADESCO_ATUALIZADO.pdf -------------------------------------------------------------------------------- /specs/Bradesco/Layout_Bradesco_ArqRetorno.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Bradesco/Layout_Bradesco_ArqRetorno.pdf -------------------------------------------------------------------------------- /specs/Bradesco/Manual_BRADESCO.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Bradesco/Manual_BRADESCO.PDF -------------------------------------------------------------------------------- /specs/Caixa/CEF-SIGCB.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Caixa/CEF-SIGCB.doc -------------------------------------------------------------------------------- /specs/Caixa/CEF-SINCO Cnab240.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Caixa/CEF-SINCO Cnab240.pdf -------------------------------------------------------------------------------- /specs/Caixa/CNAB240_SINCO.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Caixa/CNAB240_SINCO.pdf -------------------------------------------------------------------------------- /specs/Caixa/Caixa Economica Federal - Cobranca.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Caixa/Caixa Economica Federal - Cobranca.doc -------------------------------------------------------------------------------- /specs/Caixa/Codigo_Barras_Bloquetos_Cobranca_sem_Registro_SINCO.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Caixa/Codigo_Barras_Bloquetos_Cobranca_sem_Registro_SINCO.pdf -------------------------------------------------------------------------------- /specs/Caixa/Manual Codigo de Barras.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Caixa/Manual Codigo de Barras.doc -------------------------------------------------------------------------------- /specs/Caixa/Manual_CAIXA.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Caixa/Manual_CAIXA.PDF -------------------------------------------------------------------------------- /specs/Febraban/layout240V0803.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Febraban/layout240V0803.pdf -------------------------------------------------------------------------------- /specs/Febraban/layoutRecebimentoCodigoBarrasv28052004.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Febraban/layoutRecebimentoCodigoBarrasv28052004.pdf -------------------------------------------------------------------------------- /specs/HSBC/cnr240-remessa.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/HSBC/cnr240-remessa.pdf -------------------------------------------------------------------------------- /specs/HSBC/cnr240.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/HSBC/cnr240.pdf -------------------------------------------------------------------------------- /specs/HSBC/cnrbarra.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/HSBC/cnrbarra.pdf -------------------------------------------------------------------------------- /specs/HSBC/cnrremes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/HSBC/cnrremes.pdf -------------------------------------------------------------------------------- /specs/HSBC/cnrretor.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/HSBC/cnrretor.pdf -------------------------------------------------------------------------------- /specs/HSBC/cob240.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/HSBC/cob240.pdf -------------------------------------------------------------------------------- /specs/HSBC/cob400_jan.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/HSBC/cob400_jan.pdf -------------------------------------------------------------------------------- /specs/HSBC/cobbarra.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/HSBC/cobbarra.pdf -------------------------------------------------------------------------------- /specs/Itau/cobranca_cnab240.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Itau/cobranca_cnab240.pdf -------------------------------------------------------------------------------- /specs/Santander/Layout de Cobrança - Código de Barras Santander Setembro 2012 v 2 3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Santander/Layout de Cobrança - Código de Barras Santander Setembro 2012 v 2 3.pdf -------------------------------------------------------------------------------- /specs/Sicoob/Layout Sicoob.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Sicoob/Layout Sicoob.xls -------------------------------------------------------------------------------- /specs/Sicredi/manual-cnab-240.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Sicredi/manual-cnab-240.pdf -------------------------------------------------------------------------------- /specs/Sicredi/manual-cnab-400.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/specs/Sicredi/manual-cnab-400.pdf -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trust-Code/python-boleto/48c7aad9bfcc44dad39643d9d95f3d6df3951e00/tests/__init__.py -------------------------------------------------------------------------------- /tests/test_banco_banrisul.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import datetime 3 | import unittest 4 | 5 | from pyboleto.bank.banrisul import BoletoBanrisul 6 | 7 | from .testutils import BoletoTestCase 8 | 9 | 10 | class TestBancoBanrisul(BoletoTestCase): 11 | def setUp(self): 12 | self.dados = [] 13 | for i in range(3): 14 | d = BoletoBanrisul() 15 | d.data_documento = datetime.date(2000, 7, 4) 16 | d.data_vencimento = datetime.date(2000, 7, 4) 17 | d.data_processamento = datetime.date(2012, 7, 11) 18 | d.valor_documento = 550 19 | d.agencia_cedente = '1102' 20 | d.conta_cedente = '9000150' 21 | d.convenio = 7777777 22 | d.nosso_numero = str(22832563 + i) 23 | d.numero_documento = str(22832563 + i) 24 | self.dados.append(d) 25 | 26 | def test_linha_digitavel(self): 27 | self.assertEqual( 28 | self.dados[0].linha_digitavel, 29 | '04192.11107 29000.150226 83256.340593 8 10010000055000' 30 | ) 31 | 32 | def test_tamanho_codigo_de_barras(self): 33 | self.assertEqual(len(self.dados[0].barcode), 44) 34 | 35 | def test_codigo_de_barras(self): 36 | self.assertEqual(self.dados[0].barcode, 37 | '04198100100000550002111029000150228325634059') 38 | 39 | def test_campo_livre(self): 40 | self.assertEqual(self.dados[0].campo_livre, 41 | '2111029000150228325634059') 42 | 43 | 44 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoBanrisul) 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | -------------------------------------------------------------------------------- /tests/test_banco_bradesco.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import unittest 3 | import datetime 4 | 5 | from pyboleto.bank.bradesco import BoletoBradesco 6 | 7 | from .testutils import BoletoTestCase 8 | 9 | 10 | class TestBancoBradesco(BoletoTestCase): 11 | def setUp(self): 12 | self.dados = [] 13 | for i in range(3): 14 | d = BoletoBradesco() 15 | d.carteira = '06' 16 | d.agencia_cedente = '278-0' 17 | d.conta_cedente = '039232-4' 18 | d.data_vencimento = datetime.date(2011, 2, 5) 19 | d.data_documento = datetime.date(2011, 1, 18) 20 | d.data_processamento = datetime.date(2011, 1, 18) 21 | d.valor_documento = 8280.00 22 | d.nosso_numero = str(2125525 + i) 23 | d.numero_documento = str(2125525 + i) 24 | self.dados.append(d) 25 | 26 | def test_linha_digitavel(self): 27 | self.assertEqual( 28 | self.dados[0].linha_digitavel, 29 | '23790.27804 60000.212559 25003.923205 4 48690000828000' 30 | ) 31 | 32 | def test_codigo_de_barras(self): 33 | self.assertEqual( 34 | self.dados[0].barcode, 35 | '23794486900008280000278060000212552500392320' 36 | ) 37 | 38 | def test_agencia(self): 39 | self.assertEqual(self.dados[0].agencia_cedente, '0278-0') 40 | 41 | def test_conta(self): 42 | self.assertEqual(self.dados[0].conta_cedente, '0039232-4') 43 | 44 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoBradesco) 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | -------------------------------------------------------------------------------- /tests/test_banco_caixa.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import unittest 3 | import datetime 4 | 5 | from pyboleto.bank.caixa import BoletoCaixa 6 | 7 | from .testutils import BoletoTestCase 8 | 9 | 10 | class TestBancoCaixa(BoletoTestCase): 11 | def setUp(self): 12 | self.dados = [] 13 | for i in range(3): 14 | d = BoletoCaixa() 15 | d.carteira = '1' 16 | d.agencia_cedente = '1565' 17 | d.conta_cedente = '52980' 18 | d.codigo_beneficiario = '123456' 19 | d.data_vencimento = datetime.date(2012, 7, 8) 20 | d.data_documento = datetime.date(2012, 7, 3) 21 | d.data_processamento = datetime.date(2012, 7, 3) 22 | d.valor_documento = 2952.95 23 | d.nosso_numero = str(8019525086 + i) 24 | d.numero_documento = str(270319510 + i) 25 | self.dados.append(d) 26 | 27 | def test_linha_digitavel(self): 28 | self.assertEqual( 29 | self.dados[0].linha_digitavel, 30 | '10491.23456 60000.100846 01952.508644 3 53880000295295' 31 | ) 32 | 33 | def test_tamanho_codigo_de_barras(self): 34 | self.assertEqual(len(self.dados[0].barcode), 44) 35 | 36 | def test_codigo_de_barras(self): 37 | self.assertEqual( 38 | self.dados[0].barcode, 39 | '10493538800002952951234560000100840195250864' 40 | ) 41 | 42 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoCaixa) 43 | 44 | 45 | if __name__ == '__main__': 46 | unittest.main() 47 | -------------------------------------------------------------------------------- /tests/test_banco_do_brasil.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import unittest 3 | import datetime 4 | 5 | from pyboleto.bank.bancodobrasil import BoletoBB 6 | 7 | from .testutils import BoletoTestCase 8 | 9 | 10 | class TestBancoBrasil(BoletoTestCase): 11 | def setUp(self): 12 | self.dados = [] 13 | for i in range(3): 14 | d = BoletoBB(7, 1) 15 | d.carteira = '18' 16 | d.data_documento = datetime.date(2011, 3, 8) 17 | d.data_vencimento = datetime.date(2011, 3, 8) 18 | d.data_processamento = datetime.date(2012, 7, 4) 19 | d.valor_documento = 2952.95 20 | d.agencia = '9999' 21 | d.conta = '99999' 22 | d.convenio = '7777777' 23 | d.nosso_numero = str(87654 + i) 24 | d.numero_documento = str(87654 + i) 25 | self.dados.append(d) 26 | 27 | def test_linha_digitavel(self): 28 | self.assertEqual( 29 | self.dados[0].linha_digitavel, 30 | '00190.00009 07777.777009 00087.654182 6 49000000295295' 31 | ) 32 | 33 | def test_codigo_de_barras(self): 34 | self.assertEqual( 35 | self.dados[0].barcode, 36 | '00196490000002952950000007777777000008765418' 37 | ) 38 | 39 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoBrasil) 40 | 41 | 42 | if __name__ == '__main__': 43 | unittest.main() 44 | -------------------------------------------------------------------------------- /tests/test_banco_hsbc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import unittest 3 | import datetime 4 | 5 | from pyboleto.bank.hsbc import BoletoHsbc 6 | 7 | from .testutils import BoletoTestCase 8 | 9 | 10 | class TestBancoHsbc(BoletoTestCase): 11 | def setUp(self): 12 | self.dados = [] 13 | for i in range(3): 14 | d = BoletoHsbc() 15 | d.agencia_cedente = '1172-0' 16 | d.conta_cedente = '3903036' 17 | d.data_vencimento = datetime.date(2009, 5, 25) 18 | d.data_documento = datetime.date(2009, 5, 25) 19 | d.data_processamento = datetime.date(2009, 5, 25) 20 | d.valor_documento = 35.00 21 | d.nosso_numero = str(100010103120 + i) 22 | d.numero_documento = str(100010103120 + i) 23 | self.dados.append(d) 24 | 25 | def test_linha_digitavel(self): 26 | self.assertEqual( 27 | self.dados[0].linha_digitavel, 28 | '39993.90309 36010.001018 03120.145929 3 42480000003500' 29 | ) 30 | 31 | def test_codigo_de_barras(self): 32 | self.assertEqual( 33 | self.dados[0].barcode, 34 | '39993424800000035003903036010001010312014592' 35 | ) 36 | 37 | def test_agencia(self): 38 | self.assertEqual(self.dados[0].agencia_cedente, '1172-0') 39 | 40 | def test_conta(self): 41 | self.assertEqual(self.dados[0].conta_cedente, '3903036') 42 | 43 | def test_nosso_numero(self): 44 | self.assertEqual( 45 | self.dados[0].format_nosso_numero(), 46 | '0100010103120947') 47 | 48 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoHsbc) 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /tests/test_banco_hsbc_com_registro.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import unittest 3 | import datetime 4 | 5 | from pyboleto.bank.hsbc import BoletoHsbcComRegistro 6 | 7 | from .testutils import BoletoTestCase 8 | 9 | 10 | class TestBancoHsbcComRegistro(BoletoTestCase): 11 | def setUp(self): 12 | self.dados = [] 13 | for i in range(3): 14 | d = BoletoHsbcComRegistro() 15 | d.agencia_cedente = '0141-4' 16 | d.conta_cedente = '5000252' 17 | d.data_vencimento = datetime.date(2010, 11, 6) 18 | d.data_documento = datetime.date(2010, 11, 6) 19 | d.data_processamento = datetime.date(2010, 11, 6) 20 | d.valor_documento = 335.85 21 | d.nosso_numero = str(1716057195 + i) 22 | d.numero_documento = str(1716057195 + i) 23 | self.dados.append(d) 24 | 25 | def test_linha_digitavel(self): 26 | self.assertEqual( 27 | self.dados[0].linha_digitavel, 28 | '39991.71600 57195.001417 50002.520018 1 47780000033585' 29 | ) 30 | 31 | def test_codigo_de_barras(self): 32 | self.assertEqual( 33 | self.dados[0].barcode, 34 | '39991477800000335851716057195001415000252001' 35 | ) 36 | 37 | def test_agencia(self): 38 | self.assertEqual(self.dados[0].agencia_cedente, '0141-4') 39 | 40 | def test_conta(self): 41 | self.assertEqual(self.dados[0].conta_cedente, '5000252') 42 | 43 | def test_dv_nosso_numero(self): 44 | self.assertEqual(self.dados[0].dv_nosso_numero, 0) 45 | 46 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoHsbcComRegistro) 47 | 48 | 49 | if __name__ == '__main__': 50 | unittest.main() 51 | -------------------------------------------------------------------------------- /tests/test_banco_itau.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import unittest 3 | import datetime 4 | 5 | from pyboleto.bank.itau import BoletoItau 6 | 7 | from .testutils import BoletoTestCase 8 | 9 | 10 | class TestBancoItau(BoletoTestCase): 11 | def setUp(self): 12 | self.dados = [] 13 | for i in range(3): 14 | d = BoletoItau() 15 | d.carteira = '109' 16 | d.agencia_cedente = '0293' 17 | d.conta_cedente = '01328' 18 | d.conta_cedente_dv = '1' 19 | d.data_vencimento = datetime.date(2009, 10, 19) 20 | d.data_documento = datetime.date(2009, 10, 19) 21 | d.data_processamento = datetime.date(2009, 10, 19) 22 | d.valor_documento = 29.80 23 | d.nosso_numero = str(157 + i) 24 | d.numero_documento = str(456 + i) 25 | self.dados.append(d) 26 | 27 | def test_linha_digitavel(self): 28 | self.assertEqual( 29 | self.dados[0].linha_digitavel, 30 | '34191.09008 00015.710296 30132.810000 4 43950000002980' 31 | ) 32 | 33 | def test_codigo_de_barras(self): 34 | self.assertEqual( 35 | self.dados[0].barcode, 36 | '34194439500000029801090000015710293013281000' 37 | ) 38 | 39 | def test_agencia(self): 40 | self.assertEqual(self.dados[0].agencia_cedente, '0293') 41 | 42 | def test_conta(self): 43 | self.assertEqual(self.dados[0].conta_cedente, '01328') 44 | 45 | def test_dv_nosso_numero(self): 46 | self.assertEqual(self.dados[0].dv_nosso_numero, 1) 47 | 48 | def test_dv_agencia_conta_cedente(self): 49 | self.assertEqual(self.dados[0].dv_agencia_conta_cedente, 0) 50 | 51 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoItau) 52 | 53 | if __name__ == '__main__': 54 | unittest.main() 55 | -------------------------------------------------------------------------------- /tests/test_banco_santander.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import unittest 3 | import datetime 4 | 5 | from pyboleto.bank.santander import BoletoSantander 6 | 7 | from .testutils import BoletoTestCase 8 | 9 | 10 | class TestBancoSantander(BoletoTestCase): 11 | def setUp(self): 12 | self.dados = [] 13 | for i in range(3): 14 | d = BoletoSantander() 15 | d.agencia_cedente = '1333' 16 | d.conta_cedente = '0707077' 17 | d.data_vencimento = datetime.date(2012, 7, 22) 18 | d.data_documento = datetime.date(2012, 7, 17) 19 | d.data_processamento = datetime.date(2012, 7, 17) 20 | d.valor_documento = 2952.95 21 | d.nosso_numero = str(1234567 + i) 22 | d.numero_documento = str(12345 + i) 23 | d.ios = '0' 24 | self.dados.append(d) 25 | 26 | def test_linha_digitavel(self): 27 | self.assertEqual( 28 | self.dados[0].linha_digitavel, 29 | '03399.07073 07700.000123 34567.901029 5 54020000295295' 30 | ) 31 | 32 | def test_codigo_de_barras(self): 33 | self.assertEqual( 34 | self.dados[0].barcode, 35 | '03395540200002952959070707700000123456790102' 36 | ) 37 | 38 | def test_agencia(self): 39 | self.assertEqual(self.dados[0].agencia_cedente, '1333') 40 | 41 | def test_nosso_numero(self): 42 | self.assertEqual(self.dados[0].nosso_numero, '000001234567') 43 | self.assertEqual(self.dados[0].format_nosso_numero(), '000001234567-9') 44 | 45 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoSantander) 46 | 47 | 48 | if __name__ == '__main__': 49 | unittest.main() 50 | -------------------------------------------------------------------------------- /tests/test_banco_sicoob.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import unittest 3 | import datetime 4 | 5 | from pyboleto.bank.sicoob import BoletoSicoob 6 | 7 | from .testutils import BoletoTestCase 8 | 9 | 10 | class TestBancoSicoob(BoletoTestCase): 11 | def setUp(self): 12 | self.dados = [] 13 | for i in range(3): 14 | d = BoletoSicoob() 15 | d.carteira = '1' 16 | d.agencia_cedente = '3069' 17 | d.conta_cedente = '84725' 18 | d.codigo_beneficiario = '225' 19 | d.data_vencimento = datetime.date(2016, 5, 6) 20 | d.data_documento = datetime.date(2016, 4, 8) 21 | d.data_processamento = datetime.date(2016, 4, 8) 22 | d.valor_documento = 97.50 23 | d.nosso_numero = '3' 24 | d.numero_documento = '1212/1' 25 | self.dados.append(d) 26 | 27 | @unittest.skip("Não Implementado") 28 | def test_linha_digitavel(self): 29 | self.assertEqual( 30 | self.dados[0].linha_digitavel, 31 | '75693.30694 03000.022503 00000.350017 3 67860000009750' 32 | ) 33 | 34 | def test_agencia(self): 35 | self.assertEqual(self.dados[0].agencia_cedente, '3069') 36 | 37 | def test_conta(self): 38 | self.assertEqual(self.dados[0].conta_cedente, '84725'.zfill(6)) 39 | 40 | def test_dv_nosso_numero(self): 41 | self.assertEqual(self.dados[0].dv_nosso_numero, 5) 42 | 43 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoSicoob) 44 | 45 | if __name__ == '__main__': 46 | unittest.main() 47 | -------------------------------------------------------------------------------- /tests/test_banco_sicredi.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import unittest 3 | import datetime 4 | 5 | from pyboleto.bank.sicredi import BoletoSicredi 6 | 7 | from .testutils import BoletoTestCase 8 | 9 | 10 | class TestBancoSicredi(BoletoTestCase): 11 | def setUp(self): 12 | self.dados = [] 13 | for i in range(3): 14 | d = BoletoSicredi() 15 | d.carteira = '1' 16 | d.posto = '08' 17 | d.aceite = 'Sim' 18 | d.especie_documento = 'DI' 19 | d.agencia_cedente = '0434' 20 | d.conta_cedente = '36699' 21 | d.data_vencimento = datetime.date(2018, 1, 25) 22 | d.data_documento = datetime.date(2017, 11, 24) 23 | d.data_processamento = datetime.date(2017, 11, 24) 24 | d.valor_documento = 90.75 25 | d.nosso_numero = '18324121' 26 | d.numero_documento = '33287-1/12' 27 | self.dados.append(d) 28 | 29 | def test_linha_digitavel(self): 30 | self.assertEqual( 31 | self.dados[0].linha_digitavel, 32 | '74891.11836 24121.904346 08366.991068 1 74150000009075' 33 | ) 34 | 35 | def test_codigo_de_barras(self): 36 | self.assertEqual( 37 | self.dados[0].barcode, 38 | '74891741500000090751118324121904340836699106' 39 | ) 40 | 41 | def test_agencia(self): 42 | self.assertEqual(self.dados[0].agencia_cedente, '0434') 43 | 44 | def test_conta(self): 45 | self.assertEqual(self.dados[0].conta_cedente, '36699') 46 | 47 | def test_dv_nosso_numero(self): 48 | self.assertEqual(self.dados[0].dv_nosso_numero, 9) 49 | 50 | 51 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoSicredi) 52 | 53 | if __name__ == '__main__': 54 | unittest.main() 55 | -------------------------------------------------------------------------------- /tests/testutils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import with_statement 3 | 4 | import difflib 5 | import fnmatch 6 | import os 7 | import re 8 | import subprocess 9 | import tempfile 10 | import unittest 11 | 12 | from xml.etree.ElementTree import fromstring, tostring 13 | 14 | import pyboleto 15 | from pyboleto.pdf import BoletoPDF 16 | from pyboleto.html import BoletoHTML 17 | 18 | 19 | def list_recursively(directory, pattern): 20 | """Returns files recursively from directory matching pattern 21 | :param directory: directory to list 22 | :param pattern: glob mattern to match 23 | """ 24 | matches = [] 25 | for root, _, filenames in os.walk(directory): 26 | for filename in fnmatch.filter(filenames, pattern): 27 | # skip backup files 28 | if (filename.startswith('.#') or 29 | filename.endswith('~')): 30 | continue 31 | matches.append(os.path.join(root, filename)) 32 | return matches 33 | 34 | 35 | def get_sources(root): 36 | for dirpath in ['pyboleto', 'tests']: 37 | path = os.path.join(root, dirpath) 38 | for fname in list_recursively(path, '*.py'): 39 | if fname.endswith('__init__.py'): 40 | continue 41 | yield fname 42 | 43 | # yield os.path.join(root, 'setup.py') 44 | 45 | 46 | def _diff(orig, new, short, verbose): 47 | lines = difflib.unified_diff(orig, new) 48 | if not lines: 49 | return '' 50 | 51 | return ''.join('%s: %s' % (short, line) for line in lines) 52 | 53 | 54 | def diff_files(orig, new, verbose=False): 55 | with open(orig) as f_orig: 56 | with open(new) as f_new: 57 | return _diff(f_orig.readlines(), 58 | f_new.readlines(), 59 | short=os.path.basename(orig), 60 | verbose=verbose) 61 | 62 | 63 | def diff_pdf_htmls(original_filename, filename): 64 | # REPLACE all generated dates with %%DATE%% 65 | for fname in [original_filename, filename]: 66 | with open(fname) as f: 67 | data = f.read() 68 | data = re.sub(r'name="date" content="(.*)"', 69 | r'name="date" content="%%DATE%%"', data) 70 | data = re.sub(r']+>', r'', data) 71 | with open(fname, 'w') as f: 72 | f.write(data) 73 | 74 | return diff_files(original_filename, filename) 75 | 76 | 77 | class ClassInittableMetaType(type): 78 | # pylint fails to understand this is a metaclass 79 | def __init__(self, name, bases, namespace): 80 | type.__init__(self, name, bases, namespace) 81 | self.__class_init__(namespace) 82 | 83 | 84 | class SourceTest(object): 85 | __metaclass__ = ClassInittableMetaType 86 | 87 | @classmethod 88 | def __class_init__(cls, namespace): 89 | root = os.path.dirname(os.path.dirname(pyboleto.__file__)) 90 | cls.root = root 91 | for filename in get_sources(root): 92 | testname = filename[len(root):] 93 | if not cls.filename_filter(testname): 94 | continue 95 | testname = testname[:-3].replace('/', '_') 96 | name = 'test_%s' % (testname, ) 97 | # func = lambda self, r=root, f=filename: self.check_filename(r, f) 98 | 99 | def func(self, r=root, f=filename): 100 | self.check_filename(r, f) 101 | func.__name__ = name 102 | setattr(cls, name, func) 103 | 104 | def check_filename(self, root, filename): 105 | pass 106 | 107 | @classmethod 108 | def filename_filter(cls, filename): 109 | if cls.__name__ == 'SourceTest': 110 | return False 111 | else: 112 | return True 113 | 114 | 115 | def indent(elem, level=0): 116 | i = "\n" + level * " " 117 | if len(elem): 118 | if not elem.text or not elem.text.strip(): 119 | elem.text = i + " " 120 | if not elem.tail or not elem.tail.strip(): 121 | elem.tail = i 122 | for elem in elem: 123 | indent(elem, level + 1) 124 | if not elem.tail or not elem.tail.strip(): 125 | elem.tail = i 126 | else: 127 | if level and (not elem.tail or not elem.tail.strip()): 128 | elem.tail = i 129 | 130 | 131 | def pdftoxml(filename, output): 132 | p = subprocess.Popen(['pdftohtml', 133 | '-stdout', 134 | '-xml', 135 | '-noframes', 136 | '-i', 137 | '-q', 138 | filename], 139 | stdout=subprocess.PIPE) 140 | stdout, stderr = p.communicate() 141 | if stderr: 142 | raise SystemExit("Error while runnig pdftohtml: %s" % (stderr, )) 143 | 144 | root = fromstring(stdout) 145 | indent(root) 146 | with open(output, 'wb') as f: 147 | f.write(tostring(root)) 148 | 149 | 150 | class BoletoTestCase(unittest.TestCase): 151 | def _get_expected(self, bank, generated, f_type='xml'): 152 | fname = os.path.join( 153 | os.path.dirname(pyboleto.__file__), 154 | "..", "tests", f_type, bank + '-expected.' + f_type) 155 | if not os.path.exists(fname): 156 | with open(fname, 'wb') as f: 157 | with open(generated) as g: 158 | f.write(g.read()) 159 | return fname 160 | 161 | def test_pdf_triplo_rendering(self): 162 | if "dados" not in dir(self): 163 | return 164 | bank = type(self.dados[0]).__name__ 165 | filename = tempfile.mktemp(prefix="pyboleto-triplo-", 166 | suffix=".pdf") 167 | boleto = BoletoPDF(filename, True) 168 | for d in self.dados: 169 | boleto.drawBoleto(d) 170 | boleto.nextPage() 171 | boleto.save() 172 | 173 | generated = filename + '.xml' 174 | pdftoxml(filename, generated) 175 | expected = self._get_expected('Triplo-' + bank, generated) 176 | diff = diff_pdf_htmls(expected, generated) 177 | os.unlink(generated) 178 | 179 | os.unlink(filename) 180 | if diff: 181 | self.fail("Error while checking xml for %r:\n%s" % ( 182 | bank, diff)) 183 | 184 | def test_pdf_rendering(self): 185 | if "dados" not in dir(self): 186 | return 187 | dados = self.dados[0] 188 | bank = type(dados).__name__ 189 | filename = tempfile.mktemp(prefix="pyboleto-", 190 | suffix=".pdf") 191 | boleto = BoletoPDF(filename, True) 192 | boleto.drawBoleto(dados) 193 | boleto.nextPage() 194 | boleto.save() 195 | 196 | generated = filename + '.xml' 197 | pdftoxml(filename, generated) 198 | expected = self._get_expected(bank, generated) 199 | diff = diff_pdf_htmls(expected, generated) 200 | os.unlink(generated) 201 | os.unlink(filename) 202 | if diff: 203 | self.fail("Error while checking xml for %r:\n%s" % ( 204 | bank, diff)) 205 | 206 | def test_html_rendering(self): 207 | if "dados" not in dir(self): 208 | return 209 | dados = self.dados[0] 210 | bank = type(dados).__name__ 211 | filename = tempfile.mktemp(prefix="pyboleto-", 212 | suffix=".html") 213 | boleto = BoletoHTML(filename, False) 214 | boleto.drawBoleto(dados) 215 | boleto.nextPage() 216 | boleto.save() 217 | 218 | generated = filename 219 | expected = self._get_expected(bank, generated, f_type='html') 220 | diff = diff_files(expected, generated) 221 | os.unlink(generated) 222 | 223 | if diff: 224 | self.fail("Error while checking xml for %r:\n%s" % ( 225 | bank, diff)) 226 | -------------------------------------------------------------------------------- /tests/xml/BoletoBB-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Autenticação Mecânica / Ficha de Compensação 8 | Código de baixa 9 | Sacador / Avalista 10 | Pagador 11 | - CPF/CNPJ: 12 | - - - 13 | (=) Valor cobrado 14 | (+) Outros acréscimos 15 | (+) Mora/Multa 16 | (-) Outras deduções 17 | (-) Descontos/Abatimentos 18 | Instruções 19 | Uso do banco 20 | Carteira 21 | Espécie 22 | Quantidade 23 | Valor 24 | (=) Valor documento 25 | 18 26 | R$ 27 | 2952,95 28 | Data do documento 29 | N. do documento 30 | Espécie doc 31 | Aceite 32 | Data processamento 33 | Nosso número 34 | 08/03/2011 35 | 87654 36 | N 37 | 04/07/2012 38 | 77777770000087654 39 | Beneficiário 40 | Agência/Código beneficiário 41 | - CPF/CNPJ: 42 | - - - - 43 | 0000-0 / 00000000-0 44 | Local de pagamento 45 | Vencimento 46 | Pagável em qualquer banco até o vencimento. Após, atualize o boleto no site bb.com.br 47 | 08/03/2011 48 | 49 | 001-9 50 | 51 | 52 | 00190.00009 07777.777009 00087.654182 6 49000000295295 53 | 54 | 55 | 001-9 56 | 57 | 58 | Recibo do Pagador 59 | 60 | Autenticação Mecânica 61 | Beneficiário 62 | Agência/Código Beneficiário 63 | CPF/CNPJ Beneficiário 64 | Vencimento 65 | Pagador 66 | Nosso Número 67 | N. do documento 68 | Data Documento 69 | Endereço Beneficiário 70 | Valor Documento 71 | Demonstrativo 72 | 0000-0 / 00000000-0 73 | 08/03/2011 74 | - CPF/CNPJ: 75 | 77777770000087654 76 | 87654 77 | 08/03/2011 78 | - - - - 79 | 2952,95 80 | 81 | 82 | -------------------------------------------------------------------------------- /tests/xml/BoletoBanrisul-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Autenticação Mecânica / Ficha de Compensação 8 | Código de baixa 9 | Sacador / Avalista 10 | Pagador 11 | - CPF/CNPJ: 12 | - - - 13 | (=) Valor cobrado 14 | (+) Outros acréscimos 15 | (+) Mora/Multa 16 | (-) Outras deduções 17 | (-) Descontos/Abatimentos 18 | Instruções 19 | Uso do banco 20 | Carteira 21 | Espécie 22 | Quantidade 23 | Valor 24 | (=) Valor documento 25 | R$ 26 | 550,00 27 | Data do documento 28 | N. do documento 29 | Espécie doc 30 | Aceite 31 | Data processamento 32 | Nosso número 33 | 04/07/2000 34 | 22832563 35 | N 36 | 11/07/2012 37 | 22832563 38 | Beneficiário 39 | Agência/Código beneficiário 40 | - CPF/CNPJ: 41 | - - - - 42 | 1102/9000150 43 | Local de pagamento 44 | Vencimento 45 | Pagável em qualquer banco até o vencimento 46 | 04/07/2000 47 | 48 | 041-8 49 | 50 | 51 | 04192.11107 29000.150226 83256.340593 8 10010000055000 52 | 53 | 54 | 041-8 55 | 56 | 57 | Recibo do Pagador 58 | 59 | Autenticação Mecânica 60 | Beneficiário 61 | Agência/Código Beneficiário 62 | CPF/CNPJ Beneficiário 63 | Vencimento 64 | Pagador 65 | Nosso Número 66 | N. do documento 67 | Data Documento 68 | Endereço Beneficiário 69 | Valor Documento 70 | Demonstrativo 71 | 1102/9000150 72 | 04/07/2000 73 | - CPF/CNPJ: 74 | 22832563 75 | 22832563 76 | 04/07/2000 77 | - - - - 78 | 550,00 79 | 80 | 81 | -------------------------------------------------------------------------------- /tests/xml/BoletoBradesco-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Autenticação Mecânica / Ficha de Compensação 8 | Código de baixa 9 | Sacador / Avalista 10 | Pagador 11 | - CPF/CNPJ: 12 | - - - 13 | (=) Valor cobrado 14 | (+) Outros acréscimos 15 | (+) Mora/Multa 16 | (-) Outras deduções 17 | (-) Descontos/Abatimentos 18 | Instruções 19 | Uso do banco 20 | Carteira 21 | Espécie 22 | Quantidade 23 | Valor 24 | (=) Valor documento 25 | 06 26 | R$ 27 | 8280,00 28 | Data do documento 29 | N. do documento 30 | Espécie doc 31 | Aceite 32 | Data processamento 33 | Nosso número 34 | 18/01/2011 35 | 2125525 36 | N 37 | 18/01/2011 38 | 06/00002125525-6 39 | Beneficiário 40 | Agência/Código beneficiário 41 | - CPF/CNPJ: 42 | - - - - 43 | 0278-0/0039232-4 44 | Local de pagamento 45 | Vencimento 46 | Pagável Preferencialmente na Rede Bradesco ou Bradesco Expresso. 47 | 05/02/2011 48 | 49 | 237-2 50 | 51 | 52 | 23790.27804 60000.212559 25003.923205 4 48690000828000 53 | 54 | 55 | 237-2 56 | 57 | 58 | Recibo do Pagador 59 | 60 | Autenticação Mecânica 61 | Beneficiário 62 | Agência/Código Beneficiário 63 | CPF/CNPJ Beneficiário 64 | Vencimento 65 | Pagador 66 | Nosso Número 67 | N. do documento 68 | Data Documento 69 | Endereço Beneficiário 70 | Valor Documento 71 | Demonstrativo 72 | 0278-0/0039232-4 73 | 05/02/2011 74 | - CPF/CNPJ: 75 | 06/00002125525-6 76 | 2125525 77 | 18/01/2011 78 | - - - - 79 | 8280,00 80 | 81 | 82 | -------------------------------------------------------------------------------- /tests/xml/BoletoCaixa-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Autenticação Mecânica / Ficha de Compensação 8 | Código de baixa 9 | Sacador / Avalista 10 | Pagador 11 | - CPF/CNPJ: 12 | - - - 13 | (=) Valor cobrado 14 | (+) Outros acréscimos 15 | (+) Mora/Multa 16 | (-) Outras deduções 17 | (-) Descontos/Abatimentos 18 | Instruções 19 | Uso do banco 20 | Carteira 21 | Espécie 22 | Quantidade 23 | Valor 24 | (=) Valor documento 25 | 1 26 | R$ 27 | 2952,95 28 | Data do documento 29 | N. do documento 30 | Espécie doc 31 | Aceite 32 | Data processamento 33 | Nosso número 34 | 03/07/2012 35 | 270319510 36 | N 37 | 03/07/2012 38 | 14000008019525086-2 39 | Beneficiário 40 | Agência/Código beneficiário 41 | - CPF/CNPJ: 42 | - - - - 43 | 1565/123456-0 44 | Local de pagamento 45 | Vencimento 46 | Preferencialmente nas Casas Lotéricas e Agências da Caixa 47 | 08/07/2012 48 | 49 | 104-0 50 | 51 | 52 | 10491.23456 60000.100846 01952.508644 3 53880000295295 53 | 54 | 55 | 104-0 56 | 57 | 58 | Recibo do Pagador 59 | 60 | Autenticação Mecânica 61 | Beneficiário 62 | Agência/Código Beneficiário 63 | CPF/CNPJ Beneficiário 64 | Vencimento 65 | Pagador 66 | Nosso Número 67 | N. do documento 68 | Data Documento 69 | Endereço Beneficiário 70 | Valor Documento 71 | Demonstrativo 72 | 1565/123456-0 73 | 08/07/2012 74 | - CPF/CNPJ: 75 | 14000008019525086-2 76 | 270319510 77 | 03/07/2012 78 | - - - - 79 | 2952,95 80 | 81 | 82 | -------------------------------------------------------------------------------- /tests/xml/BoletoHsbc-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Autenticação Mecânica / Ficha de Compensação 8 | Código de baixa 9 | Sacador / Avalista 10 | Pagador 11 | - CPF/CNPJ: 12 | - - - 13 | (=) Valor cobrado 14 | (+) Outros acréscimos 15 | (+) Mora/Multa 16 | (-) Outras deduções 17 | (-) Descontos/Abatimentos 18 | Instruções 19 | Uso do banco 20 | Carteira 21 | Espécie 22 | Quantidade 23 | Valor 24 | (=) Valor documento 25 | CNR 26 | R$ 27 | 35,00 28 | Data do documento 29 | N. do documento 30 | Espécie doc 31 | Aceite 32 | Data processamento 33 | Nosso número 34 | 25/05/2009 35 | 0100010103120 36 | N 37 | 25/05/2009 38 | 0100010103120947 39 | Beneficiário 40 | Agência/Código beneficiário 41 | - CPF/CNPJ: 42 | - - - - 43 | 1172-0/3903036 44 | Local de pagamento 45 | Vencimento 46 | Pagável em qualquer banco até o vencimento 47 | 25/05/2009 48 | 49 | 399-9 50 | 51 | 52 | 39993.90309 36010.001018 03120.145929 3 42480000003500 53 | 54 | 55 | 399-9 56 | 57 | 58 | Recibo do Pagador 59 | 60 | Autenticação Mecânica 61 | Beneficiário 62 | Agência/Código Beneficiário 63 | CPF/CNPJ Beneficiário 64 | Vencimento 65 | Pagador 66 | Nosso Número 67 | N. do documento 68 | Data Documento 69 | Endereço Beneficiário 70 | Valor Documento 71 | Demonstrativo 72 | 1172-0/3903036 73 | 25/05/2009 74 | - CPF/CNPJ: 75 | 0100010103120947 76 | 0100010103120 77 | 25/05/2009 78 | - - - - 79 | 35,00 80 | 81 | 82 | -------------------------------------------------------------------------------- /tests/xml/BoletoHsbcComRegistro-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Autenticação Mecânica / Ficha de Compensação 8 | Código de baixa 9 | Sacador / Avalista 10 | Pagador 11 | - CPF/CNPJ: 12 | - - - 13 | (=) Valor cobrado 14 | (+) Outros acréscimos 15 | (+) Mora/Multa 16 | (-) Outras deduções 17 | (-) Descontos/Abatimentos 18 | Instruções 19 | Uso do banco 20 | Carteira 21 | Espécie 22 | Quantidade 23 | Valor 24 | (=) Valor documento 25 | CSB 26 | R$ 27 | 335,85 28 | Data do documento 29 | N. do documento 30 | Espécie doc 31 | Aceite 32 | Data processamento 33 | Nosso número 34 | 06/11/2010 35 | 1716057195 36 | PD 37 | N 38 | 06/11/2010 39 | 1716057195 40 | Beneficiário 41 | Agência/Código beneficiário 42 | - CPF/CNPJ: 43 | - - - - 44 | 0141-4/5000252 45 | Local de pagamento 46 | Vencimento 47 | Pagável em qualquer banco até o vencimento 48 | 06/11/2010 49 | 50 | 399-9 51 | 52 | 53 | 39991.71600 57195.001417 50002.520018 1 47780000033585 54 | 55 | 56 | 399-9 57 | 58 | 59 | Recibo do Pagador 60 | 61 | Autenticação Mecânica 62 | Beneficiário 63 | Agência/Código Beneficiário 64 | CPF/CNPJ Beneficiário 65 | Vencimento 66 | Pagador 67 | Nosso Número 68 | N. do documento 69 | Data Documento 70 | Endereço Beneficiário 71 | Valor Documento 72 | Demonstrativo 73 | 0141-4/5000252 74 | 06/11/2010 75 | - CPF/CNPJ: 76 | 1716057195 77 | 1716057195 78 | 06/11/2010 79 | - - - - 80 | 335,85 81 | 82 | 83 | -------------------------------------------------------------------------------- /tests/xml/BoletoItau-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Autenticação Mecânica / Ficha de Compensação 8 | Código de baixa 9 | Sacador / Avalista 10 | Pagador 11 | - CPF/CNPJ: 12 | - - - 13 | (=) Valor cobrado 14 | (+) Outros acréscimos 15 | (+) Mora/Multa 16 | (-) Outras deduções 17 | (-) Descontos/Abatimentos 18 | Instruções 19 | Uso do banco 20 | Carteira 21 | Espécie 22 | Quantidade 23 | Valor 24 | (=) Valor documento 25 | 109 26 | R$ 27 | 29,80 28 | Data do documento 29 | N. do documento 30 | Espécie doc 31 | Aceite 32 | Data processamento 33 | Nosso número 34 | 19/10/2009 35 | 456 36 | DM 37 | N 38 | 19/10/2009 39 | 109/00000157-1 40 | Beneficiário 41 | Agência/Código beneficiário 42 | - CPF/CNPJ: 43 | - - - - 44 | 0293/01328-1 45 | Local de pagamento 46 | Vencimento 47 | Até o vencimento, preferencialmente no Itaú. Após o vencimento, somente no Itaú 48 | 19/10/2009 49 | 50 | 341-7 51 | 52 | 53 | 34191.09008 00015.710296 30132.810000 4 43950000002980 54 | 55 | 56 | 341-7 57 | 58 | 59 | Recibo do Pagador 60 | 61 | Autenticação Mecânica 62 | Beneficiário 63 | Agência/Código Beneficiário 64 | CPF/CNPJ Beneficiário 65 | Vencimento 66 | Pagador 67 | Nosso Número 68 | N. do documento 69 | Data Documento 70 | Endereço Beneficiário 71 | Valor Documento 72 | Demonstrativo 73 | 0293/01328-1 74 | 19/10/2009 75 | - CPF/CNPJ: 76 | 109/00000157-1 77 | 456 78 | 19/10/2009 79 | - - - - 80 | 29,80 81 | 82 | 83 | -------------------------------------------------------------------------------- /tests/xml/BoletoSantander-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Autenticação Mecânica / Ficha de Compensação 8 | Código de baixa 9 | Sacador / Avalista 10 | Pagador 11 | - CPF/CNPJ: 12 | - - - 13 | (=) Valor cobrado 14 | (+) Outros acréscimos 15 | (+) Mora/Multa 16 | (-) Outras deduções 17 | (-) Descontos/Abatimentos 18 | Instruções 19 | Uso do banco 20 | Carteira 21 | Espécie 22 | Quantidade 23 | Valor 24 | (=) Valor documento 25 | 102 26 | R$ 27 | 2952,95 28 | Data do documento 29 | N. do documento 30 | Espécie doc 31 | Aceite 32 | Data processamento 33 | Nosso número 34 | 17/07/2012 35 | 12345 36 | N 37 | 17/07/2012 38 | 000001234567-9 39 | Beneficiário 40 | Agência/Código beneficiário 41 | - CPF/CNPJ: 42 | - - - - 43 | 1333/0707077 44 | Local de pagamento 45 | Vencimento 46 | Pagável em qualquer banco até o vencimento 47 | 22/07/2012 48 | 49 | 033-7 50 | 51 | 52 | 03399.07073 07700.000123 34567.901029 5 54020000295295 53 | 54 | 55 | 033-7 56 | 57 | 58 | Recibo do Pagador 59 | 60 | Autenticação Mecânica 61 | Beneficiário 62 | Agência/Código Beneficiário 63 | CPF/CNPJ Beneficiário 64 | Vencimento 65 | Pagador 66 | Nosso Número 67 | N. do documento 68 | Data Documento 69 | Endereço Beneficiário 70 | Valor Documento 71 | Demonstrativo 72 | 1333/0707077 73 | 22/07/2012 74 | - CPF/CNPJ: 75 | 000001234567-9 76 | 12345 77 | 17/07/2012 78 | - - - - 79 | 2952,95 80 | 81 | 82 | -------------------------------------------------------------------------------- /tests/xml/BoletoSicoob-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Autenticação Mecânica / Ficha de Compensação 8 | Código de baixa 9 | Sacador / Avalista 10 | Pagador 11 | - CPF/CNPJ: 12 | - - - 13 | (=) Valor cobrado 14 | (+) Outros acréscimos 15 | (+) Mora/Multa 16 | (-) Outras deduções 17 | (-) Descontos/Abatimentos 18 | Instruções 19 | Uso do banco 20 | Carteira 21 | Espécie 22 | Quantidade 23 | Valor 24 | (=) Valor documento 25 | 1 26 | R$ 27 | 97,50 28 | Data do documento 29 | N. do documento 30 | Espécie doc 31 | Aceite 32 | Data processamento 33 | Nosso número 34 | 08/04/2016 35 | 1212/1 36 | DM 37 | N 38 | 08/04/2016 39 | 0000003-5 40 | Beneficiário 41 | Coop Contr/Cód Beneficiário 42 | - CPF/CNPJ: 43 | - - - - 44 | 3069/0000225 45 | Local de pagamento 46 | Vencimento 47 | Pagável Preferencialmente nas Cooperativas da Rede Sicoob ou Qualquer Banco até o Vencimento. 48 | 06/05/2016 49 | 50 | 756 51 | 52 | 53 | 75691.30698 01000.022507 00000.350017 4 67860000009750 54 | 55 | 56 | 756 57 | 58 | 59 | Recibo do Pagador 60 | 61 | Autenticação Mecânica 62 | Beneficiário 63 | Agência/Código Beneficiário 64 | CPF/CNPJ Beneficiário 65 | Vencimento 66 | Pagador 67 | Nosso Número 68 | N. do documento 69 | Data Documento 70 | Endereço Beneficiário 71 | Valor Documento 72 | Demonstrativo 73 | 3069/0000225 74 | 06/05/2016 75 | - CPF/CNPJ: 76 | 0000003-5 77 | 1212/1 78 | 08/04/2016 79 | - - - - 80 | 97,50 81 | 82 | 83 | -------------------------------------------------------------------------------- /tests/xml/BoletoSicredi-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Autenticação Mecânica / Ficha de Compensação 8 | Código de baixa 9 | Sacador / Avalista 10 | Pagador 11 | - CPF/CNPJ: 12 | - - - 13 | (=) Valor cobrado 14 | (+) Outros acréscimos 15 | (+) Mora/Multa 16 | (-) Outras deduções 17 | (-) Descontos/Abatimentos 18 | Instruções 19 | Uso do banco 20 | Carteira 21 | Espécie 22 | Quantidade 23 | Valor 24 | (=) Valor documento 25 | 1 26 | R$ 27 | 90,75 28 | Data do documento 29 | N. do documento 30 | Espécie doc 31 | Aceite 32 | Data processamento 33 | Nosso número 34 | 24/11/2017 35 | 33287-1/12 36 | DI 37 | Sim 38 | 24/11/2017 39 | 18/324121-9 40 | Beneficiário 41 | Agência/Código beneficiário 42 | - CPF/CNPJ: 43 | - - - - 44 | 0434/36699 45 | Local de pagamento 46 | Vencimento 47 | Pagável prefencialmente nas Coop. de Crédito Sicredi 48 | 25/01/2018 49 | 50 | 748-0 51 | 52 | 53 | 74891.11836 24121.904346 08366.991068 1 74150000009075 54 | 55 | 56 | 748-0 57 | 58 | 59 | Recibo do Pagador 60 | 61 | Autenticação Mecânica 62 | Beneficiário 63 | Agência/Código Beneficiário 64 | CPF/CNPJ Beneficiário 65 | Vencimento 66 | Pagador 67 | Nosso Número 68 | N. do documento 69 | Data Documento 70 | Endereço Beneficiário 71 | Valor Documento 72 | Demonstrativo 73 | 0434/36699 74 | 25/01/2018 75 | - CPF/CNPJ: 76 | 18/324121-9 77 | 33287-1/12 78 | 24/11/2017 79 | - - - - 80 | 90,75 81 | 82 | 83 | -------------------------------------------------------------------------------- /tests/xml/Triplo-BoletoSicoob-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Autenticação Mecânica / Ficha de Compensação 8 | Código de baixa 9 | Sacador / Avalista 10 | Pagador 11 | - CPF/CNPJ: 12 | - - - 13 | (=) Valor cobrado 14 | (+) Outros acréscimos 15 | (+) Mora/Multa 16 | (-) Outras deduções 17 | (-) Descontos/Abatimentos 18 | Instruções 19 | Uso do banco 20 | Carteira 21 | Espécie 22 | Quantidade 23 | Valor 24 | (=) Valor documento 25 | 1 26 | R$ 27 | 97,50 28 | Data do documento 29 | N. do documento 30 | Espécie doc 31 | Aceite 32 | Data processamento 33 | Nosso número 34 | 08/04/2016 35 | 1212/1 36 | DM 37 | N 38 | 08/04/2016 39 | 0000003-5 40 | Beneficiário 41 | Coop Contr/Cód Beneficiário 42 | - CPF/CNPJ: 43 | - - - - 44 | 3069/0000225 45 | Local de pagamento 46 | Vencimento 47 | Pagável Preferencialmente nas Cooperativas da Rede Sicoob ou Qualquer Banco até o Vencimento. 48 | 06/05/2016 49 | 50 | 756 51 | 52 | 53 | 75691.30698 01000.022507 00000.350017 4 67860000009750 54 | 55 | 56 | 756 57 | 58 | 59 | Recibo do Pagador 60 | 61 | Autenticação Mecânica 62 | Beneficiário 63 | Agência/Código Beneficiário 64 | CPF/CNPJ Beneficiário 65 | Vencimento 66 | Pagador 67 | Nosso Número 68 | N. do documento 69 | Data Documento 70 | Endereço Beneficiário 71 | Valor Documento 72 | Demonstrativo 73 | 3069/0000225 74 | 06/05/2016 75 | - CPF/CNPJ: 76 | 0000003-5 77 | 1212/1 78 | 08/04/2016 79 | - - - - 80 | 97,50 81 | 82 | 83 | --------------------------------------------------------------------------------