sylius / invoicing-plugin
Invoicing plugin for Sylius.
Installs: 828 056
Dependents: 2
Suggesters: 0
Security: 0
Stars: 81
Watchers: 21
Forks: 84
Open Issues: 19
Type:sylius-plugin
Requires
- php: ^8.2
- knplabs/knp-snappy-bundle: ^1.10
- ramsey/uuid: ^4.7
- sylius/grid-bundle: ^1.13
- sylius/resource-bundle: ^1.12
- sylius/sylius: ~2.0.0
- sylius/twig-hooks: ^0.5
- symfony/clock: ^6.4 || ^7.1
- symfony/config: ^6.4 || ^7.1
- symfony/console: ^6.4 || ^7.1
- symfony/dependency-injection: ^6.4 || ^7.1
- symfony/form: ^6.4 || ^7.1
- symfony/framework-bundle: ^6.4 || ^7.1
- symfony/http-foundation: ^6.4 || ^7.1
- symfony/http-kernel: ^6.4 || ^7.1
- symfony/messenger: ^6.4 || ^7.1
- symfony/options-resolver: ^6.4 || ^7.1
- symfony/routing: ^6.4 || ^7.1
Requires (Dev)
- behat/behat: ^3.14
- dmore/behat-chrome-extension: ^1.4
- dmore/chrome-mink-driver: ^2.9
- friends-of-behat/mink: ^1.11
- friends-of-behat/mink-browserkit-driver: ^1.6
- friends-of-behat/mink-debug-extension: ^2.1
- friends-of-behat/mink-extension: ^2.7
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.1
- friends-of-behat/symfony-extension: ^2.6
- friends-of-behat/variadic-extension: ^1.6
- matthiasnoback/symfony-config-test: ^5.1
- matthiasnoback/symfony-dependency-injection-test: ^5.1
- phpspec/phpspec: ^7.5
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^1.12
- phpstan/phpstan-doctrine: ^1.5
- phpstan/phpstan-symfony: ^1.4
- phpstan/phpstan-webmozart-assert: ^1.2
- phpunit/phpunit: ^9.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- sylius-labs/coding-standard: ^4.4
- symfony/browser-kit: ^6.4 || ^7.1
- symfony/debug-bundle: ^6.4 || ^7.1
- symfony/dotenv: ^6.4 || ^7.1
- symfony/intl: ^6.4 || ^7.1
- symfony/web-profiler-bundle: ^6.4 || ^7.1
- symfony/webpack-encore-bundle: ^2.2
- 2.0.x-dev
- v2.0.0-RC.1
- 1.0.x-dev
- v1.0.0-RC.1
- v0.25.1
- v0.25.0
- v0.24.0
- v0.23.1
- v0.23.0
- v0.22.0
- v0.21.0
- v0.20.0
- v0.19.0
- v0.18.1
- v0.18.0
- v0.17.0
- v0.16.1
- v0.16.0
- v0.15.0
- v0.14.0
- v0.13.0
- v0.12.0
- v0.11.0
- v0.10.1
- v0.10.0
- v0.9.0
- v0.8.3
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.0
- v0.6.0
- 0.5.1
- 0.5
- 0.4
- 0.3.1
- 0.3
- v0.2.3
- 0.2.2
- 0.2.1
- 0.2
- 0.1.1
- 0.1
- dev-upmerge/1.0_2.0
- dev-damonsson-patch-1
- dev-add-support-to-sylius-1.13
This package is auto-updated.
Last update: 2024-12-17 02:33:13 UTC
README
Invoicing Plugin
This plugin creates an invoice related to the order.
SyliusInvoicingPlugin creates new immutable invoice when the order is in given state (default: created) and allows both customer and admin to download invoices related to the order.
Business value
The primary aim of Invoicing Plugin is to create a document representing Customer's will to buy particular products and pay for them.
An Invoice can also be treated as a proof of placing an Order. Thus, it is downloadable as .pdf file and can be sent to Customer manually by the Administrator or automatically once an Order is paid.
Additional feature of the plugin that fulfills Invoicing domain is the ability to set billing data on a Seller.
Installation
Beware!
This installation instruction assumes that you're using Symfony Flex. If you don't, take a look at the legacy installation instruction. However, we strongly encourage you to use Symfony Flex, it's much quicker!
-
Require plugin with composer:
composer require sylius/invoicing-plugin
Remember to allow community recipes with
composer config extra.symfony.allow-contrib true
or during plugin installation process -
Apply migrations to your database:
bin/console doctrine:migrations:migrate
-
Default configuration assumes enabled PDF file generation. If you don't want to use that feature change your app configuration:
# config/packages/sylius_invoicing.yaml sylius_invoicing: pdf_generator: enabled: false
Otherwise, check if you have wkhtmltopdf binary. If not, you can download it here.
In case wkhtmltopdf is not located in
/usr/local/bin/wkhtmltopdf
modify theWKHTMLTOPDF_PATH
environment variable in the.env
file:WKHTMLTOPDF_PATH=/usr/local/bin/wkhtmltopdf # Change this! :)
-
If you want to generate invoices for orders placed before plugin's installation run the following command using your terminal:
bin/console sylius-invoicing:generate-invoices
Extension points
Majority of actions contained in SyliusInvoicingPlugin is executed once an event after changing the state of the Order.
Here is the example for Winzou State Machine
:
winzou_state_machine: sylius_payment: callbacks: after: sylius_invoicing_plugin_payment_complete_producer: on: ['complete'] do: ['@sylius_invoicing_plugin.event_producer.order_payment_paid', '__invoke'] args: ['object']
Code placed above is a part of configuration placed in config.yml
file.
You can customize this file by adding new state machine events listeners or editing existing ones.
Here is the example for Symfony's workflow
:
<service id="sylius_invoicing_plugin.event_listener.workflow.payment.produce_order_payment_paid" class="Sylius\InvoicingPlugin\EventListener\Workflow\Payment\ProduceOrderPaymentPaidListener"> <argument type="service" id="sylius_invoicing_plugin.event_producer.order_payment_paid" /> <tag name="kernel.event_listener" event="workflow.sylius_payment.completed.complete" priority="100" /> </service>
Apart from that an Invoice model is treated as a Resource.
You can read more about Resources here:
http://docs.sylius.com/en/latest/components_and_bundles/bundles/SyliusResourceBundle/index.html.
Hence, template for displaying the list of Invoices is defined in routing.yml
file:
sylius_invoicing_invoice: resource: | alias: sylius_invoicing.invoice section: admin templates: "@SyliusAdmin\\Crud" only: ['index'] grid: sylius_invoicing_invoice permission: true vars: all: subheader: sylius_invoicing.ui.manage_invoices index: icon: inbox type: sylius.resource
Another aspect that can be both replaced and customized is displaying Invoices list on Order show view. Code responsible for displaying Invoices related to the Order is injected to existing Sylius template using Sonata events. You can read about customizing templates via events here:
http://docs.sylius.com/en/latest/customization/template.html
Invoices files
By default, when the order is paid, an immutable Invoice pdf file is saved on the server. The save directory is specified
with %sylius_invoicing.invoice_save_path%
parameter, that can be overridden if needed.
There is no direct relation between Sylius\InvoicingPlugin\Entity\Invoice
entity and its file. It's resolved based on
the Invoice::$number
, which is defined in Sylius\InvoicingPlugin\Provider\InvoiceFileProviderInterface
service.
By overriding this service, you can change a logic that is used to retrieve the invoice file.
Fixtures
You can add ShopBillingData
fixtures into a yaml to add Channel ShopBillingData info to your installation.
More instructions on the fixtures configuration instructions.
Security issues
If you think that you have found a security issue, please do not use the issue tracker and do not post it publicly.
Instead, all security issues must be sent to security@sylius.com
.