Virtuaaliviivakoodi is a Python library for generating and deconstructing virtual barcodes based on Finanssiala's pankkiviivakoodi spec.
pip install virtuaaliviivakoodi
from virtuaaliviivakoodi import virtuaaliviivakoodi
virtuaaliviivakoodi(
iban="FI49 5000 9420 0287 30",
reference="12345 67907",
due_date=date(2022, 12, 12),
euro_amount=100.20,
)
# > "449500094200287300001002000000000000001234567907201212"
from virtuaaliviivakoodi import deconstruct_virtuaaliviivakoodi
deconstruct = deconstruct_virtuaaliviivakoodi("449500094200287300001002000000000000001234567907201212")
# > deconstruct.symbol = SymbolVersion.VERSION_4,
# deconstruct.iban = FI4950009420028730,
# deconstruct.euro_amount = Decimal('100.20'),
# deconstruct.reference = 1234567907,
# deconstruct.due_date = date(2022, 12, 12),
Argument | Type | Description |
---|---|---|
iban |
str |
Mandatory. Payment receiver's IBAN. Must be in Finnish format. E.g.: "FI49 5000 9420 0287 30" or "FI4950009420028730" |
reference |
str int |
Mandatory. Invoice reference in Finnish or international (RF) format. May invluce whitespace characters. E.g. "12345 67907" , "1234567907" , 1234567907 or "RF92 1234 2345" |
euro_amount |
float int Decimal |
Mandatory. Invoice total amount in Euros. Must be positive number. According the spec amount must be smaller than 1000000. |
due_date |
date |
Optional. Invoice due date as a Python date object. If left empty, "000000" is used as the date according to the spec |
Argument | Type | Description |
---|---|---|
virtuaaliviivakoodi |
str |
Mandatory. Virtuaaliviivakoodi to deconstruct. E.g.: "449500094200287300001002000000000000001234567907201212" |
Exceptions can be imported the following way:
from virtuaaliviivakoodi.exceptions import (
VirtuaaliviivakoodiException,
InvalidIBANException,
InvalidReferenceException,
InvalidEuroAmountException,
InvalidDueDateException,
InvalidSymbolException,
InvalidLengthException
)
Exception | Description |
---|---|
VirtuaaliviivakoodiException |
Base exception class for all of the following exceptions. |
InvalidIBANException |
Raised for invalid IBANs |
InvalidReferenceException |
Raised for invalid references |
InvalidEuroAmountException |
Raised for invalid euro amounts |
InvalidDueDateException |
Raised for invalid due dates |
InvalidSymbolException |
Raised for invalid symbol version of the virtuaaliviivakoodi |
InvalidLengthException |
Raised for invalid length of the virtuaaliviivakoodi |