Welcome to BankBarcode’s documentation!¶
Release v0.1.4
Contents:
BankBarcode¶
Python library to generate barcodes for financial documents
Currently only the following codes are implemented:
- cuaderno57, Cobros por ventanilla y autoservicio, serie normas y procedimientos bancarios, No57, Enero 2001
- Recibo507, Recibos y otros (Cobros por Ventanilla y Autoservicio, V2001)
Feel free to implement more.
from bankbarcode.cuaderno57 import Recibo507
entity = '01234567'
suffix = '023'
ref = '12345678901'
notice = '123456'
amount = '6543.21'
recibo507 = Recibo507(entity, suffix, ref, notice, amount)
# get checksum value
checksum = recibo507.checksum()
# save barcocde as /tmp/mybarcode.svg
provided_filename = '/tmp/mybarcode.svg'
generated_filename = recibo507.save(provided_filename)
# get a string with the barcode in SVG fromat
svg = recibo507.svg()
Read the documentation at http://bankbarcode.readthedocs.org
Backend¶
BankBarcode uses pyBarcode to generate the barcodes.
pyBarcode¶
pyBarcode generates barcodes with Code128 (EAN128) since v0.8b1.
API¶
-
class
bankbarcode.bankbarcode.
BankBarcode
¶ Base class for barcodes
-
__weakref__
¶ list of weak references to the object (if defined)
-
_check_length
(name, value, expected_length, description)¶ Check length of a value.
Parameters: - name – name of the value
- value – the value itself
- expected_length – the expected length of the value
- description – definition of the expected value
Returns: True if value have the expected length, otherwise False
-
code
()¶ Code generation. To implement in child classes
-
save
(path, writer_options=None)¶ Save barcode in SVG format.
Parameters: - path – path to SVG file with or without ”.svg” extension
- writer_options – Common options from pyBarcode http://pythonhosted.org/pyBarcode/writers/index.html?#common-options
Returns: a string with the name of the file generated
-
svg
(writer_options=None)¶ Generate a SVG with the barcode.
Parameters: writer_options – Common options from pyBarcode http://pythonhosted.org/pyBarcode/writers/index.html?#common-options Returns: a string with the barcode in SVG format
-
-
class
bankbarcode.cuaderno57.
Recibo
¶ Base class for receipts (recibos) of Cobros por ventanilla y autoservicio, serie normas y procedimientos bancarios, No57, Enero 2001
-
_check_amount
(amount)¶ Check the amount (Importe)
Parameters: amount – the amount (Importe) Returns: True if it have the expected length, otherwise False
-
_check_due_date
(due_date, suffix)¶ Check due date (Fecha limite) and suffix
Parameters: due_date – Due Date (Fecha limite) Returns: True if due date is a Datetime or string with format ‘%Y-%m-%d’ and suffix bigger than 499, otherwise False
-
_check_entity
(value)¶ Check entity code (Número de la sociedad emisora)
Parameters: value – the entity code (Número de la sociedad emisora) Returns: True if it have the expected length, otherwise False
-
_check_notice
(value)¶ Check the notice identification code (Identificación)
Parameters: value – the notice identification code (Identificación) Returns: True if it have the expected length, otherwise False
-
_check_ref
(value)¶ Check the reference code (Número de referencia)
Parameters: value – the reference code (Número de referencia) Returns: True if it have the expected length, otherwise False
-
_check_suffix
(value)¶ Check the suffix code (Sufijo)
Parameters: value – the suffix of the entity (Sufijo) Returns: True if it have the expected length, otherwise False
-
-
class
bankbarcode.cuaderno57.
Recibo507
(entity=None, suffix=None, ref=None, notice=None, amount=None, due_date=None)¶ Receipt (Recibo) 507 for Recibos y otros (Cobros por Ventanilla y Autoservicio, V2001)
-
__init__
(entity=None, suffix=None, ref=None, notice=None, amount=None, due_date=None)¶ Create and object of Recibo507 with checked values.
Parameters: - entity – the entity code (Número de la sociedad emisora)
- suffix – the suffix of the entity (Sufijo)
- ref – the reference code (Número de referencia)
- notice – the notice identification code (Identificación)
- amount – the amount (Importe)
- due_date – Due date (Fecha limite)
Returns: an object of Recibo507
-
amount
¶ The amount (Importe)
Returns: the amount (Importe) as an string with 10 characters
-
amount100
()¶ Remove the decimal point of the amount (Importe)
Returns: the amount (Importe) as an unicode string without decimal point
-
checksum
()¶ Generate the checksum (Dígitos de Control) to be added to reference code (Número de referencia)
Returns: the checksum (Dígitos de Control) as an unicode string with 2 characters
-
code
()¶ Generate the code for the barcode
Returns: an unicode string with the code for the barcode
-
due_date
¶ Due date (Fecha limite)
Returns: Datetime with Due date
-
entity
¶ The entity code (Número de la sociedad emisora)
Returns: the entity code (Número de la sociedad emisora) as an string with 8 characters
-
notice
¶ The notice identification code (Identificación)
Returns: the notice identification code (Identificación) as an string with 6 characters
-
ref
¶ The reference code (Número de referencia)
Returns: the reference code (Número de referencia) as an string with 11 characters
-
suffix
¶ The suffix (Sufijo)
Returns: the suffix (Sufijo) as an string with 3 characters
-