Client for Croatian Fiskalizacija tax service
Project description
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
-
Install
fiskal-hr
:pip install fiskal-hr
-
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, )
-
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. -
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 raisefiskalhr.ResponseError
with the error details in thedetails
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
andisort
find no problems- the code doesn't depend on any external service
Copyright and license
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fiskal-hr-0.0.1.tar.gz
.
File metadata
- Download URL: fiskal-hr-0.0.1.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e710d0ff10222b815f168c23883b98b1f024e44461684879f798af85aa48603 |
|
MD5 | 02b2465343fc39e3de95e044ea1e3667 |
|
BLAKE2b-256 | 57fa32e8fc4833381a80c96a88c927c754bb8b63008876a1d4ab560ebd858717 |
File details
Details for the file fiskal_hr-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: fiskal_hr-0.0.1-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1326e65a48bf02b7747ff352fe6000b54bb36f1495d6059f52ffeaa8e3c05178 |
|
MD5 | a171669823feb3b163652d17e7a11d7e |
|
BLAKE2b-256 | b24fb99cfaa0277459b8ff55b51d72f0a7b9ce0b9cd3888ab6b7d158f5b2edc3 |