Skip to main content

A library to generate Swiss QR-bill payment slips

Project description

https://travis-ci.org/claudep/swiss-qr-bill.svg?branch=master https://img.shields.io/pypi/v/qrbill.svg

Python library to generate Swiss QR-bills

From 2020, Swiss payment slips will progressively be converted to the QR-bill format. Specifications can be found on https://www.paymentstandards.ch/

This library is aimed to produce properly-formatted QR-bills as SVG files either from command line input or by using the QRBill class.

Installation

You can easily install this library with:

$ pip install qrbill

Command line usage example

Minimal:

$ qrbill --account "CH5800791123000889012" --creditor-name "John Doe"
  --creditor-postalcode 2501 --creditor-city "Biel"

More complete:

$ qrbill --account "CH44 3199 9123 0008 8901 2" --reference-number "210000000003139471430009017"
--creditor-name "Robert Schneider AG" --creditor-street "Rue du Lac 1268"
--creditor-postalcode "2501" --creditor-city "Biel"
--extra-infos "Bill No. 3139 for garden work and disposal of cuttings."
--debtor-name "Pia Rutschmann" --debtor-street "Marktgasse 28" --debtor-postalcode "9400"
--debtor-city "Rorschach" --due-date "2019-10-31" --language "de"

For usage:

$ qrbill -h

If no –output SVG file path is specified, the SVG file will be named after the account and the current date/time and written in the current directory.

Python usage example

>>> from qrbill.bill import QRBill
>>> my_bill = QRBill(
        account='CH5800791123000889012',
        creditor={
            'name': 'Jane', 'pcode': '1000', 'city': 'Lausanne', 'country': 'CH',
        },
        amount='22.45',
    )
>>> bill.as_svg('/tmp/my_bill.svg')

Outputting as PDF

If you want to produce a PDF version of the resulting bill, we suggest using the svglib <https://pypi.org/project/svglib/> library. It can be used on the command line with the svg2pdf script, or directly from Python:

>>> import tempfile
>>> from qrbill.bill import QRBill
>>> from svglib.svglib import svg2rlg
>>> from reportlab.graphics import renderPDF

>>> my_bill = QRBill(
        account='CH5800791123000889012',
        creditor={
            'name': 'Jane', 'pcode': '1000', 'city': 'Lausanne', 'country': 'CH',
        },
        amount='22.45',
    )
>>> with tempfile.NamedTemporaryFile(mode='w') as temp:
>>>     my_bill.as_svg(temp)
>>>     temp.seek(0)
>>>     drawing = svg2rlg(temp.name)
>>> renderPDF.drawToFile(drawing, "file.pdf")

Running tests

You can run tests either by executing:

$ python tests/test_qrbill.py

or:

$ python setup.py test

ChangeLog

0.5.2 (2020-11-17)

  • Final creditor is only for future use, it was removed from command line parameters.
  • Capitalized Helvetica font name in code (#43).
  • The top line was printed a bit lower to be more visible (#42).

0.5.1 (2020-08-19)

  • Fix for missing country field in QR code when using CombinedAddress (#31).
  • Added support for printing bill to full A4 format, using the full_page parameter of QRBill.as_svg() or the CLI argument --full-page.
  • The vertical separation line between receipt and main part can be omitted through the --no-payment-line CLI argument.
  • A new --text command line parameter allows for a raw text output.
  • Support for Alternate procedures lines was added (--alt-procs argument, #40).

0.5 (2020-06-24)

  • QRBill.as_svg() accepts now file-like objects.
  • Added support for combined address format.
  • A top separation line is now printed by default. It can be deactivated through the top_line boolean parameter of QRBill.__init__().
  • The error correction level of the QR code conforms now to the spec (M).

0.4 (2020-02-24)

Changes were not logged until version 0.4. Development stage was still alpha.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for qrbill, version 0.5.2
Filename, size File type Python version Upload date Hashes
Filename, size qrbill-0.5.2.tar.gz (16.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page