项目作者: BeHappyCommunication

项目描述 :
A Plugin for Sylius to generate invoices (! deprecated, use sylius/invoicing-plugin instead)
高级语言: PHP
项目地址: git://github.com/BeHappyCommunication/SyliusInvoicePlugin.git
创建时间: 2017-09-27T06:10:10Z
项目社区:https://github.com/BeHappyCommunication/SyliusInvoicePlugin

开源协议:MIT License

下载


sylius-invoice

A Plugin for Sylius to generate invoices

Installation-procedure

  1. $ composer require behappy/invoice-plugin

Informations

This plugin use Knp Snappy Bundle. Please refer to it’s documentation for wkhtmltopdf installation (https://github.com/KnpLabs/snappy)

Enable the plugin

Enable those plugins in AppKernel

  1. // in app/AppKernel.php
  2. public function registerBundles() {
  3. $bundles = array(
  4. // ...
  5. new Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
  6. new \BeHappy\SyliusCompanyDataPlugin\BeHappySyliusCompanyDataPlugin(),
  7. new \BeHappy\SyliusInvoicePlugin\BeHappySyliusInvoicePlugin(),
  8. );
  9. // ...
  10. }
  1. #in app/config/config.yml
  2. imports:
  3. ...
  4. - { resource: "@BeHappySyliusCompanyDataPlugin/Resources/config/config.yml" }
  5. - { resource: "@BeHappySyliusInvoicePlugin/Resources/config/config.yml" }
  6. ...
  1. # in routing.yml
  2. ...
  3. behappy_company_data_plugin:
  4. resource: '@BeHappySyliusCompanyDataPlugin/Resources/config/routing.yml'
  5. behappy_invoice_plugin.admin:
  6. resource: '@BeHappySyliusInvoicePlugin/Resources/config/routes/admin.yml'
  7. prefix: /admin
  8. behappy_invoice_plugin.shop:
  9. resource: '@BeHappySyliusInvoicePlugin/Resources/config/routes/shop.yml'
  10. prefix: /{_locale}/account
  11. requirements:
  12. _locale: ^[a-z]{2}(?:_[A-Z]{2})?$
  13. ...

Generate database

Simply launch

  1. php bin/console doctrine:schema:update --dump-sql --force

You might have tables referring to BeHappySyliusCompanyDataPlugin if you did not enabled it before requiring this plugin

Optional : generate invoices

In order to have invoices for previously placed orders, you can run this command :

  1. php bin/console behappy:invoices:generate

This command will generate invoices for all orders in state FULFILLED with no invoices attached

That’s it !

From now on, each and every time an order is fulfilled, the event listener will create a new invoice and copy (if needed)
company data information into a separate table to make them static.

A new block is also displayed in admin under the shipment section of orders that have an invoice linked.

In the account section for your customers, a link is also displayed for every invoice linked to their orders.

Configuration

Invoice number

By default, invoices will be generated with a 12 digits number filled with 0 (str_pad(12, ‘0’, STR_PAD_LEFT))

You can redefine this length definition by overriding this :

  1. # in app/config.yml
  2. parameters:
  3. ...
  4. behappy_invoice_plugin.invoice_number.length: 14
  5. ...

Now every invoice will be 14 digits long.

In a near future, this plugin will use a number generator that you’ll be free to override according to your needs.

Events

During the invoice creation, 2 events are fired with the order as argument.

  1. behappy_invoice_plugin.event.invoice.pre_create
  2. behappy_invoice_plugin.event.invoice.post_create

You can subscribe to those events and do whatever you need

Override

In order to override the pdf template file, you simply have to create the following file : app/Resources/BeHappySyliusInvoicePlugin/views/Invoice/pdf.html.twig

Thanks

This plugin is partially inspired by BitBagCommerce/SyliusInvoicingPlugin (https://github.com/BitBagCommerce/SyliusInvoicingPlugin).

Feel free to contribute

You can also ask your questions at the mail address in the composer.json mentioning this package.

Other

You can also check our other packages (including Sylius plugins) at https://github.com/BeHappyCommunication