Metadata-Version: 2.4
Name: qrbill
Version: 1.1.0
Summary: A library to generate Swiss QR-bill payment slips
Home-page: https://github.com/claudep/swiss-qr-bill/
Author: Claude Paroz
Author-email: claude@2xlibre.net
License: MIT
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
License-File: LICENSE.TXT
Requires-Dist: iso3166
Requires-Dist: python-stdnum>=1.13
Requires-Dist: qrcode
Requires-Dist: svgwrite
Dynamic: license-file

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

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"
    --additional-information "Bill No. 3139 for garden work and disposal of cuttings."
    --debtor-name "Pia Rutschmann" --debtor-street "Marktgasse 28" --debtor-postalcode "9400"
    --debtor-city "Rorschach" --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.

Note that if you don't like the automatic line wrapping in the human-readable
part of some address, you can replace a space by a newline sequence in the
creditor or debtor name, line1, line2, or street to force a line break in the
printed addresses.
(e.g. `--creditor-street "Rue des Quatorze Contours du Chemin\ndu Creux du Van"`)
The data encoded in the QR bill will *not* have the newline character. It will
be replaced by a regular space.

Python usage example
====================

::

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

Outputting as PDF or bitmap
===========================

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 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.TemporaryFile(encoding='utf-8', mode='r+') as temp:
    >>>     my_bill.as_svg(temp)
    >>>     temp.seek(0)
    >>>     drawing = svg2rlg(temp)
    >>> renderPDF.drawToFile(drawing, "file.pdf")

or to produce a bitmap image output::

    >>> from reportlab.graphics import renderPM
    >>> dpi = 300
    >>> drawing.scale(dpi/72, dpi/72)
    >>> renderPM.drawToFile(drawing, "file.png", fmt='PNG', dpi=dpi)

Running tests
=============

You can run tests either by executing::

    $ python tests/test_qrbill.py

or::

    $ python setup.py test


Sponsors
========

.. image:: https://seantis.ch/static/img/logo.svg
    :width: 150
    :target: https://seantis.ch/

.. -*- mode: rst -*-

ChangeLog
=========

1.1.0 (2023-12-16)
------------------
- Add Arial font name in addition to Helvetica for better font fallback on some
  systems.
- Drop support for Python < 3.8, and add testing for Python 3.11 and 3.12.

1.0.0 (2022-09-21)
------------------
- BREAKING: Removed the ``due-date`` command line argument and the ``due_date``
  QRBill init kwarg, as this field is no longer in the most recent specs (#84).
- Handle line breaks in additional information, so it is showing in the printed
  version, but stripped from the QR data (#86).
- Improved performance by deactivating debug mode in svgwrite (#82).

0.8.1 (2022-05-10)
------------------
- Fixed a regression where the currency was not visible in the payment part
  (#81).

0.8.0 (2022-04-13)
------------------
- Replaced ``##`` with ``//`` as separator in additional informations (#75).
- Print scissors symbol on horizontal separation line when not in full page.
  WARNING: the resulting bill is 1 millimiter higher to be able to show the
  entire symbol (#65).
- Renamed ``--extra-infos`` command line parameter to ``--additional-information``
  and renamed ``extra_infos`` and ``ref_number`` ``QRBill.__init__`` arguments
  to ``additional_information`` and ``reference_number``, respectively.
  The old arguments are still accepted but raise a deprecation warning (#68).

0.7.1 (2022-03-07)
------------------
- Fixed bad position of amount rect on receipt part (#74).
- Increased title font size and section spacing on payment part.

0.7.0 (2021-12-18)
------------------
- License changed from GPL to MIT (#72).
- Prevented separation line filled on some browsers.
- Scissors symbol is now an SVG path (#46).

0.6.1 (2021-05-01)
------------------
- Added ``--version`` command-line option.
- QR-code size is now more in line with the specs, including the embedded Swiss
  cross (#58, #59).
- Widen space at the right of the QR-code (#57).
- A new ``--font-factor`` command-line option allows to scale the font if the
  actual size does not fit your needs (#55).

0.6.0 (2021-02-11)
------------------
- Added the possibility to include newline sequences in name, street, line1, or
  line2 part of addresses to improve printed line wrapping of long lines.
- Moved QR-code and amount section to better comply with the style guide (#52).
- Dropped support for EOL Python 3.5 and confirmed support for Python 3.9.

0.5.3 (2021-01-25)
------------------
- Enforced black as swiss cross background color.
- Allowed output with extension other than .svg (warning instead of error).
- Split long address lines to fit in available space (#48).

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.
