Skip to main content

szamlazz.py

The szamlazz.py package is a Python client (wrapper) for Szamlazz.hu::Számla Agent.

Introduction

Számla Agent is a non-browser-based interface of the Számlázz.hu system. It receives XML messages and depending on the received information it can do various actions.

Using szamlazz.py, you can interact with this interface in a convenient and Pythonic way.

szamlazz.py provides multiple translated (Hungarian -> English) NamedTuple classes to help interaction with the API client.

Integration

Install the package from PyPI:

pip install szamlazz.py

Import the client into your Python module:

from szamlazz import SzamlazzClient

# Depending on your future action(s), you might need the following model classes too:
from szamlazz import Header, Merchant, Buyer, Item, PdfDataMissingError

For all model classes, see models.py.

API

The SzamlazzClient instance can be initialised in two ways:

  • username/password combination
  • Agent Key (Számla Agent Kulcs)

Failing to provide one of these authentication methods will raise AssertionError.

All actions (e.g.: generate_invoice, reverse_invoice, etc.) return a new SzamlazzResponse instance.
SzamlazzResponse has the following major parameters:

  • .has_errors
  • .error_code
  • .error_message
  • .ok
  • .response
  • .text

SzamlazzResponse has the following major functions:

  • .get_pdf_base64()
  • .get_pdf_bytes()
  • .write_pdf_to_disk()
  • .print_errors()

For more details, see the contents of class SzamlazzResponse.

Action query_taxpayer returns a new QueryTaxpayerResponse instance which has the following parameters:

  • .has_errors
  • .ok
  • .response
  • .raw_xml
  • .to_dict

QueryTaxpayerResponse has a single callable function:

  • .print_errors() -> Tuple[str, str]

For more details, see the contents of class QueryTaxpayerResponse.

Implementation Status

Currently, the following actions can be executed via szamlazz.py:

  • create invoices
  • reverse invoices
  • register credit entries
  • query invoice pdf files
  • query invoice xml files
  • delete pro forma invoices
  • create receipts // With limitations. See the source code for more details
  • reverse receipts
  • query receipts
  • send receipts
  • query taxpayers
  • self billing // Implementation is not on the roadmap

Note: New actions are continuously implemented. Contributions are welcome too.

Each action's function takes a definite number of arguments. For example, let's examine SzamlazzClient.generate_invoice():

from typing import List
from szamlazz.models import Header, Merchant, Buyer, Item, SzamlazzResponse

def generate_invoice(header: Header,
                     merchant: Merchant,
                     buyer: Buyer,
                     items: List[Item],
                     e_invoice: bool = True,
                     invoice_download: bool = True,
                     ) -> SzamlazzResponse:
    pass

The Szamlazz.hu::Számla Agent XML has the following tags (depending on the action):

<xmlszamla>
    <beallitasok></beallitasok>
    <fejlec></fejlec>
    <elado></elado>
    <vevo></vevo>
    <tetelek>
        <tetel></tetel>
    </tetelek>
</xmlszamla>

Each of these tags, except <beallitasok> and <tetelek> can be mapped to a dataclass model:

  • fejlec -> Header
  • elado -> Merchant
  • vevo -> Buyer
  • tetel -> Item

Use the models to create your payloads for each action, for example, to create a <fejlec>:

from szamlazz.models import Header

fejlec = Header(
    creating_date="2021-08-26",
    payment_date="2021-08-26",
    due_date="2021-08-31",
    payment_type="Átutalás",
    currency="HUF",
    invoice_language="hu",
    invoice_comment="No Comment",
    name_of_bank="MNB",
    exchange_rate=0.0,
    order_number="ORDER-73",
    pro_forma_number_ref="",
    deposit_invoice=False,
    invoice_after_deposit_invoice=False,
    correction_invoice=False,
    number_of_corrected_invoice="",
    proforma_invoice=False,
    invoice_prefix="DK",
)

This Header dataclass instance can be passed to the generate_invoice function:

resp = generate_invoice(header=fejlec)

Contribution

Contributions are welcome. Should you have a question or an idea, open a new GitHub issue. Your contributions are expected through GitHub Pull Requests.

If you're developing with PyCharm, consider using examples/IntelliJ Config Template.run.xml to configure the examples (demo files) for quick testing.

Releasing

Releases are automatically pushed from the master branch on a new tag using GitHub Workflows.

Manual Releasing
Make sure you have the latest version of PyPA’s build installed:

python -m pip install --upgrade build

Run this command from the same directory where pyproject.toml is located:

python setup.py sdist bdist_wheel

License

MIT

Metadata

Release files for szamlazz.py 1.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for szamlazz.py 1.5.1
File Size Uploaded Provenance Actions
szamlazz_py-1.5.1.tar.gz 25.5 kB Without provenance Details for szamlazz_py-1.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for szamlazz.py 1.5.1
File Interpreter ABI Platform Actions
szamlazz_py-1.5.1-py3-none-any.whl Python 3 none any Details for szamlazz_py-1.5.1-py3-none-any.whl

Total release size: 54.4 kB

Release files / szamlazz_py-1.5.1.tar.gz

Download URL szamlazz_py-1.5.1.tar.gz
Size 25.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b22fb3065d99516afdddc66ad14a51a8b5e24c8a24c4c98e64db8a2fa822d5e5
BLAKE2b-256 checksum
How to use checksums
a32bba45b13b17174aeed4ac73a04f687e695fe8907dacd0ff7fd9090d5890e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release files / szamlazz_py-1.5.1-py3-none-any.whl

Download URL szamlazz_py-1.5.1-py3-none-any.whl
Size 28.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40efdc3b7cc1c3503bf60b6034e5f8d67add26e8cbfe52c11956ed52a9a3638a
BLAKE2b-256 checksum
How to use checksums
b58f31db35952023468e75fa1b64a421592ec7ede9a6307d33a1f2ad2e6db3a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Security for szamlazz.py 1.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page