Open ambroisemaupate opened 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?
Hi @bitbager
Thanks for you interest !
Making CompanyData aware of Channels is a great idea, so we could add:
channel
OneToOne field to CompanyData
invoiceNumberTemplate
string to CompanyData
validateCustomerVatNumber
boolean to CompanyData
or Channel
?generateInvoiceAfterPaymentSuccess
boolean to CompanyData
or Channel
?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.
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? 😉
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
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 forWEB-2018-00001
for the first invoice generated in 2018. We can even usechannel
code such as in$channel-YYYY-XXXXX
. This invoice number template could be editable in theconfig.yml
or, even better, in theCompanyData
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… 🥔