Giter Site home page Giter Site logo

bitbagcommerce / syliusinvoicingplugin Goto Github PK

View Code? Open in Web Editor NEW
21.0 7.0 3.0 10.19 MB

This plugin enables generating invoices in Sylius platform application.

License: MIT License

PHP 74.69% JavaScript 1.45% HTML 23.86%
sylius-plugin sylius ecommerce symfony invoicing

syliusinvoicingplugin's Introduction

Overview

This plugin enables generating invoices in Sylius platform application. It adds a VAT number field for the billing address during the checkout and allows to download the invoice in the admin panel view.

Support

We work on amazing eCommerce projects on top of Sylius and Pimcore. Need some help or additional resources for a project? Write us an email on [email protected] or visit our website! 🚀

Demo

We created a demo app with some useful use-cases of the plugin! Visit demo.bitbag.shop to take a look at it. The admin can be accessed under demo.bitbag.shop/admin link and sylius: sylius credentials.

Installation

$ composer require bitbag/invoicing-plugin:dev-master

Add plugin dependencies to your AppKernel.php file:

public function registerBundles()
{
    return array_merge(parent::registerBundles(), [
        ...
        
        new \Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
        new \BitBag\SyliusInvoicingPlugin\BitBagSyliusInvoicingPlugin(),
    ]);
}

Note

This plugin uses wkhtmltopdf under the hood wrapped into KnpSnappyBundle. It requires you to install the wkthmltopdf binary. Read more in the KnpSnappyBundle docs and on Wkhtmltopdf website.

Import required config in your app/config/config.yml file:

# app/config/config.yml

imports:
    ...
    
    - { resource: "@BitBagSyliusInvoicingPlugin/Resources/config/config.yml" }

Import routing in your app/config/routing.yml file:

# app/config/routing.yml
...

bitbag_sylius_invoicing_plugin:
    resource: '@BitBagSyliusInvoicingPlugin/Resources/config/routing.yml'

Finish the installation by updating/migrating the database schema:

$ bin/console doctrine:schema:update --force

Usage

To see what templates you need to override in order to enable this plugin on your storefront, browse Twig files from /tests/Application/app/Resources/SyliusShopBundle path of this plugin.

To override the invoice template, override the invoice.html.twig file of this plugin, which you should do in app/Resources/BitBagSyliusInvoicingPlugin/views/invoice.html.twig file of your local project or in the theme path, in case you are using multiple themes.

In your admin panel, add the company data. So far, only single company data is supported.

In order to see the ability to download invoice, in the checkout, confirm a billing address and fill the VAT number. Make sure you customized your local SyliusShopBundle templates like described above. Then, in the admin panel, you should see a button to download the invoice for an order, which has the billing address with VAT number fulfilled (which in your case, shoul be the last one).

Customization

Available services you can decorate and forms you can extend

  bitbag_sylius_invoicing_plugin.controller.action.download_order_invoice                      BitBag\SyliusInvoicingPlugin\Controller\Action\DownloadOrderInvoice                                       
  bitbag_sylius_invoicing_plugin.controller.company_data                                       Sylius\Bundle\ResourceBundle\Controller\ResourceController                                                
  bitbag_sylius_invoicing_plugin.controller.invoice                                            Sylius\Bundle\ResourceBundle\Controller\ResourceController                                                
  bitbag_sylius_invoicing_plugin.event_listener.company_data                                   BitBag\SyliusInvoicingPlugin\Menu\CompanyDataMenuBuilder                                                  
  bitbag_sylius_invoicing_plugin.event_listener.order_show                                     BitBag\SyliusInvoicingPlugin\Menu\DownloadInvoiceMenuBuilder                                              
  bitbag_sylius_invoicing_plugin.factory.company_data                                          Sylius\Component\Resource\Factory\Factory                                                                 
  bitbag_sylius_invoicing_plugin.factory.invoice                                               Sylius\Component\Resource\Factory\Factory                                                                 
  bitbag_sylius_invoicing_plugin.file_generator.invoice_filename                               BitBag\SyliusInvoicingPlugin\FileGenerator\InvoicePdfFilenameGenerator                                        
  bitbag_sylius_invoicing_plugin.file_generator.invoice_file                                   BitBag\SyliusInvoicingPlugin\FileGenerator\InvoicePdfFileGenerator                                        
  bitbag_sylius_invoicing_plugin.form.extension.address                                        BitBag\SyliusInvoicingPlugin\Form\Extension\AddressTypeExtension                                          
  bitbag_sylius_invoicing_plugin.form.type.company_data                                        BitBag\SyliusInvoicingPlugin\Form\Type\CompanyDataType                                                    
  bitbag_sylius_invoicing_plugin.form.type.invoice                                             BitBag\SyliusInvoicingPlugin\Form\Type\InvoiceType                                                        
  bitbag_sylius_invoicing_plugin.manager.company_data                                          alias for "doctrine.orm.default_entity_manager"                                                           
  bitbag_sylius_invoicing_plugin.manager.invoice                                               alias for "doctrine.orm.default_entity_manager"                                                           
  bitbag_sylius_invoicing_plugin.repository.company_data                                       BitBag\SyliusInvoicingPlugin\Repository\CompanyDataRepository                                             
  bitbag_sylius_invoicing_plugin.repository.invoice                                            BitBag\SyliusInvoicingPlugin\Repository\InvoiceRepository                                                 
  bitbag_sylius_invoicing_plugin.resolver.company_data                                         BitBag\SyliusInvoicingPlugin\Resolver\CompanyDataResolver                                                 
  bitbag_sylius_invoicing_plugin.resolver.invoice_file                                         BitBag\SyliusInvoicingPlugin\Resolver\InvoiceFileResolver                                                 
  bitbag_sylius_invoicing_plugin.validator.vat_number                                          BitBag\SyliusInvoicingPlugin\Validator\Constraints\VatNumberValidator

