robier / sylius-croatian-fiscalization-plugin
Plugin allowing to send data to Croatian FINA
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:sylius-plugin
Requires
- php: ^8.0
- robier/fiscalization: dev-master
- sylius/sylius: ~1.9.0 || ~1.10.0@alpha
- symfony/lock: ^5.3
Requires (Dev)
- behat/behat: ^3.6.1
- behat/mink-selenium2-driver: ^1.4
- dmore/behat-chrome-extension: ^1.3
- dmore/chrome-mink-driver: ^2.7
- friends-of-behat/mink: ^1.8
- friends-of-behat/mink-browserkit-driver: ^1.4
- friends-of-behat/mink-debug-extension: ^2.0.0
- friends-of-behat/mink-extension: ^2.4
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.0
- friends-of-behat/symfony-extension: ^2.1
- friends-of-behat/variadic-extension: ^1.3
- friendsofsymfony/oauth-server-bundle: ^1.6 || >2.0.0-alpha.0 ^2.0@dev
- phpspec/phpspec: ^7.0
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: 0.12.85
- phpstan/phpstan-doctrine: 0.12.33
- phpstan/phpstan-strict-rules: ^0.12.0
- phpstan/phpstan-webmozart-assert: 0.12.12
- phpunit/phpunit: ^9.5
- sensiolabs/security-checker: ^6.0
- sylius-labs/coding-standard: ^4.0
- symfony/browser-kit: ^4.4 || ^5.2
- symfony/debug-bundle: ^4.4 || ^5.2
- symfony/dotenv: ^4.4 || ^5.2
- symfony/intl: ^4.4 || ^5.2
- symfony/web-profiler-bundle: ^4.4 || ^5.2
- vimeo/psalm: 4.7.1
This package is auto-updated.
Last update: 2024-11-04 16:58:23 UTC
README
Note: This package is still under development
Enables your shop to communicate with Croatian FINA when a customer makes a purchase.
You do not need to send data to FINA if a customer makes offline purchase (bank transfer or paying on delivery). This is configurable via plugin configuration.
Every order will get its bill sequence, bill unique identifier and issuer security code according to FINA standards. You will see in order detail view (inside admin) those data. If for any reason those data could not be fiscalized, you will see log of errors that happened. You try to resend data by clicking the button under error logs.
Configuration
Before setting up configurations you will need to have 3 things:
- root certificate
- personal certificate
- personal certificate passphrase
You will get those things from FINA. You can find more info here.
robier_sylius_croatian_fiscalization: environment: demo # 'demo' or 'production' disable_on_payment_codes: - bank_transfer - cash_on_delivery # depends on your configuration, by default it will be applied to all payment types resending: max_attempts: 3 certificate: demo: root_path: '%kernel.project_dir%/var/certificates/demo/root.txt' private_path: '%kernel.project_dir%/var/certificates/demo/FISKAL_1.p12' passphrase: '**********' production: root_path: '%kernel.project_dir%/var/certificates/production/root.txt' private_path: '%kernel.project_dir%/var/certificates/production/FISKAL_1.p12' passphrase: '**********' company: oib: 76915349123 inside_tax_registry: true operator: oib: 28841868149 # if null (~), company.oib will be used instead
Installation
Install application via composer:
composer require robier/sylius-croatian-fiscalization-plugin
Enable bundle in your sylius instance:
<?php return [ # ..., Robier\SyliusCroatianFiscalizationPlugin\RobierSyliusCroatianFiscalizationPlugin::class => ['all' => true], # ..., ];
Copy configuration to your project:
# config/packages/robier_sylius_croatian_fiscalization.yaml imports: - { resource: "@RobierSyliusCroatianFiscalizationPlugin/Resources/config/config.yaml" } robier_sylius_croatian_fiscalization: environment: demo # 'demo' or 'production' disable_on_payment_codes: - bank_transfer - cash_on_delivery # depends on your configuration, by default it will be applied to all payment types resending: max_attempts: 3 certificate: demo: root_path: '%kernel.project_dir%/var/certificates/demo/root.txt' private_path: '%kernel.project_dir%/var/certificates/demo/FISKAL_1.p12' passphrase: '**********' production: root_path: '%kernel.project_dir%/var/certificates/production/root.txt' private_path: '%kernel.project_dir%/var/certificates/production/FISKAL_1.p12' passphrase: '**********' company: oib: 76915349123 inside_tax_registry: true operator: oib: 28841868149 # if null (~), company.oib will be used instead
Add certificates provided by FINA somewhere outside the git jurisdiction and change paths in package configuration file
certificate.demo.*
certificate.production.*
Import routes
# config/routes/robier_sylius_croatian_fiscalization_plugin.yaml robier_sylius_croatian_fiscalization_plugin: resource: "@RobierSyliusCroatianFiscalizationPlugin/Resources/config/routing.yaml"
Add new tables to the database:
bin/console doctrine:schema:update --dump-sql
# and if you are satisfied with updates then run
bin/console doctrine:schema:update --force
Replace default order number sequence generator so invoice numbers will be generated by Croatian FINA standard.
# config/services.yaml sylius.sequential_order_number_generator: alias: robier_sylius_croatian_fiscalization_plugin.order.number_generator
Create starting bill sequence by running command
bin/console robier:croatian-fiscalization:set-bill-sequence 1/POS1/1
Sequence should be defined by company internal act document but this library for now only supports numbers like this is single toll device. Only first number increases with every bill sent to FINA.
Clear your application cache
bin/console clear:cache
Setup TAX in your admin. You need to create TAX with code vat
if you want it to be applied
on the bill that is sent to the FINA. Delivery is added as TAX exemption, as delivery
company will apply TAX on their bill.
Local development (Docker)
Start project with
docker/env dev on
Enter container
docker/enter dev:php # or docker/run dev:node # or docker/enter dev:mysql
Stop project
docker/env dev off
Remove all containers and volumes
docker/env dev down -v -t0
When docker environment started, you can open your project by http://localhost:8889 in your browser.
You can change nginx port by adding docker/.env
and override the value ie.
# docker/.env file NGINX_HTTP_PORT=8888
Any value existing in docker/.env.dist
can be overridden like that.
Default mysql credentials are:
MYSQL_USER=sylius MYSQL_PASSWORD=nopassword MYSQL_DATABASE=sylius
TODO
[] add tests [] add better documentation [] add docker installation script [] setup database [] setup fixtures [] open project in browser when setup finishes
Documentation
For a comprehensive guide on Sylius Plugins development please go to Sylius documentation, there you will find the Plugin Development Guide, that is full of examples.
Quickstart Installation
-
Run
composer create-project sylius/plugin-skeleton ProjectName
. -
From the plugin skeleton root directory, run the following commands:
$ (cd tests/Application && yarn install) $ (cd tests/Application && yarn build) $ (cd tests/Application && APP_ENV=test bin/console assets:install public) $ (cd tests/Application && APP_ENV=test bin/console doctrine:database:create) $ (cd tests/Application && APP_ENV=test bin/console doctrine:schema:create)
To be able to setup a plugin's database, remember to configure you database credentials in tests/Application/.env
and tests/Application/.env.test
.
Usage
Running plugin tests
-
PHPUnit
vendor/bin/phpunit
-
PHPSpec
vendor/bin/phpspec run
-
Behat (non-JS scenarios)
vendor/bin/behat --strict --tags="~@javascript"
-
Behat (JS scenarios)
-
Start Headless Chrome:
google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1
- Install SSL certificates (only once needed) and run test application's webserver on
127.0.0.1:8080
:
symfony server:ca:install APP_ENV=test symfony server:start --port=8080 --dir=tests/Application/public --daemon
- Run Behat:
vendor/bin/behat --strict --tags="@javascript"
-
Static Analysis
-
Psalm
vendor/bin/psalm
-
PHPStan
vendor/bin/phpstan analyse -c phpstan.neon -l max src/
-
-
Coding Standard
vendor/bin/ecs check src
Opening Sylius with your plugin
-
Using
test
environment:(cd tests/Application && APP_ENV=test bin/console sylius:fixtures:load) (cd tests/Application && APP_ENV=test bin/console server:run -d public)
-
Using
dev
environment:(cd tests/Application && APP_ENV=dev bin/console sylius:fixtures:load) (cd tests/Application && APP_ENV=dev bin/console server:run -d public)