Trace order amendments through invoice lines and generate legally compliant invoices

My notes after a brainstorming session with @lin_d_hop on this topic:

  • the previous tech solution would imply to generate invoices at each amendments, which could blow up as users are editing orders heavily (orders are often treated as pre-orders)

  • we need to think about buttons enabling users to generate invoices when they are ready. Invoices would only be generated or re-generated through this action.

  • a new menu would be introduced in the right-hand menu of the edit orders page. Basically a tab listing all invoices for this order (when an invoice is generated and there has been edits to the order, the previous invoice is cancelled and a new one is generated / referencing the old one. If no edits we don’t re-generate an invoice). This menu allows to generate, cancel, view and download.

  • Bulk invoice printing can generate invoices according to the above rules or just read from the stored invoices.

  • Sending invoices per email won’t generate invoice however: we need to simplify and avoid having several places to generate invoices. It’s perhaps out of scope, but if we start storing invoices, maybe we can display them in the customer account and send a link instead of sending them attached in mail. To be confirmed, but this could ease sending the email in bulk.

  • When doing this we need to introduce at some stages a confirm modal (as cancelling a previous invoice e.g. is not a light choice) - just adding this as a reminder

  • Invoice number: perhaps out of scope (dealt in separate feature) but we will need enterprises to be able to choose their invoice prefix (in settings). From there, all invoices from this enterprise have the same prefix and a sequential number.

These ideas will need to be confirmed / checked with a dev when we are ready to pick up new work.

When we will reach this stage I will move this as new issues in github, with the rest of small issues we might tackle at the same time. Note to myself: it could be worth looking into merging both invoice template while we are at it… as it will be a headache to adapt both template if we need to mention some history. But let’s not get too excited about this yet, this will need a deeper analysis.