Skip to main content

fiskal-hr

Python 3 package for integrating with Croatian tax authority Fiskalizacija service.

Scope

The package provides full integration with the Fiskalizacija service, including:

  • checking invoice details in test (DEMO) mode - FiskalClient.check_invoice()
  • submitting an invoice - FiskalClient.submit_invoice()
  • submitting a fiscalization document - FiskalClient.submit_document()
  • changing the payment method - FiskalClient.change_payment_method()

Requirements

You'll need your client certificate, Fiskalizacija service certificate and FINA root CA certificates. Read the integration guide for detailed steps how to get and prepare the certificates.

You'll also need the libxmlsec1 library installed on your computer.

Quickstart

  1. Install fiskal-hr:

    pip install fiskal-hr
    
  2. Make sure you have your certificates ready, then initialize the fiskal client package:

    from fiskalhr.invoice import Invoice
    from fiskalhr.ws import FiskalClient
    from fiskalhr.signature import Signer, Verifier
    
    signer = Signer("path/to/your-client-cert.pem")  # if encrypted, you'll need the password as well
    verifier = Verifier("path/to/service-cert.pem", ["path/to/fina-demo-ca-combined.pem"])
    fiskal_client = FiskalClient(
        "path/to/fina-demo-ca-combined.pem",
        "path/to/wsdl/FiskalizacijaService.wsdl",
        signer,
        verifier,
    )
    
  3. Check communication with the service:

    fiskal_client.test_service()
    

    This sends a "ping" message to the echo service, to check that basic connectivity is working. If there's an error, the test_service() method will raise an exception.

  4. Create a test invoice and ask the service to do sanity checks on it (this only works in the demo mode):

    invoice = Invoice(fiskal_client, oib="YOUR-OIB", invoice_number="1/X/1", total=100)
    
    fiskal_client.check_invoice(invoice)
    

    If there are any errors, the check_invoice() method will raise fiskalhr.ResponseError with the error details in the details attribute.

    Note that this does only basic sanity checking. For example, it will not check if the point of sale location (code X in the invoice number in this example) is registered.

Testing

This package has 100% unit test coverage. To run the tests:

pytest

Coverage report is generated automatically. To export it in HTML form, run coverage html.

The tests do not contact Fiskalizacija service or any other external service, nor do they require actual certificates. They are entirely self-contained.

More info about testing and certificates is available in the testing guide.

Contributing

Found a bug or think something can be improved? All contributions are welcome!

Before changing any code, please open a GitHub issue explaining what you'd like to do. This will ensure that your planned contribution fits well with the rest of the package and minimize the chance your pull request will be rejected.

If changing any code, please ensure that after your changes:

  • all tests pass and the code coverage is still 100%
  • black, flake8 and isort find no problems
  • the code doesn't depend on any external service

Copyright (C) 2022 by Senko Rasic senko@senko.net

This package may be used and distributed under the terms of MIT license. See the LICENSE file for details.

Metadata

Release files for fiskal-hr 0.9.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 fiskal-hr 0.9.1
File Size Uploaded Provenance
fiskal-hr-0.9.1.tar.gz 16.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fiskal-hr 0.9.1
File Interpreter ABI Platform
fiskal_hr-0.9.1-py3-none-any.whl Python 3 none any Details

Total release size: 36.6 kB

Release files / fiskal-hr-0.9.1.tar.gz

Download URL fiskal-hr-0.9.1.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0634d40fb03500ab3b70541e4cd68a7ea58b9ce21c2597ef89c6c59a29208eaa
BLAKE2b-256 checksum
How to use checksums
88b08b70516ada39e1e8f2019a9a3081cd0dba03f4f80d872b41e8b682a510e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.9

Release files / fiskal_hr-0.9.1-py3-none-any.whl

Download URL fiskal_hr-0.9.1-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
367d9a557eb71c25edfa62681cff7b2b9525a5fcff5b44cdbffe2aba6e88bc21
BLAKE2b-256 checksum
How to use checksums
224507d2f00d83067217873b289ae522f08b7191fdb17f035da577b453fa2518
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.9

Security for fiskal-hr 0.9.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