BitBagCommerce / SyliusInvoicingPlugin

This plugin enables generating invoices in Sylius platform application.
MIT License
20 stars 3 forks source link

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

Open ambroisemaupate opened 6 years ago

ambroisemaupate commented 6 years ago

I will try to create a PR for this.

French law requires e-commerce resellers to:

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.


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… 🥔

bitbager commented 6 years ago

Hi! Thanks, that's a lot of information. First, I think we should consider making CompanyData aware of Channels. I also believe that we should be able to configure whether the VAT number for this specific channel should be validated and if it should be sent to the customer after the payment has proceeded. Doing it the same way as it's done in the channel config with skip payment/shipment step if one available would be perfect. We should remember that it's a plugin and it should solve more than one problem, as there might be users who would need to use it in another way the French law allows.

Secondary, although payment event is great, you should consider a state machine callback for this purpose. Payments are not being managed through resource events, they do through the state machine though.

What do you think?

ambroisemaupate commented 6 years ago

Hi @bitbager
Thanks for you interest !

Making CompanyData aware of Channels is a great idea, so we could add:

It’s my first project with Sylius, so I’m new with their payment state machine.

See https://github.com/ambroisemaupate/SyliusInvoicingPlugin/commits/channel-aware WIP branch.

bitbager commented 6 years ago

I think that all of these data should be assofisted with CompanyData model. Also allowing string template path is not a good idea. Let’s make it a ChoiceType of constants and for customization, we will include a reference to Symfony FormExtension documentation. How is the progress btw? 😉

ambroisemaupate commented 6 years ago

Progress is good!
Invoice generation and email sending is done on Payment state-machine transition, I’ve added all fields into CompanyData. I need now to make invoice number configurable and improve invoice template to display VAT, Shipping and reductions.

I’ll publish my PR when I’m back on this project. 🤞
Do not hesitate to have a look on my branch… https://github.com/ambroisemaupate/SyliusInvoicingPlugin/commits/channel-aware