Right now there is a emerging need to send and receive invoice to the national tax agency or other businesses (b2b).
I propose a similar design like in the Payment module:
- Have a workflow that keep track of the invoice state
- wainting (spooled for a batch send)
- rejected (error, need user intervention)
- done (invoiced accepted)
- waiting (user need to check the invoice)
- done (the user accepted the invoice and is imported in tryton)
- rejected (the user rejected the invoice)
- The business logic need to be implement by other module (referred as from now “gateway”)
- The list of available "gateway"s should be selectable in the invoice form, with some way to restrict the choice
- The list of active “gateways” (for inbound invoices) should be configurable
- The invoice (outbound) can be routed trough multiple gateways
The gateway is what serialize an invoice so it can be sent, or de-serialize the invoice and create a invoice record in tryton without user intervention (if possible).
Each nation do it differently, so this is what the end user need to implement via a custom module (if none provided by the main project)
It’s in charge to advance the state of the workflow.
The gateway can implement both sending and receiving, or just one of them.
What if you want the benefit of a single tryton instance for multiple company, but one company is in another jurisdiction/nation? Right now you cannot do it with a single instance.
In italy (this is just an example), company outside italy can send invoice via the SDI(sistema di interscambio aka “invoice exchange system”) to italian companies. So the company need send a copy of the invoice via another system (but this is a niche case IMHO)
A little bit easier for module development
This will eliminate the need to implement a workflow,work queue and views for each “gateway”. In reality is not a huge amount the developer saves, but at least is code it can’t be “borked” (usually by me).
multiple comunication way
For example in Italy we can send the same invoice via certificate-email, SFTP and web/soap.
In this way the user can choose the gateway he prefers, and switch to another when needed (E.G. service outrage, or waiting the tax agency to release the credential for another communication way).
This post was inspired by the Suministro Inmediato de Información (SII) and my desire to one day make something similar for italy.
This is just a very rough idea, so please comment if this make some sort of sense.