Parameters you can override in your parameters.yml(.dist) file

parameters:
    wkhtmltopdf_binary_path: /usr/local/bin/wkhtmltopdf
    invoices_root_dir: "%kernel.project_dir%/var/invoices"

Testing

$ composer install
$ cd tests/Application
$ yarn install
$ yarn run gulp
$ bin/console assets:install web -e test
$ bin/console doctrine:schema:create -e test
$ bin/console server:run 127.0.0.1:8080 -d web -e test
$ open http://localhost:8080
$ bin/behat
$ bin/phpspec run

Contribution

Learn more about our contribution workflow on http://docs.sylius.org/en/latest/contributing/.

syliusinvoicingplugin's People

Contributors

ambroisemaupate avatar bitbager avatar czende avatar juchi avatar lchrusciel avatar lsmith77 avatar marek-pietrzak-tg avatar pamil avatar patrick477 avatar pjedrzejewski avatar steadexe avatar stefandoorn avatar zales0123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

syliusinvoicingplugin's Issues

Invoice path should be stored relatively to invoices_root_dir

Once invoice file has been generated, its absolute path is hardcoded in database. This could be a problem if you want to move your Sylius project elsewhere!

Could we just store path relative to invoices_root_dir parameter, so that we just store 19be581a08453.pdf in database. This would much more portable.

[FR] Generate invoices at «complete» Order state and invoice number template

I will try to create a PR for this.

French law requires e-commerce resellers to:

  • send invoices for their customers even if they’re not professional and even without VAT number,
  • have unique and consecutive invoice numbers for the same selling unit (channel)

So I suggest to enhance this plugin to subscribe to the Sylius order completed state to generate invoice only if payment has succeded, not to generate invoices all the time (kind of boring to generate cancelled invoices if user changes his mind before payment). In this case, invoices are acting like order receipts that resellers have to print and include into the shipping box at least, but it occurs after payment and not before.

For the unique and consecutive invoice numbers, I suggest to add configurable and automatic number template. For example: WEB-YYYY-XXXXX should stand for WEB-2018-00001 for the first invoice generated in 2018. We can even use channel code such as in $channel-YYYY-XXXXX. This invoice number template could be editable in the config.yml or, even better, in the CompanyData entity.

  • I can provide this invoice number generator feature in a Composer lib as I’ve already developed this for an other PHP project.

These features may lead too far from this original plugin goal, but we can add this as an optional
and configurable features.

Sorry for the long issue… 🥔

Call to a member function get() on null

Hi, when I want to add or edit address in frontstore in my account I'm getting this error:

screen shot 2018-03-13 at 01 06 14

Moreover I'm still not able to get this plugin works. I've override two twig templates that you are describing in the readme, but still without success. My bitbag_invoicing_invoice table is still empty. I'm I missing something? wkhtmltopdf installed, company data filled, billing adress in checkout step filled. Is it supposed to generate invoice after every complete step? I'm on sylius-standard 1.1.1 and invoice-plugin:dev-master. Thx!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.