Writing an invoice transmission plugin¶
An invoice transmission provider transports an invoice from the sender to the recipient.
There are pre-defined types of invoice transmission in i-ticket, currently "email", "peppol", and "it_sdi".
You can find more information about them at Transmission types.
New transmission types can not be added by plugins but need to be added to i-ticket itself. However, plugins can provide implementations for the actual transmission. Please read Creating a plugin first, if you haven’t already.
Output registration¶
New invoice transmission providers can be registered through the registry mechanism
1from i-ticket.base.invoicing.transmission import transmission_providers, TransmissionProvider
2
3@transmission_providers.new()
4class SdiTransmissionProvider(TransmissionProvider):
5 identifier = "fatturapa_providerabc"
6 type = "it_sdi"
7 verbose_name = _("FatturaPA through provider ABC")
8 ...
The provider class¶
- class i-ticket.base.invoicing.transmission.TransmissionProvider¶
- TransmissionProvider.identifier¶
A short and unique identifier for this transmission provider. This should only contain lowercase letters and underscores.
This is an abstract attribute, you must override this!
- TransmissionProvider.type¶
Identifier of the transmission type this provider provides.
This is an abstract attribute, you must override this!
- TransmissionProvider.verbose_name¶
A human-readable name for this transmission provider (can be localized).
This is an abstract attribute, you must override this!
- TransmissionProvider.priority¶
Returns a priority that is used for sorting transmission providers. Higher priority will be chosen over lower priority for transmission. Default to 100.
- TransmissionProvider.testmode_supported¶
Whether testmode invoices may be passed to this provider.
- TransmissionProvider.is_ready(event) bool¶
Return whether this provider has all required configuration to be used in this event.
This is an abstract method, you must override this!
- TransmissionProvider.is_available(event, country: Country, is_business: bool) bool¶
Return whether this provider may be used for an invoice for the given recipient country and address type.
This is an abstract method, you must override this!
- TransmissionProvider.transmit(invoice: Invoice)¶
Transmit the invoice. The invoice passed as a parameter will be in status
TRANSMISSION_STATUS_INFLIGHT. Invoices that stay in this state for more than 24h will be retried automatically. Implementations are expected to:Send the invoice.
Update the
transmission_statusto TRANSMISSION_STATUS_COMPLETED or TRANSMISSION_STATUS_FAILED after sending, as well astransmission_infowith provider-specific data, andtransmission_dateto the date and time of completion.Create a log entry of action type
i-ticket.event.order.invoice.sentori-ticket.event.order.invoice.sending_failedwith the fieldsfull_invoice_no,transmission_provider,transmission_typeand a provider-specificdatafield.
Make sure to either handle
invoice.order.testmodeproperly or settestmode_supportedtoFalse.This is an abstract method, you must override this!
- TransmissionProvider.settings_url(event) str | None¶
Return a URL to the settings page of this provider (if any).