Croatian fiscalization library
This package is auto-updated.
Last update: 2021-09-29 13:04:51 UTC
Library for connecting your shop to the Croatian FINA.
There are 2 types of certificates demo and production. Depending on type of certificate, you need to use different client as demo and production FINA environments has different URLs. No matter the type, there are 2 certificates needed for this library to work properly. Root certificate (that are publicly available for download) and personal one that is used for signing the payload before sending it to the FINA.
When you finish procedure, you should have 3 items:
- FINA root certificate
- your own certificate
- passphrase for your own certificate
Those 3 items are necessary to successfully communicate with FINA servers.
use Robier\Fiscalization\Bill; use Robier\Fiscalization\Certificate; use Robier\Fiscalization\Client; use Robier\Fiscalization\Company; use Robier\Fiscalization\Oib; use Robier\Fiscalization\Operator; use Robier\Fiscalization\Refund; use Robier\Fiscalization\Tax; $company = new Company(new Oib('96918429930'), true); $operator = new Operator(new Oib('07392314075')); $id = new Bill\Identifier(23, 'MAGE5', 1); $bill = new Bill( $company, $operator, new DateTimeImmutable(), $id, Bill\PaymentType::cash(), Bill\SequenceType::shop() ); $bill ->addTax(new Tax\Vat(100_00, 25_00, 25_00)) ->addTax(new Tax\Vat(50_00, 5_00, 2_50)) ->addTax(new Tax\Vat(300_00, 25_00, 75_00)) ->addTax(new Tax\Vat(400_00, 25_00, 100_00)) ->addTax(new Tax\ConsumptionTax(600_00, 3_00, 18_00)) ->setTaxFreeAmount(100_00) ->setMarginTaxAmount(50_00) ->addRefund(new Refund('Povratna naknada', 10_00)) ; $certificate = new Certificate( __DIR__ . '/config/certificates/demo_root.txt', // root certificate path __DIR__ . '/config/certificates/FISKAL_1.p12', // private certificate path '************' // private certificate passphrase ); $client = Client::demo($certificate); $client->send($bill); // sends bill to FINA $client->check($bill); // checks bill trough demo checking (available only in DEMO client) $client->ping(); // checks if server is avaliable
Local development should be done via docker.
Build docker container:
After you build your docker container, you can go inside and use it via:
Or run command inside docker from outside via:
docker/run composer install
Everything should be tested. You can run tests with command: