tulik / invoicing-plugin
Invoicing plugin for Sylius.
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 84
Type:sylius-plugin
Requires
- php: ^7.3
- knplabs/knp-snappy-bundle: ^1.8
- ramsey/uuid: ^3.9
- sylius/grid-bundle: ^1.7
- sylius/resource-bundle: ^1.6
- sylius/sylius: ^1.8
- symfony/config: ^4.4 || ^5.2
- symfony/dependency-injection: ^4.4 || ^5.2
- symfony/form: ^4.4 || ^5.2
- symfony/framework-bundle: ^4.4 || ^5.2
- symfony/http-foundation: ^4.4 || ^5.2
- symfony/http-kernel: ^4.4 || ^5.2
- symfony/messenger: ^4.4 || ^5.2
- symfony/options-resolver: ^4.4 || ^5.2
- symfony/routing: ^4.4 || ^5.2
Requires (Dev)
- behat/behat: ^3.6.1
- behat/mink-selenium2-driver: ^1.4
- friends-of-behat/mink: ^1.8
- friends-of-behat/mink-browserkit-driver: ^1.3
- friends-of-behat/mink-extension: ^2.3
- 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
- lakion/mink-debug-extension: ^1.2.3
- matthiasnoback/symfony-config-test: ^4.0
- matthiasnoback/symfony-dependency-injection-test: ^4.1
- phpspec/phpspec: ^7.0
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: 0.12.29
- phpstan/phpstan-doctrine: ^0.12
- phpstan/phpstan-symfony: ^0.12
- phpstan/phpstan-webmozart-assert: ^0.12
- phpunit/phpunit: ^8.5
- sylius-labs/coding-standard: ^3.2
- 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
- symfony/web-server-bundle: ^4.4 || ^5.2
Conflicts
- symplify/package-builder: ^8.3.25
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
-
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 migration to your database:
bin/console doctrine:migrations:migrate
-
Check if you have wkhtmltopdf binary. If not, you can download it here.
In case wkhtmltopdf is not located in /usr/local/bin/wkhtmltopdf, add a following snippet at the end of your application's config.yml:
knp_snappy:
pdf:
enabled: true
binary: /usr/local/bin/wkhtmltopdf # Change this! :)
options: []
- 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
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! :)
Extension points
Majority of actions contained in SyliusInvoicingPlugin is executed once an event after changing the state of
the Order on winzou_state_machine
is dispatched.
Here is the example:
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.
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_plugin_invoice: resource: | alias: sylius_invoicing_plugin.invoice section: admin templates: "@SyliusAdmin\\Crud" only: ['index'] grid: sylius_invoicing_plugin_invoice permission: true vars: all: subheader: sylius_invoicing_plugin.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
Invoicing Plugin renders invoices grid using a certain pattern, including displaying a dot next to channel in which an invoice as issued.
The dot's color is dependant on a property defined on Channel entity or, if not provided, a global parameter named default_channel_color
.
Like any other parameter, default_channel_color
can also be overwritten in your config.yml
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
.