├── .gitignore ├── .travis.yml ├── LICENSE ├── MANIFEST.in ├── README.rst ├── bin ├── html_pyboleto_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 │ ├── hsbc.py │ ├── itau.py │ ├── real.py │ ├── santander.py │ └── sicredi.py ├── data.py ├── django │ ├── __init__.py │ ├── admin.py │ ├── models.py │ └── views.py ├── html.py ├── media │ ├── logo_bancobradesco.jpg │ ├── logo_bancocaixa.jpg │ ├── logo_bancohsbc.jpg │ ├── logo_bancoreal.jpg │ ├── logo_banrisul.jpg │ ├── logo_bb.jpg │ ├── logo_itau.jpg │ ├── logo_santander.jpg │ └── logo_sicredi.jpg ├── pdf.py └── templates │ ├── head.html │ ├── recibo_caixa.html │ └── recibo_sacado.html ├── 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 ├── tests ├── __init__.py ├── alltests.py ├── 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_real.py ├── test_banco_santander.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 │ ├── BoletoReal-expected.xml │ ├── BoletoSantander-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-BoletoReal-expected.xml │ └── Triplo-BoletoSantander-expected.xml └── tox.ini /.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 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "2.7" 4 | - "3.5" 5 | # command to install dependencies 6 | before_install: 7 | - sudo apt-get update 8 | - sudo apt-get install poppler-utils # For pdftohtml 9 | #install: 10 | #- pip install -r requirements.txt --use-mirrors 11 | # command to run tests 12 | script: python setup.py test 13 | -------------------------------------------------------------------------------- /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 | pyboleto 3 | ======== 4 | |travis| |pypi| 5 | 6 | .. |travis| image:: https://secure.travis-ci.org/eduardocereto/pyboleto.png?branch=master 7 | :target: http://travis-ci.org/#!/eduardocereto/pyboleto 8 | 9 | .. |pypi| image:: https://img.shields.io/pypi/v/pyboleto.svg 10 | :target: https://pypi.python.org/pypi/pyboleto/ 11 | 12 | 13 | .. _pyboleto-synopsis: 14 | 15 | pyboleto provides a python class to generate "boletos de cobranca" as these 16 | are the Brazilian equivalent for invoices. 17 | 18 | It's easy to implement classes for new banks. 19 | 20 | This class is still in development and currently has no documented API. 21 | 22 | .. contents:: 23 | :local: 24 | 25 | .. _pyboleto-implemented-bank: 26 | 27 | Implemented Banks 28 | ================= 29 | 30 | You can help writing code for more banks or printing and testing current 31 | implementations. 32 | 33 | For now here's where we are. 34 | 35 | +----------------------+----------------+-----------------+------------+ 36 | | **Bank** | **Carteira /** | **Implemented** | **Tested** | 37 | | | **Convenio** | | | 38 | +======================+================+=================+============+ 39 | | **Banco do Brasil** | 18 | Yes | Yes | 40 | +----------------------+----------------+-----------------+------------+ 41 | | **Banrisul** | x | Yes | Yes | 42 | +----------------------+----------------+-----------------+------------+ 43 | | **Bradesco** | 06, 03 | Yes | Yes | 44 | +----------------------+----------------+-----------------+------------+ 45 | | **Caixa Economica** | SR | Yes | No | 46 | +----------------------+----------------+-----------------+------------+ 47 | | **HSBC** | CNR, CSB | Yes | No | 48 | +----------------------+----------------+-----------------+------------+ 49 | | **Itau** | 157 | Yes | Yes | 50 | +----------------------+----------------+-----------------+------------+ 51 | | **Itau** | 175, 174, 178, | Yes | No | 52 | | | 104, 109 | | | 53 | +----------------------+----------------+-----------------+------------+ 54 | | **Real** | 57 | Yes | No | 55 | +----------------------+----------------+-----------------+------------+ 56 | | **Santander** | 102 | Yes | Yes | 57 | +----------------------+----------------+-----------------+------------+ 58 | | **Santander** | 101, 201 | Yes | No | 59 | +----------------------+----------------+-----------------+------------+ 60 | 61 | .. _pyboleto-docs: 62 | 63 | Documentation 64 | ============= 65 | 66 | http://packages.python.org/pyboleto/ 67 | 68 | The best way to learn how to create Boletos using pyboleto is to look at the 69 | examples at `pdf_pyboleto_sample.py`_ or `html_pyboleto_sample.py`_ 70 | 71 | 72 | .. _pdf_pyboleto_sample.py: https://github.com/eduardocereto/pyboleto/blob/master/bin/pdf_pyboleto_sample.py 73 | 74 | .. _html_pyboleto_sample.py: https://github.com/eduardocereto/pyboleto/blob/master/bin/html_pyboleto_sample.py 75 | 76 | .. _pyboleto-installation: 77 | 78 | Installation 79 | ============ 80 | 81 | You can install pyboleto either via the Python Package Index (PyPI) 82 | or from source. 83 | 84 | To install using pip,:: 85 | 86 | $ pip install pyboleto 87 | 88 | To install using easy_install,:: 89 | 90 | $ easy_install pyboleto 91 | 92 | 93 | .. _pyboleto-installing-from-source: 94 | 95 | Downloading and installing from source 96 | -------------------------------------- 97 | 98 | Download the latest version of pyboleto from 99 | http://pypi.python.org/pypi/pyboleto/ 100 | 101 | You can install it by doing the following,:: 102 | 103 | $ tar xvfz pyboleto-0.0.0.tar.gz 104 | $ cd pyboleto-0.0.0 105 | $ python setup.py build 106 | # python setup.py install # as root 107 | 108 | .. _pyboleto-installing-from-hg: 109 | 110 | Using the development version 111 | ----------------------------- 112 | 113 | You can clone the repository by doing the following:: 114 | 115 | $ git clone https://github.com/eduardocereto/pyboleto.git 116 | 117 | .. _pyboleto-unittests: 118 | 119 | Executing unittests 120 | =================== 121 | 122 | You need either setuptools or distribute in order to execute the tests. Chances are you already have one or another. You also need `pdftohtml`_.:: 123 | 124 | $ cd pyboleto 125 | $ python setup.py test 126 | 127 | 128 | .. _pdftohtml: http://poppler.freedesktop.org/ 129 | 130 | .. _pyboleto-license: 131 | 132 | License 133 | ======= 134 | 135 | This software is licensed under the `New BSD License`. See the ``LICENSE`` 136 | file in the top distribution directory for the full license text. 137 | 138 | .. vim:tw=0:sw=4:et 139 | -------------------------------------------------------------------------------- /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_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__ = '0.3.0' 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 | } 14 | 15 | 16 | def get_class_for_codigo(banco_codigo): 17 | """Retorna a classe que implementa o banco 18 | 19 | :param banco_codigo: 20 | :type banco_codigo: string 21 | :return: Classo do Banco subclasse de :class:`pyboleto.data.BoletoData` 22 | :rtype: :class:`pyboleto.data.BoletoData` 23 | """ 24 | try: 25 | banco = BANCOS_IMPLEMENTADOS[banco_codigo].split('.') 26 | except KeyError: 27 | raise(BoletoException('Este banco não é suportado.')) 28 | 29 | mod = __import__('pyboleto.bank.' + banco[0], 30 | globals(), locals(), [banco[1]]) 31 | 32 | return getattr(mod, banco[1]) 33 | -------------------------------------------------------------------------------- /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 | 61 | def format_nosso_numero(self): 62 | if self.format_convenio == 7: 63 | return "%7s%10s" % ( 64 | self.convenio, 65 | self.nosso_numero 66 | ) 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) 138 | elif self.format_convenio in (7, 8): 139 | content = "000000%s%s%s" % (self.convenio, 140 | self.nosso_numero, 141 | self.carteira) 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) 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 | 31 | def format_nosso_numero(self): 32 | return "%s/%s-%s" % ( 33 | self.carteira, 34 | self.nosso_numero, 35 | self.dv_nosso_numero 36 | ) 37 | 38 | @property 39 | def dv_nosso_numero(self): 40 | numero = self.carteira + self.nosso_numero 41 | resto = self.modulo11( 42 | num=numero, 43 | base=7, 44 | r=1 45 | ) 46 | 47 | if resto == 1: 48 | digito = 'P' 49 | elif resto == 0: 50 | digito = resto 51 | else: 52 | digito = 11 - resto 53 | 54 | return digito 55 | 56 | @property 57 | def campo_livre(self): 58 | content = "%4s%2s%11s%7s%1s" % (self.agencia_cedente.split('-')[0], 59 | self.carteira, 60 | self.nosso_numero, 61 | self.conta_cedente.split('-')[0], 62 | '0' 63 | ) 64 | return content 65 | -------------------------------------------------------------------------------- /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 | 12 | conta_cedente = CustomProperty('conta_cedente', 11) 13 | ''' 14 | Este numero tem o inicio fixo 15 | Carteira SR: 80, 81 ou 82 16 | Carteira CR: 90 (Confirmar com gerente qual usar) 17 | 18 | ''' 19 | nosso_numero = CustomProperty('nosso_numero', 10) 20 | 21 | def __init__(self): 22 | super(BoletoCaixa, self).__init__() 23 | 24 | self.codigo_banco = "104" 25 | self.local_pagamento = "Preferencialmente nas Casas Lotéricas e \ 26 | Agências da Caixa" 27 | self.logo_image = "logo_bancocaixa.jpg" 28 | 29 | @property 30 | def dv_nosso_numero(self): 31 | resto2 = self.modulo11(self.nosso_numero.split('-')[0], 9, 1) 32 | digito = 11 - resto2 33 | if digito == 10 or digito == 11: 34 | dv = 0 35 | else: 36 | dv = digito 37 | return dv 38 | 39 | @property 40 | def campo_livre(self): 41 | content = "%10s%4s%11s" % (self.nosso_numero, 42 | self.agencia_cedente, 43 | self.conta_cedente.split('-')[0]) 44 | return content 45 | 46 | def format_nosso_numero(self): 47 | return self.nosso_numero + '-' + str(self.dv_nosso_numero) 48 | -------------------------------------------------------------------------------- /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/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 | 28 | @property 29 | def dv_nosso_numero(self): 30 | composto = "%4s%5s%3s%8s" % (self.agencia_cedente, self.conta_cedente, 31 | self.carteira, self.nosso_numero) 32 | return self.modulo10(composto) 33 | 34 | @property 35 | def dv_agencia_conta_cedente(self): 36 | agencia_conta = "%s%s" % (self.agencia_cedente, self.conta_cedente) 37 | return self.modulo10(agencia_conta) 38 | 39 | @property 40 | def agencia_conta_cedente(self): 41 | return "%s/%s-%s" % (self.agencia_cedente, self.conta_cedente, 42 | self.dv_agencia_conta_cedente) 43 | 44 | def format_nosso_numero(self): 45 | return "%3s/%8s-%1s" % (self.carteira, self.nosso_numero, 46 | self.dv_nosso_numero) 47 | 48 | @property 49 | def campo_livre(self): 50 | content = "%3s%8s%1s%4s%5s%1s%3s" % (self.carteira, 51 | self.nosso_numero, 52 | self.dv_nosso_numero, 53 | self.agencia_cedente, 54 | self.conta_cedente, 55 | self.dv_agencia_conta_cedente, 56 | '000' 57 | ) 58 | return content 59 | -------------------------------------------------------------------------------- /pyboleto/bank/real.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyboleto.data import BoletoData 3 | 4 | 5 | class BoletoReal(BoletoData): 6 | """Real Bank Boleto Implementation""" 7 | 8 | def __init__(self): 9 | super(BoletoReal, self).__init__() 10 | 11 | self.codigo_banco = "356" 12 | self.logo_image = "logo_bancoreal.jpg" 13 | 14 | @property 15 | def agencia_conta_cedente(self): 16 | dv = self.digitao_cobranca 17 | s = "%s/%s/%s" % (self.agencia_cedente, self.conta_cedente, dv) 18 | return s 19 | 20 | @property 21 | def digitao_cobranca(self): 22 | num = "%s%s%s" % ( 23 | self.nosso_numero, 24 | self.agencia_cedente, 25 | self.conta_cedente 26 | ) 27 | dv = self.modulo10(num) 28 | return dv 29 | 30 | def calculate_dv_barcode(self, line): 31 | dv = self.modulo11(line, r=1) 32 | if dv == 0 or dv == 1: 33 | dv = 1 34 | else: 35 | dv = 11 - dv 36 | return dv 37 | 38 | @property 39 | def campo_livre(self): 40 | content = "%4s%7s%1s%13s" % (self.agencia_cedente, 41 | self.conta_cedente, 42 | self.digitao_cobranca, 43 | self.nosso_numero) 44 | return content 45 | -------------------------------------------------------------------------------- /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 | from pyboleto.pdf import BoletoFields 19 | 20 | 21 | class BoletoSantander(BoletoData): 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, **kwargs): 36 | super(BoletoSantander, self).__init__(**kwargs) 37 | 38 | self.codigo_banco = "033" 39 | self.logo_image = "logo_santander.jpg" 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, 59 | self.nosso_numero, 60 | self._dv_nosso_numero(), 61 | self.ios, 62 | self.carteira, 63 | ]) 64 | return content 65 | 66 | 67 | class SantanderBoletoFields(BoletoFields): 68 | RECIDO_SACADO = 'Recibo do Pagador' 69 | SACADO = 'Pagador' 70 | CEDENTE = 'Beneficiário' 71 | AG_COD_CEDENTE = 'Agência/ Código Beneficiário' 72 | 73 | 74 | class BoletoRegistradoSantander(BoletoSantander): 75 | ''' 76 | Create necessary data for registered boleto on Santander 77 | ''' 78 | 79 | def __init__(self, **kwargs): 80 | self.linha_dig = kwargs.pop('linha_dig', '') 81 | self.codigo_barras = kwargs.pop('codigo_barras', '') 82 | super(BoletoRegistradoSantander, self).__init__(**kwargs) 83 | 84 | self.carteira = '101' 85 | self.fields = SantanderBoletoFields 86 | 87 | @property 88 | def nosso_numero_by_santander(self): 89 | """ On new Webservice for boleto, 90 | santander can create their own 91 | nosso_numero with 13 digits 92 | and without dv 93 | """ 94 | return len(self.nosso_numero) == 13 95 | 96 | def format_nosso_numero(self): 97 | if self.nosso_numero_by_santander: 98 | return self.nosso_numero 99 | 100 | return super(BoletoRegistradoSantander, self).format_nosso_numero() 101 | 102 | def _dv_nosso_numero(self): 103 | if self.nosso_numero_by_santander: 104 | return '' 105 | 106 | return super(BoletoRegistradoSantander, self)._dv_nosso_numero() 107 | 108 | @property 109 | def linha_digitavel(self): 110 | if self.linha_dig: 111 | return self.linha_dig 112 | 113 | return super(BoletoRegistradoSantander, self).linha_digitavel 114 | 115 | @property 116 | def barcode(self): 117 | if self.codigo_barras: 118 | return self.codigo_barras 119 | 120 | return super(BoletoSantander, self).barcode 121 | -------------------------------------------------------------------------------- /pyboleto/bank/sicredi.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyboleto.data import BoletoData, custom_property 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 = custom_property('agencia_cedente', 4) 10 | conta_cedente = custom_property('conta_cedente', 8) 11 | posto = custom_property('posto', 2) 12 | convenio = custom_property('convenio', 4) 13 | # Nosso numero (sem dv) com 8 digitos 14 | nosso_numero = custom_property('nosso_numero', 8) 15 | 16 | def __init__(self): 17 | ''' 18 | Construtor para boleto do Banco Sicredi 19 | 20 | Args: 21 | format_convenio Formato do convenio 6, 7 ou 8 22 | format_nnumero Formato nosso numero 1 ou 2 23 | ''' 24 | super(BoletoSicredi, self).__init__() 25 | 26 | self.codigo_banco = "748" 27 | self.carteira = 3 28 | self.posto = "05" 29 | self.logo_image = "logo_sicredi.jpg" 30 | 31 | # Size of convenio 6, 7 or 8 32 | self.format_convenio = 5 33 | 34 | # Nosso Numero format. 1 or 2 35 | # 1: Nosso Numero with 5 positions 36 | # 2: Nosso Numero with 17 positions 37 | self.format_nnumero = 1 # self.nosso_numero 38 | 39 | def format_ano(self): 40 | ano = str(self.data_vencimento.strftime('%y')) 41 | ano = ano.zfill(2) 42 | return ano 43 | 44 | def format_nosso_numero(self): 45 | 46 | # 14 ano + 2 : Nosso Número deve ser apresentado no formato 47 | # AA/BXXXXX-D, onde: 48 | return "%s/2%s-%s" % ( 49 | self.format_ano(), 50 | self.nosso_numero, 51 | self.dv_nosso_numero 52 | ) 53 | 54 | # Nosso numero (sem dv) sao 11 digitos 55 | def _get_nosso_numero(self): 56 | return self._nosso_numero 57 | 58 | def _set_nosso_numero(self, val): 59 | val = str(val) 60 | if self.format_convenio == 5: 61 | if self.format_nnumero == 1: 62 | nn = val.zfill(5) 63 | elif self.format_nnumero == 2: 64 | nn = val.zfill(17) 65 | elif self.format_convenio == 7: 66 | nn = val.zfill(10) 67 | elif self.format_convenio == 8: 68 | nn = val.zfill(9) 69 | self._nosso_numero = nn 70 | 71 | nosso_numero = property(_get_nosso_numero, _set_nosso_numero) 72 | 73 | def _get_convenio(self): 74 | return self._convenio 75 | 76 | def _set_convenio(self, val): 77 | self._convenio = str(val).rjust(self.format_convenio, '0') 78 | convenio = property(_get_convenio, _set_convenio) 79 | 80 | @property 81 | def agencia_conta_cedente(self): 82 | return "%s.%s.%s" % ( 83 | self.agencia_cedente, 84 | self.posto, 85 | self.convenio 86 | ) 87 | 88 | @property 89 | def dv_nosso_numero(self): 90 | dv = "%s%s%s%s2%s" % (self.agencia_cedente, 91 | self.posto, 92 | self.convenio, 93 | self.format_ano(), 94 | self.nosso_numero 95 | ) 96 | dv = self.modulo11(dv) 97 | return dv 98 | 99 | @property 100 | def campo_livre(self): 101 | content = str("") 102 | if self.format_nnumero == 1: 103 | # "3027050000414205586") 104 | # 14 ano + 2 : Nosso Número deve ser apresentado no formato 105 | # AA/BXXXXX-D, onde: 106 | content = "%s1%s2%s%s%s%s%s10" % (self.carteira, 107 | self.format_ano(), 108 | self.nosso_numero, 109 | self.dv_nosso_numero, 110 | self.agencia_cedente, 111 | self.posto, 112 | self.convenio 113 | ) 114 | n = self.modulo11(content) 115 | if n > 9: 116 | n = 1 117 | content += str(n) 118 | return str(content) 119 | 120 | @property 121 | def codigo_dv_banco(self): 122 | cod = "%s-X" % (self.codigo_banco) 123 | return cod 124 | -------------------------------------------------------------------------------- /pyboleto/django/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/pyboleto/django/__init__.py -------------------------------------------------------------------------------- /pyboleto/django/admin.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | try: 3 | from StringIO import StringIO 4 | except ImportError: 5 | from io import StringIO 6 | 7 | from datetime import date 8 | 9 | from django.http import HttpResponse 10 | from django.contrib import admin 11 | 12 | from pyboleto.django.models import Boleto 13 | from pyboleto.pdf import BoletoPDF 14 | 15 | 16 | def print_boletos(modeladmin, request, queryset): 17 | 18 | buffer = StringIO() 19 | boleto_pdf = BoletoPDF(buffer) 20 | 21 | for b in queryset: 22 | b.print_pdf_pagina(boleto_pdf) 23 | boleto_pdf.nextPage() 24 | boleto_pdf.save() 25 | 26 | pdf_file = buffer.getvalue() 27 | 28 | response = HttpResponse() 29 | response['Content-Disposition'] = 'attachment; filename=%s' % ( 30 | u'boletos_%s.pdf' % ( 31 | date.today().strftime('%Y%m%d'), 32 | ), 33 | ) 34 | response.write(pdf_file) 35 | return response 36 | print_boletos.short_description = u'Imprimir Boletos Selecionados' 37 | 38 | 39 | class BoletoAdmin(admin.ModelAdmin): 40 | list_display = ('numero_documento', 41 | 'sacado_nome', 42 | 'data_vencimento', 43 | 'data_documento', 44 | 'valor_documento') 45 | search_fields = ('numero_documento', 'sacado_nome') 46 | date_hierarchy = 'data_documento' 47 | list_filter = ('data_vencimento', 'data_documento') 48 | actions = (print_boletos, ) 49 | admin.site.register(Boleto, BoletoAdmin) 50 | -------------------------------------------------------------------------------- /pyboleto/django/models.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from django.db import models 3 | 4 | 5 | class Boleto(models.Model): 6 | # Informações Gerais 7 | codigo_banco = models.CharField(u'Código do Banco', max_length=3) 8 | carteira = models.CharField(max_length=5) 9 | aceite = models.CharField(max_length=1, default='N') 10 | 11 | valor_documento = models.DecimalField(u'Valor do Documento', 12 | max_digits=8, decimal_places=2) 13 | valor = models.DecimalField(max_digits=8, 14 | decimal_places=2, blank=True, null=True) 15 | 16 | data_vencimento = models.DateField(u'Data de Vencimento') 17 | data_documento = models.DateField(u'Data do Documento') 18 | data_processamento = models.DateField(u'Data de Processamento', 19 | auto_now=True) 20 | 21 | numero_documento = models.CharField(u'Número do Documento', max_length=11) 22 | 23 | # Informações do Cedente 24 | agencia_cedente = models.CharField(u'Agência Cedente', max_length=4) 25 | conta_cedente = models.CharField('Conta Cedente', max_length=7) 26 | 27 | cedente = models.CharField(u'Nome do Cedente', max_length=255) 28 | cedente_documento = models.CharField(u'Documento do Cedente', 29 | max_length=50) 30 | cedente_cidade = models.CharField(u'Cidade do Cedente', max_length=255) 31 | cedente_uf = models.CharField(u'Estado do Cedente', max_length=2) 32 | cedente_endereco = models.CharField(u'Endereço do Cedente', 33 | max_length=255) 34 | cedente_bairro = models.CharField(u'Bairro do Cedente', max_length=255) 35 | cedente_cep = models.CharField(u'CEP do Cedente', max_length=9) 36 | 37 | # Informações do Sacado 38 | sacado_nome = models.CharField(u'Nome do Sacado', max_length=255) 39 | sacado_documento = models.CharField(u'Documento do Sacado', max_length=255) 40 | sacado_cidade = models.CharField(u'Cidade do Sacado', max_length=255) 41 | sacado_uf = models.CharField(u'Estado do Sacado', max_length=2) 42 | sacado_endereco = models.CharField(u'Endereço do Sacado', max_length=255) 43 | sacado_bairro = models.CharField(u'Bairro do Sacado', max_length=255) 44 | sacado_cep = models.CharField(u'CEP do Sacado', max_length=9) 45 | 46 | # Informações Opcionais 47 | quantidade = models.CharField(u'Quantidade', max_length=10, blank=True) 48 | especie_documento = models.CharField(u'Espécie do Documento', 49 | max_length=255, blank=True) 50 | especie = models.CharField(u'Espécie', max_length=2, default="R$") 51 | moeda = models.CharField(max_length=2, default='9') 52 | local_pagamento = models.CharField( 53 | u'Local de Pagamento', max_length=255, 54 | default=u'Pagável em qualquer banco até o vencimento') 55 | demonstrativo = models.TextField(blank=True) 56 | instrucoes = models.TextField(default=u"""1- Não receber após 30 dias. 57 | 2- Multa de 2% após o vencimento. 58 | 3- Taxa diária de permanência de 0,2%.""") 59 | 60 | def __unicode__(self): 61 | return self.numero_documento 62 | 63 | def print_pdf_pagina(self, pdf_file): 64 | from pyboleto import bank 65 | 66 | ClasseBanco = bank.get_class_for_codigo(self.codigo_banco) 67 | 68 | boleto_dados = ClasseBanco() 69 | 70 | for field in self._meta.get_all_field_names(): 71 | if getattr(self, field): 72 | setattr(boleto_dados, field, getattr(self, field)) 73 | 74 | setattr(boleto_dados, 'nosso_numero', 75 | getattr(self, 'numero_documento')) 76 | 77 | pdf_file.drawBoleto(boleto_dados) 78 | -------------------------------------------------------------------------------- /pyboleto/django/views.py: -------------------------------------------------------------------------------- 1 | # Create your views here. 2 | -------------------------------------------------------------------------------- /pyboleto/media/logo_bancobradesco.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/pyboleto/media/logo_bancobradesco.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_bancocaixa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/pyboleto/media/logo_bancocaixa.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_bancohsbc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/pyboleto/media/logo_bancohsbc.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_bancoreal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/pyboleto/media/logo_bancoreal.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_banrisul.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/pyboleto/media/logo_banrisul.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_bb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/pyboleto/media/logo_bb.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_itau.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/pyboleto/media/logo_itau.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_santander.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/pyboleto/media/logo_santander.jpg -------------------------------------------------------------------------------- /pyboleto/media/logo_sicredi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/pyboleto/media/logo_sicredi.jpg -------------------------------------------------------------------------------- /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
83 |
87 |
(-) Outras deduções
88 |
92 |
(+) Mora/Multa
93 |
97 |
(+) Outros acréscimos
98 |
102 |
(=) 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 | -------------------------------------------------------------------------------- /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 | import sys 6 | 7 | from setuptools import setup, find_packages 8 | 9 | 10 | def read(fname): 11 | return open(os.path.join(os.path.dirname(__file__), fname)).read() 12 | 13 | 14 | def get_version(package): 15 | """Return package version as listed in `__version__` in `__init__.py`.""" 16 | init_py = open(os.path.join(os.path.dirname(__file__), 17 | package, '__init__.py'), 18 | 'r').read() 19 | return re.search("^__version__ = ['\"]([^'\"]+)['\"]", 20 | init_py, re.MULTILINE 21 | ).group(1) 22 | 23 | 24 | 25 | 26 | setup( 27 | name='pyboleto', 28 | version=get_version('pyboleto'), 29 | author='Eduardo Cereto Carvalho', 30 | author_email='eduardocereto@gmail.com', 31 | url='https://github.com/eduardocereto/pyboleto', 32 | packages=find_packages(), 33 | package_data={ 34 | '': ['LICENSE'], 35 | 'pyboleto': ['media/*.jpg', 'templates/*.html'], 36 | 'tests': ['xml/*.xml'] 37 | }, 38 | zip_safe=False, 39 | provides=[ 40 | 'pyboleto' 41 | ], 42 | license='BSD', 43 | description='Python Library to create "boletos de cobrança bancária" for \ 44 | several Brazilian banks', 45 | long_description=read('README.rst'), 46 | download_url='http://pypi.python.org/pypi/pyboleto', 47 | scripts=[ 48 | 'bin/html_pyboleto_sample.py', 49 | 'bin/pdf_pyboleto_sample.py' 50 | ], 51 | classifiers=[ 52 | 'Development Status :: 4 - Beta', 53 | 'Operating System :: OS Independent', 54 | 'Intended Audience :: Developers', 55 | 'Intended Audience :: Financial and Insurance Industry', 56 | 'Operating System :: OS Independent', 57 | 'License :: OSI Approved :: BSD License', 58 | 'Natural Language :: Portuguese (Brazilian)', 59 | 'Programming Language :: Python', 60 | 'Programming Language :: Python :: 3', 61 | 'Programming Language :: Python :: 2.7', 62 | 'Programming Language :: Python :: 2.6', 63 | 'Topic :: Office/Business :: Financial', 64 | 'Topic :: Software Development :: Libraries :: Python Modules', 65 | 'Framework :: Django', 66 | ], 67 | platforms='any', 68 | test_suite='tests.alltests.suite', 69 | install_requires=[ 70 | 'reportlab', 71 | 'six' 72 | ], 73 | tests_require=[ 74 | 'pylint', 75 | 'tox', 76 | 'coverage', 77 | 'pep8', 78 | 'sphinx-pypi-upload', 79 | 'sphinx==1.8.5' 80 | ] 81 | ) 82 | -------------------------------------------------------------------------------- /specs/BancoDoBrasil/Doc5175Bloqueto.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/BancoDoBrasil/Doc5175Bloqueto.pdf -------------------------------------------------------------------------------- /specs/BancoReal/COBRANCA_240_POSICOES.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/BancoReal/COBRANCA_240_POSICOES.pdf -------------------------------------------------------------------------------- /specs/BancoReal/COBRANCA_CARNES_400_POSICOES.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/BancoReal/COBRANCA_CARNES_400_POSICOES.pdf -------------------------------------------------------------------------------- /specs/Bradesco/Boleto_formulas_layout_bradesco.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/Bradesco/Boleto_formulas_layout_bradesco.doc -------------------------------------------------------------------------------- /specs/Bradesco/Layout Cobranca e Boleto Completo BRADESCO_ATUALIZADO.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/Bradesco/Layout Cobranca e Boleto Completo BRADESCO_ATUALIZADO.pdf -------------------------------------------------------------------------------- /specs/Bradesco/Layout_Bradesco_ArqRetorno.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/Bradesco/Layout_Bradesco_ArqRetorno.pdf -------------------------------------------------------------------------------- /specs/Bradesco/Manual_BRADESCO.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/Bradesco/Manual_BRADESCO.PDF -------------------------------------------------------------------------------- /specs/Caixa/CEF-SIGCB.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/Caixa/CEF-SIGCB.doc -------------------------------------------------------------------------------- /specs/Caixa/CEF-SINCO Cnab240.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/Caixa/CEF-SINCO Cnab240.pdf -------------------------------------------------------------------------------- /specs/Caixa/CNAB240_SINCO.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/Caixa/CNAB240_SINCO.pdf -------------------------------------------------------------------------------- /specs/Caixa/Caixa Economica Federal - Cobranca.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/Caixa/Caixa Economica Federal - Cobranca.doc -------------------------------------------------------------------------------- /specs/Caixa/Codigo_Barras_Bloquetos_Cobranca_sem_Registro_SINCO.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/Caixa/Codigo_Barras_Bloquetos_Cobranca_sem_Registro_SINCO.pdf -------------------------------------------------------------------------------- /specs/Caixa/Manual Codigo de Barras.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/Caixa/Manual Codigo de Barras.doc -------------------------------------------------------------------------------- /specs/Caixa/Manual_CAIXA.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/Caixa/Manual_CAIXA.PDF -------------------------------------------------------------------------------- /specs/Febraban/layout240V0803.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/Febraban/layout240V0803.pdf -------------------------------------------------------------------------------- /specs/Febraban/layoutRecebimentoCodigoBarrasv28052004.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/Febraban/layoutRecebimentoCodigoBarrasv28052004.pdf -------------------------------------------------------------------------------- /specs/HSBC/cnr240-remessa.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/HSBC/cnr240-remessa.pdf -------------------------------------------------------------------------------- /specs/HSBC/cnr240.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/HSBC/cnr240.pdf -------------------------------------------------------------------------------- /specs/HSBC/cnrbarra.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/HSBC/cnrbarra.pdf -------------------------------------------------------------------------------- /specs/HSBC/cnrremes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/HSBC/cnrremes.pdf -------------------------------------------------------------------------------- /specs/HSBC/cnrretor.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/HSBC/cnrretor.pdf -------------------------------------------------------------------------------- /specs/HSBC/cob240.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/HSBC/cob240.pdf -------------------------------------------------------------------------------- /specs/HSBC/cob400_jan.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/HSBC/cob400_jan.pdf -------------------------------------------------------------------------------- /specs/HSBC/cobbarra.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/HSBC/cobbarra.pdf -------------------------------------------------------------------------------- /specs/Itau/cobranca_cnab240.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/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/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/specs/Santander/Layout de Cobrança - Código de Barras Santander Setembro 2012 v 2 3.pdf -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luizalabs/pyboleto/f8b067f6d15545ed35a67d1187490823ceb88080/tests/__init__.py -------------------------------------------------------------------------------- /tests/alltests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import unittest 4 | 5 | 6 | def suite(): 7 | """suite that tests all banks""" 8 | def my_import(name): 9 | # See http://docs.python.org/lib/built-in-funcs.html#l2h-6 10 | components = name.split('.') 11 | try: 12 | # python setup.py test 13 | mod = __import__(name) 14 | for comp in components[1:]: 15 | mod = getattr(mod, comp) 16 | except ImportError: 17 | # python tests/alltests.py 18 | mod = __import__(components[1]) 19 | return mod 20 | 21 | modules_to_test = [ 22 | 'tests.test_banco_banrisul', 23 | 'tests.test_banco_bradesco', 24 | 'tests.test_banco_caixa', 25 | 'tests.test_banco_do_brasil', 26 | 'tests.test_banco_hsbc', 27 | 'tests.test_banco_hsbc_com_registro', 28 | 'tests.test_banco_itau', 29 | 'tests.test_banco_real', 30 | 'tests.test_banco_santander', 31 | ] 32 | alltests = unittest.TestSuite() 33 | for module in [my_import(x) for x in modules_to_test]: 34 | alltests.addTest(module.suite) 35 | return alltests 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.TextTestRunner(verbosity=2).run(suite()) 40 | -------------------------------------------------------------------------------- /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(self.dados[0].linha_digitavel, 28 | '23790.27804 60000.212559 25003.923205 4 48690000828000' 29 | ) 30 | 31 | def test_codigo_de_barras(self): 32 | self.assertEqual(self.dados[0].barcode, 33 | '23794486900008280000278060000212552500392320' 34 | ) 35 | 36 | def test_agencia(self): 37 | self.assertEqual(self.dados[0].agencia_cedente, '0278-0') 38 | 39 | def test_conta(self): 40 | self.assertEqual(self.dados[0].conta_cedente, '0039232-4') 41 | 42 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoBradesco) 43 | 44 | 45 | if __name__ == '__main__': 46 | unittest.main() 47 | -------------------------------------------------------------------------------- /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 = 'SR' 16 | d.agencia_cedente = '1565' 17 | d.conta_cedente = '87000000414' 18 | d.data_vencimento = datetime.date(2012, 7, 8) 19 | d.data_documento = datetime.date(2012, 7, 3) 20 | d.data_processamento = datetime.date(2012, 7, 3) 21 | d.valor_documento = 2952.95 22 | d.nosso_numero = str(8019525086 + i) 23 | d.numero_documento = str(270319510 + i) 24 | self.dados.append(d) 25 | 26 | def test_linha_digitavel(self): 27 | self.assertEqual(self.dados[0].linha_digitavel, 28 | '10498.01952 25086.156582 70000.004146 1 53880000295295' 29 | ) 30 | 31 | def test_tamanho_codigo_de_barras(self): 32 | self.assertEqual(len(self.dados[0].barcode), 44) 33 | 34 | def test_codigo_de_barras(self): 35 | self.assertEqual(self.dados[0].barcode, 36 | '10491538800002952958019525086156587000000414' 37 | ) 38 | 39 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoCaixa) 40 | 41 | 42 | if __name__ == '__main__': 43 | unittest.main() 44 | -------------------------------------------------------------------------------- /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(self.dados[0].linha_digitavel, 29 | '00190.00009 07777.777009 00087.654182 6 49000000295295' 30 | ) 31 | 32 | def test_codigo_de_barras(self): 33 | self.assertEqual(self.dados[0].barcode, 34 | '00196490000002952950000007777777000008765418' 35 | ) 36 | 37 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoBrasil) 38 | 39 | 40 | if __name__ == '__main__': 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /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(self.dados[0].linha_digitavel, 27 | '39993.90309 36010.001018 03120.145929 3 42480000003500' 28 | ) 29 | 30 | def test_codigo_de_barras(self): 31 | self.assertEqual(self.dados[0].barcode, 32 | '39993424800000035003903036010001010312014592' 33 | ) 34 | 35 | def test_agencia(self): 36 | self.assertEqual(self.dados[0].agencia_cedente, '1172-0') 37 | 38 | def test_conta(self): 39 | self.assertEqual(self.dados[0].conta_cedente, '3903036') 40 | 41 | def test_nosso_numero(self): 42 | self.assertEqual(self.dados[0].format_nosso_numero(), 43 | '0100010103120947') 44 | 45 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoHsbc) 46 | 47 | 48 | if __name__ == '__main__': 49 | unittest.main() 50 | -------------------------------------------------------------------------------- /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(self.dados[0].linha_digitavel, 27 | '39991.71600 57195.001417 50002.520018 1 47780000033585' 28 | ) 29 | 30 | def test_codigo_de_barras(self): 31 | self.assertEqual(self.dados[0].barcode, 32 | '39991477800000335851716057195001415000252001' 33 | ) 34 | 35 | def test_agencia(self): 36 | self.assertEqual(self.dados[0].agencia_cedente, '0141-4') 37 | 38 | def test_conta(self): 39 | self.assertEqual(self.dados[0].conta_cedente, '5000252') 40 | 41 | def test_dv_nosso_numero(self): 42 | self.assertEqual(self.dados[0].dv_nosso_numero, 0) 43 | 44 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoHsbcComRegistro) 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | -------------------------------------------------------------------------------- /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.data_vencimento = datetime.date(2009, 10, 19) 19 | d.data_documento = datetime.date(2009, 10, 19) 20 | d.data_processamento = datetime.date(2009, 10, 19) 21 | d.valor_documento = 29.80 22 | d.nosso_numero = str(157 + i) 23 | d.numero_documento = str(456 + i) 24 | self.dados.append(d) 25 | 26 | def test_linha_digitavel(self): 27 | self.assertEqual(self.dados[0].linha_digitavel, 28 | '34191.09008 00015.710296 30132.800001 9 43950000002980' 29 | ) 30 | 31 | def test_codigo_de_barras(self): 32 | self.assertEqual(self.dados[0].barcode, 33 | '34199439500000029801090000015710293013280000' 34 | ) 35 | 36 | def test_agencia(self): 37 | self.assertEqual(self.dados[0].agencia_cedente, '0293') 38 | 39 | def test_conta(self): 40 | self.assertEqual(self.dados[0].conta_cedente, '01328') 41 | 42 | def test_dv_nosso_numero(self): 43 | self.assertEqual(self.dados[0].dv_nosso_numero, 1) 44 | 45 | def test_dv_agencia_conta_cedente(self): 46 | self.assertEqual(self.dados[0].dv_agencia_conta_cedente, 0) 47 | 48 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoItau) 49 | 50 | if __name__ == '__main__': 51 | unittest.main() 52 | -------------------------------------------------------------------------------- /tests/test_banco_real.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import unittest 3 | import datetime 4 | 5 | from pyboleto.bank.real import BoletoReal 6 | 7 | from .testutils import BoletoTestCase 8 | 9 | 10 | class TestBancoReal(BoletoTestCase): 11 | def setUp(self): 12 | self.dados = [] 13 | for i in range(3): 14 | d = BoletoReal() 15 | d.carteira = '06' 16 | d.agencia_cedente = '0531' 17 | d.conta_cedente = '5705853' 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 = 355.00 22 | d.nosso_numero = str(123 + i) 23 | d.numero_documento = str(123 + i) 24 | self.dados.append(d) 25 | 26 | def test_linha_digitavel(self): 27 | self.assertEqual(self.dados[0].linha_digitavel, 28 | '35690.53154 70585.390001 00000.001230 8 48690000035500' 29 | ) 30 | 31 | def test_codigo_de_barras(self): 32 | self.assertEqual(self.dados[0].barcode, 33 | '35698486900000355000531570585390000000000123' 34 | ) 35 | 36 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoReal) 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /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(self.dados[0].linha_digitavel, 28 | '03399.07073 07700.000123 34567.901029 5 54020000295295' 29 | ) 30 | 31 | def test_codigo_de_barras(self): 32 | self.assertEqual(self.dados[0].barcode, 33 | '03395540200002952959070707700000123456790102' 34 | ) 35 | 36 | def test_agencia(self): 37 | self.assertEqual(self.dados[0].agencia_cedente, '1333') 38 | 39 | def test_nosso_numero(self): 40 | self.assertEqual(self.dados[0].nosso_numero, '000001234567') 41 | self.assertEqual(self.dados[0].format_nosso_numero(), '000001234567-9') 42 | 43 | suite = unittest.TestLoader().loadTestsFromTestCase(TestBancoSantander) 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | -------------------------------------------------------------------------------- /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 sys 9 | import subprocess 10 | import tempfile 11 | import unittest 12 | 13 | from xml.etree.ElementTree import fromstring, tostring 14 | 15 | import pyboleto 16 | 17 | 18 | try: 19 | from pyboleto.pdf import BoletoPDF 20 | except ImportError as err: 21 | if sys.version_info >= (3,): 22 | pass # Reportlab doesn;t support Python3 23 | else: 24 | raise(err) 25 | 26 | 27 | def list_recursively(directory, pattern): 28 | """Returns files recursively from directory matching pattern 29 | :param directory: directory to list 30 | :param pattern: glob mattern to match 31 | """ 32 | matches = [] 33 | for root, _, filenames in os.walk(directory): 34 | for filename in fnmatch.filter(filenames, pattern): 35 | # skip backup files 36 | if (filename.startswith('.#') or 37 | filename.endswith('~')): 38 | continue 39 | matches.append(os.path.join(root, filename)) 40 | return matches 41 | 42 | 43 | def get_sources(root): 44 | for dirpath in ['pyboleto', 'tests']: 45 | path = os.path.join(root, dirpath) 46 | for fname in list_recursively(path, '*.py'): 47 | if fname.endswith('__init__.py'): 48 | continue 49 | yield fname 50 | 51 | # yield os.path.join(root, 'setup.py') 52 | 53 | 54 | def _diff(orig, new, short, verbose): 55 | lines = difflib.unified_diff(orig, new) 56 | if not lines: 57 | return '' 58 | 59 | return ''.join('%s: %s' % (short, line) for line in lines) 60 | 61 | 62 | def diff_files(orig, new, verbose=False): 63 | with open(orig) as f_orig: 64 | with open(new) as f_new: 65 | return _diff(f_orig.readlines(), 66 | f_new.readlines(), 67 | short=os.path.basename(orig), 68 | verbose=verbose) 69 | 70 | 71 | def diff_pdf_htmls(original_filename, filename): 72 | # REPLACE all generated dates with %%DATE%% 73 | for fname in [original_filename, filename]: 74 | with open(fname) as f: 75 | data = f.read() 76 | data = re.sub(r'name="date" content="(.*)"', 77 | r'name="date" content="%%DATE%%"', data) 78 | data = re.sub(r']+>', r'', data) 79 | with open(fname, 'w') as f: 80 | f.write(data) 81 | 82 | return diff_files(original_filename, filename) 83 | 84 | 85 | class ClassInittableMetaType(type): 86 | # pylint fails to understand this is a metaclass 87 | def __init__(self, name, bases, namespace): 88 | type.__init__(self, name, bases, namespace) 89 | self.__class_init__(namespace) 90 | 91 | 92 | class SourceTest(object): 93 | __metaclass__ = ClassInittableMetaType 94 | 95 | @classmethod 96 | def __class_init__(cls, namespace): 97 | root = os.path.dirname(os.path.dirname(pyboleto.__file__)) 98 | cls.root = root 99 | for filename in get_sources(root): 100 | testname = filename[len(root):] 101 | if not cls.filename_filter(testname): 102 | continue 103 | testname = testname[:-3].replace('/', '_') 104 | name = 'test_%s' % (testname, ) 105 | # func = lambda self, r=root, f=filename: self.check_filename(r, f) 106 | 107 | def func(self, r=root, f=filename): 108 | self.check_filename(r, f) 109 | func.__name__ = name 110 | setattr(cls, name, func) 111 | 112 | def check_filename(self, root, filename): 113 | pass 114 | 115 | @classmethod 116 | def filename_filter(cls, filename): 117 | if cls.__name__ == 'SourceTest': 118 | return False 119 | else: 120 | return True 121 | 122 | 123 | def indent(elem, level=0): 124 | i = "\n" + level * " " 125 | if len(elem): 126 | if not elem.text or not elem.text.strip(): 127 | elem.text = i + " " 128 | if not elem.tail or not elem.tail.strip(): 129 | elem.tail = i 130 | for elem in elem: 131 | indent(elem, level + 1) 132 | if not elem.tail or not elem.tail.strip(): 133 | elem.tail = i 134 | else: 135 | if level and (not elem.tail or not elem.tail.strip()): 136 | elem.tail = i 137 | 138 | 139 | def pdftoxml(filename, output): 140 | p = subprocess.Popen(['pdftohtml', 141 | '-stdout', 142 | '-xml', 143 | '-noframes', 144 | '-i', 145 | '-q', 146 | filename], 147 | stdout=subprocess.PIPE) 148 | stdout, stderr = p.communicate() 149 | if stderr: 150 | raise SystemExit("Error while runnig pdftohtml: %s" % (stderr, )) 151 | 152 | root = fromstring(stdout) 153 | indent(root) 154 | with open(output, 'wb') as f: 155 | f.write(tostring(root)) 156 | 157 | 158 | class BoletoTestCase(unittest.TestCase): 159 | def _get_expected(self, bank, generated): 160 | fname = os.path.join(os.path.dirname(pyboleto.__file__), 161 | "..", "tests", "xml", bank + '-expected.xml') 162 | if not os.path.exists(fname): 163 | with open(fname, 'wb') as f: 164 | with open(generated) as g: 165 | f.write(g.read()) 166 | return fname 167 | 168 | def test_pdf_triplo_rendering(self): 169 | bank = type(self.dados[0]).__name__ 170 | filename = tempfile.mktemp(prefix="pyboleto-triplo-", 171 | suffix=".pdf") 172 | boleto = BoletoPDF(filename, True) 173 | for d in self.dados: 174 | boleto.drawBoleto(d) 175 | boleto.nextPage() 176 | boleto.save() 177 | 178 | generated = filename + '.xml' 179 | pdftoxml(filename, generated) 180 | expected = self._get_expected('Triplo-' + bank, generated) 181 | diff = diff_pdf_htmls(expected, generated) 182 | if diff: 183 | self.fail("Error while checking xml for %r:\n%s" % ( 184 | bank, diff)) 185 | os.unlink(generated) 186 | 187 | def test_pdf_rendering(self): 188 | dados = self.dados[0] 189 | bank = type(dados).__name__ 190 | filename = tempfile.mktemp(prefix="pyboleto-", 191 | suffix=".pdf") 192 | boleto = BoletoPDF(filename, True) 193 | boleto.drawBoleto(dados) 194 | boleto.nextPage() 195 | boleto.save() 196 | 197 | generated = filename + '.xml' 198 | pdftoxml(filename, generated) 199 | expected = self._get_expected(bank, generated) 200 | diff = diff_pdf_htmls(expected, generated) 201 | if diff: 202 | self.fail("Error while checking xml for %r:\n%s" % ( 203 | bank, diff)) 204 | os.unlink(generated) 205 | -------------------------------------------------------------------------------- /tests/xml/BoletoBB-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | Autenticação Mecânica / Ficha de Compensação 68 | Código de baixa 69 | Sacador / Avalista 70 | Sacado 71 | - CPF/CNPJ: 72 | - - - 73 | (=) Valor cobrado 74 | (+) Outros acréscimos 75 | (+) Mora/Multa 76 | (-) Outras deduções 77 | (-) Descontos/Abatimentos 78 | Instruções 79 | Uso do banco 80 | Carteira 81 | Espécie 82 | Quantidade 83 | Valor 84 | (=) Valor documento 85 | 18 86 | R$ 87 | 2952,95 88 | Data do documento 89 | N. do documento 90 | Espécie doc 91 | Aceite 92 | Data processamento 93 | Nosso Número 94 | 08/03/2011 95 | 87654 96 | N 97 | 04/07/2012 98 | 77777770000087654 99 | Cedente 100 | Agência/Código Cedente 101 | 0000-0 / 00000000-0 102 | Local de pagamento 103 | Vencimento 104 | Pagável em qualquer banco até o vencimento 105 | 08/03/2011 106 | 001-9 107 | 00190.00009 07777.777009 00087.654182 6 49000000295295 108 | 001-9 109 | Recibo do Sacado 110 | Autenticação Mecânica 111 | Cedente 112 | Agência/Código Cedente 113 | CPF/CNPJ Cedente 114 | Vencimento 115 | Sacado 116 | Nosso Número 117 | N. do documento 118 | Data Documento 119 | Endereço Cedente 120 | Valor Documento 121 | Demonstrativo 122 | 0000-0 / 00000000-0 123 | 08/03/2011 124 | - CPF/CNPJ: 125 | 77777770000087654 126 | 87654 127 | 08/03/2011 128 | - - - - 129 | 2952,95 130 | 131 | 132 | -------------------------------------------------------------------------------- /tests/xml/BoletoBanrisul-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Autenticação Mecânica / Ficha de Compensação 64 | Código de baixa 65 | Sacador / Avalista 66 | Sacado 67 | - CPF/CNPJ: 68 | - - - 69 | (=) Valor cobrado 70 | (+) Outros acréscimos 71 | (+) Mora/Multa 72 | (-) Outras deduções 73 | (-) Descontos/Abatimentos 74 | Instruções 75 | Uso do banco 76 | Carteira 77 | Espécie 78 | Quantidade 79 | Valor 80 | (=) Valor documento 81 | R$ 82 | 550,00 83 | Data do documento 84 | N. do documento 85 | Espécie doc 86 | Aceite 87 | Data processamento 88 | Nosso Número 89 | 04/07/2000 90 | 22832563 91 | N 92 | 11/07/2012 93 | 22832563 94 | Cedente 95 | Agência/Código Cedente 96 | 1102/9000150 97 | Local de pagamento 98 | Vencimento 99 | Pagável em qualquer banco até o vencimento 100 | 04/07/2000 101 | 041-8 102 | 04192.11107 29000.150226 83256.340593 8 10010000055000 103 | 041-8 104 | Recibo do Sacado 105 | Autenticação Mecânica 106 | Cedente 107 | Agência/Código Cedente 108 | CPF/CNPJ Cedente 109 | Vencimento 110 | Sacado 111 | Nosso Número 112 | N. do documento 113 | Data Documento 114 | Endereço Cedente 115 | Valor Documento 116 | Demonstrativo 117 | 1102/9000150 118 | 04/07/2000 119 | - CPF/CNPJ: 120 | 22832563 121 | 22832563 122 | 04/07/2000 123 | - - - - 124 | 550,00 125 | 126 | 127 | -------------------------------------------------------------------------------- /tests/xml/BoletoBradesco-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Autenticação Mecânica / Ficha de Compensação 64 | Código de baixa 65 | Sacador / Avalista 66 | Sacado 67 | - CPF/CNPJ: 68 | - - - 69 | (=) Valor cobrado 70 | (+) Outros acréscimos 71 | (+) Mora/Multa 72 | (-) Outras deduções 73 | (-) Descontos/Abatimentos 74 | Instruções 75 | Uso do banco 76 | Carteira 77 | Espécie 78 | Quantidade 79 | Valor 80 | (=) Valor documento 81 | 06 82 | R$ 83 | 8280,00 84 | Data do documento 85 | N. do documento 86 | Espécie doc 87 | Aceite 88 | Data processamento 89 | Nosso Número 90 | 18/01/2011 91 | 2125525 92 | N 93 | 18/01/2011 94 | 06/00002125525-6 95 | Cedente 96 | Agência/Código Cedente 97 | 0278-0/0039232-4 98 | Local de pagamento 99 | Vencimento 100 | Pagável em qualquer banco até o vencimento 101 | 05/02/2011 102 | 237-2 103 | 23790.27804 60000.212559 25003.923205 4 48690000828000 104 | 237-2 105 | Recibo do Sacado 106 | Autenticação Mecânica 107 | Cedente 108 | Agência/Código Cedente 109 | CPF/CNPJ Cedente 110 | Vencimento 111 | Sacado 112 | Nosso Número 113 | N. do documento 114 | Data Documento 115 | Endereço Cedente 116 | Valor Documento 117 | Demonstrativo 118 | 0278-0/0039232-4 119 | 05/02/2011 120 | - CPF/CNPJ: 121 | 06/00002125525-6 122 | 2125525 123 | 18/01/2011 124 | - - - - 125 | 8280,00 126 | 127 | 128 | -------------------------------------------------------------------------------- /tests/xml/BoletoCaixa-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | Autenticação Mecânica / Ficha de Compensação 65 | Código de baixa 66 | Sacador / Avalista 67 | Sacado 68 | - CPF/CNPJ: 69 | - - - 70 | (=) Valor cobrado 71 | (+) Outros acréscimos 72 | (+) Mora/Multa 73 | (-) Outras deduções 74 | (-) Descontos/Abatimentos 75 | Instruções 76 | Uso do banco 77 | Carteira 78 | Espécie 79 | Quantidade 80 | Valor 81 | (=) Valor documento 82 | SR 83 | R$ 84 | 2952,95 85 | Data do documento 86 | N. do documento 87 | Espécie doc 88 | Aceite 89 | Data processamento 90 | Nosso Número 91 | 03/07/2012 92 | 270319510 93 | N 94 | 03/07/2012 95 | 8019525086-7 96 | Cedente 97 | Agência/Código Cedente 98 | 1565/87000000414 99 | Local de pagamento 100 | Vencimento 101 | Preferencialmente nas Casas Lotéricas e Agências da Caixa 102 | 08/07/2012 103 | 104-0 104 | 10498.01952 25086.156582 70000.004146 1 53880000295295 105 | 104-0 106 | Recibo do Sacado 107 | Autenticação Mecânica 108 | Cedente 109 | Agência/Código Cedente 110 | CPF/CNPJ Cedente 111 | Vencimento 112 | Sacado 113 | Nosso Número 114 | N. do documento 115 | Data Documento 116 | Endereço Cedente 117 | Valor Documento 118 | Demonstrativo 119 | 1565/87000000414 120 | 08/07/2012 121 | - CPF/CNPJ: 122 | 8019525086-7 123 | 270319510 124 | 03/07/2012 125 | - - - - 126 | 2952,95 127 | 128 | 129 | -------------------------------------------------------------------------------- /tests/xml/BoletoHsbc-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Autenticação Mecânica / Ficha de Compensação 64 | Código de baixa 65 | Sacador / Avalista 66 | Sacado 67 | - CPF/CNPJ: 68 | - - - 69 | (=) Valor cobrado 70 | (+) Outros acréscimos 71 | (+) Mora/Multa 72 | (-) Outras deduções 73 | (-) Descontos/Abatimentos 74 | Instruções 75 | Uso do banco 76 | Carteira 77 | Espécie 78 | Quantidade 79 | Valor 80 | (=) Valor documento 81 | CNR 82 | R$ 83 | 35,00 84 | Data do documento 85 | N. do documento 86 | Espécie doc 87 | Aceite 88 | Data processamento 89 | Nosso Número 90 | 25/05/2009 91 | 0100010103120 92 | N 93 | 25/05/2009 94 | 0100010103120947 95 | Cedente 96 | Agência/Código Cedente 97 | 1172-0/3903036 98 | Local de pagamento 99 | Vencimento 100 | Pagável em qualquer banco até o vencimento 101 | 25/05/2009 102 | 399-9 103 | 39993.90309 36010.001018 03120.145929 3 42480000003500 104 | 399-9 105 | Recibo do Sacado 106 | Autenticação Mecânica 107 | Cedente 108 | Agência/Código Cedente 109 | CPF/CNPJ Cedente 110 | Vencimento 111 | Sacado 112 | Nosso Número 113 | N. do documento 114 | Data Documento 115 | Endereço Cedente 116 | Valor Documento 117 | Demonstrativo 118 | 1172-0/3903036 119 | 25/05/2009 120 | - CPF/CNPJ: 121 | 0100010103120947 122 | 0100010103120 123 | 25/05/2009 124 | - - - - 125 | 35,00 126 | 127 | 128 | -------------------------------------------------------------------------------- /tests/xml/BoletoHsbcComRegistro-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Autenticação Mecânica / Ficha de Compensação 64 | Código de baixa 65 | Sacador / Avalista 66 | Sacado 67 | - CPF/CNPJ: 68 | - - - 69 | (=) Valor cobrado 70 | (+) Outros acréscimos 71 | (+) Mora/Multa 72 | (-) Outras deduções 73 | (-) Descontos/Abatimentos 74 | Instruções 75 | Uso do banco 76 | Carteira 77 | Espécie 78 | Quantidade 79 | Valor 80 | (=) Valor documento 81 | CSB 82 | R$ 83 | 335,85 84 | Data do documento 85 | N. do documento 86 | Espécie doc 87 | Aceite 88 | Data processamento 89 | Nosso Número 90 | 06/11/2010 91 | 1716057195 92 | PD 93 | N 94 | 06/11/2010 95 | 1716057195 96 | Cedente 97 | Agência/Código Cedente 98 | 0141-4/5000252 99 | Local de pagamento 100 | Vencimento 101 | Pagável em qualquer banco até o vencimento 102 | 06/11/2010 103 | 399-9 104 | 39991.71600 57195.001417 50002.520018 1 47780000033585 105 | 399-9 106 | Recibo do Sacado 107 | Autenticação Mecânica 108 | Cedente 109 | Agência/Código Cedente 110 | CPF/CNPJ Cedente 111 | Vencimento 112 | Sacado 113 | Nosso Número 114 | N. do documento 115 | Data Documento 116 | Endereço Cedente 117 | Valor Documento 118 | Demonstrativo 119 | 0141-4/5000252 120 | 06/11/2010 121 | - CPF/CNPJ: 122 | 1716057195 123 | 1716057195 124 | 06/11/2010 125 | - - - - 126 | 335,85 127 | 128 | 129 | -------------------------------------------------------------------------------- /tests/xml/BoletoItau-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Autenticação Mecânica / Ficha de Compensação 64 | Código de baixa 65 | Sacador / Avalista 66 | Sacado 67 | - CPF/CNPJ: 68 | - - - 69 | (=) Valor cobrado 70 | (+) Outros acréscimos 71 | (+) Mora/Multa 72 | (-) Outras deduções 73 | (-) Descontos/Abatimentos 74 | Instruções 75 | Uso do banco 76 | Carteira 77 | Espécie 78 | Quantidade 79 | Valor 80 | (=) Valor documento 81 | 109 82 | R$ 83 | 29,80 84 | Data do documento 85 | N. do documento 86 | Espécie doc 87 | Aceite 88 | Data processamento 89 | Nosso Número 90 | 19/10/2009 91 | 456 92 | DM 93 | N 94 | 19/10/2009 95 | 109/00000157-1 96 | Cedente 97 | Agência/Código Cedente 98 | 0293/01328-0 99 | Local de pagamento 100 | Vencimento 101 | Pagável em qualquer banco até o vencimento 102 | 19/10/2009 103 | 341-7 104 | 34191.09008 00015.710296 30132.800001 9 43950000002980 105 | 341-7 106 | Recibo do Sacado 107 | Autenticação Mecânica 108 | Cedente 109 | Agência/Código Cedente 110 | CPF/CNPJ Cedente 111 | Vencimento 112 | Sacado 113 | Nosso Número 114 | N. do documento 115 | Data Documento 116 | Endereço Cedente 117 | Valor Documento 118 | Demonstrativo 119 | 0293/01328-0 120 | 19/10/2009 121 | - CPF/CNPJ: 122 | 109/00000157-1 123 | 456 124 | 19/10/2009 125 | - - - - 126 | 29,80 127 | 128 | 129 | -------------------------------------------------------------------------------- /tests/xml/BoletoReal-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Autenticação Mecânica / Ficha de Compensação 64 | Código de baixa 65 | Sacador / Avalista 66 | Sacado 67 | - CPF/CNPJ: 68 | - - - 69 | (=) Valor cobrado 70 | (+) Outros acréscimos 71 | (+) Mora/Multa 72 | (-) Outras deduções 73 | (-) Descontos/Abatimentos 74 | Instruções 75 | Uso do banco 76 | Carteira 77 | Espécie 78 | Quantidade 79 | Valor 80 | (=) Valor documento 81 | 06 82 | R$ 83 | 355,00 84 | Data do documento 85 | N. do documento 86 | Espécie doc 87 | Aceite 88 | Data processamento 89 | Nosso Número 90 | 18/01/2011 91 | 123 92 | N 93 | 18/01/2011 94 | 0000000000123 95 | Cedente 96 | Agência/Código Cedente 97 | 0531/5705853/9 98 | Local de pagamento 99 | Vencimento 100 | Pagável em qualquer banco até o vencimento 101 | 05/02/2011 102 | 356-5 103 | 35690.53154 70585.390001 00000.001230 8 48690000035500 104 | 356-5 105 | Recibo do Sacado 106 | Autenticação Mecânica 107 | Cedente 108 | Agência/Código Cedente 109 | CPF/CNPJ Cedente 110 | Vencimento 111 | Sacado 112 | Nosso Número 113 | N. do documento 114 | Data Documento 115 | Endereço Cedente 116 | Valor Documento 117 | Demonstrativo 118 | 0531/5705853/9 119 | 05/02/2011 120 | - CPF/CNPJ: 121 | 0000000000123 122 | 123 123 | 18/01/2011 124 | - - - - 125 | 355,00 126 | 127 | 128 | -------------------------------------------------------------------------------- /tests/xml/BoletoSantander-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Autenticação Mecânica / Ficha de Compensação 64 | Código de baixa 65 | Sacador / Avalista 66 | Sacado 67 | - CPF/CNPJ: 68 | - - - 69 | (=) Valor cobrado 70 | (+) Outros acréscimos 71 | (+) Mora/Multa 72 | (-) Outras deduções 73 | (-) Descontos/Abatimentos 74 | Instruções 75 | Uso do banco 76 | Carteira 77 | Espécie 78 | Quantidade 79 | Valor 80 | (=) Valor documento 81 | 102 82 | R$ 83 | 2952,95 84 | Data do documento 85 | N. do documento 86 | Espécie doc 87 | Aceite 88 | Data processamento 89 | Nosso Número 90 | 17/07/2012 91 | 12345 92 | N 93 | 17/07/2012 94 | 000001234567-9 95 | Cedente 96 | Agência/Código Cedente 97 | 1333/0707077 98 | Local de pagamento 99 | Vencimento 100 | Pagável em qualquer banco até o vencimento 101 | 22/07/2012 102 | 033-7 103 | 03399.07073 07700.000123 34567.901029 5 54020000295295 104 | 033-7 105 | Recibo do Sacado 106 | Autenticação Mecânica 107 | Cedente 108 | Agência/Código Cedente 109 | CPF/CNPJ Cedente 110 | Vencimento 111 | Sacado 112 | Nosso Número 113 | N. do documento 114 | Data Documento 115 | Endereço Cedente 116 | Valor Documento 117 | Demonstrativo 118 | 1333/0707077 119 | 22/07/2012 120 | - CPF/CNPJ: 121 | 000001234567-9 122 | 12345 123 | 17/07/2012 124 | - - - - 125 | 2952,95 126 | 127 | 128 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | 3 | minversion=2.3.1 4 | envlist = py27,py35 5 | 6 | [testenv] 7 | 8 | deps = 9 | # coverage 10 | 11 | whitelist_externals = pdftohtml 12 | 13 | commands = 14 | # coverage erase 15 | # coverage run -p --include=pyboleto/ setup.py test 16 | # coverage combine 17 | python setup.py test 18 | --------------------------------------------------------------------------------