mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
Pluggable invoice transmission methods (#5020)
* Flexible invoice transmission
* UI work
* Add peppol and output
* API support
* Profile integration
* Simplify form for individuals
* Remove sent_to_customer usage
* more steps
* Revert "Bank transfer: Allow to send the invoice direclty to the accounting department (#2975)"
This reverts commit cea6c340be.
* minor fixes
* Fixes after rebase
* update stati
* Backend view
* Transmit and show status
* status, retransmission
* API retransmission
* More fields
* API docs
* Plugin docs
* Update migration
* Add missing license headers
* Remove dead code, fix current tests
* Run isort
* Update regex
* Rebase migration
* Fix migration
* Add tests, fix bugs
* Rebase migration
* Apply suggestion from @luelista
Co-authored-by: luelista <weller@rami.io>
* Apply suggestion from @luelista
Co-authored-by: luelista <weller@rami.io>
* Apply suggestion from @luelista
Co-authored-by: luelista <weller@rami.io>
* Apply suggestion from @luelista
Co-authored-by: luelista <weller@rami.io>
* Apply suggestion from @luelista
Co-authored-by: luelista <weller@rami.io>
* Make migration reversible
* Add TransmissionType.enforce_transmission
* Fix registries API usage after rebase
* Remove code I forgot to delete
* Update transmission status display depending on type
* Add testmode_supported
* Update src/pretix/static/pretixbase/js/addressform.js
Co-authored-by: luelista <weller@rami.io>
* Update src/pretix/static/pretixbase/js/addressform.js
Co-authored-by: luelista <weller@rami.io>
* Update src/pretix/static/pretixbase/js/addressform.js
Co-authored-by: luelista <weller@rami.io>
* New mechanism for non-required invoice forms
* Update src/pretix/base/invoicing/transmission.py
Co-authored-by: luelista <weller@rami.io>
* Declare testmode_supported for email
* Make transmission_email_other an implementation detail
* Fix failing tests and add new ones
* Update src/pretix/base/services/invoices.py
Co-authored-by: luelista <weller@rami.io>
* Add emails to email history
* Fix comma error
* More generic default email text
* Cleanup
* Remove "email invoices" button and refine logic
* Rebase migration
* Fix edge case
---------
Co-authored-by: luelista <weller@rami.io>
This commit is contained in:
@@ -42,7 +42,7 @@ from django.db.models.functions import Cast
|
||||
from django.utils import timezone
|
||||
from django.utils.crypto import get_random_string
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import pgettext
|
||||
from django.utils.translation import gettext_lazy as _, pgettext
|
||||
from django_scopes import ScopedManager
|
||||
|
||||
from pretix.base.settings import COUNTRIES_WITH_STATE_IN_ADDRESS
|
||||
@@ -110,6 +110,21 @@ class Invoice(models.Model):
|
||||
:param file: The filename of the rendered invoice
|
||||
:type file: File
|
||||
"""
|
||||
TRANSMISSION_STATUS_PENDING = "pending"
|
||||
TRANSMISSION_STATUS_INFLIGHT = "inflight"
|
||||
TRANSMISSION_STATUS_COMPLETED = "completed"
|
||||
TRANSMISSION_STATUS_FAILED = "failed"
|
||||
TRANSMISSION_STATUS_UNKNOWN = "unknown"
|
||||
TRANSMISSION_STATUS_TESTMODE_IGNORED = "testmode_ignored"
|
||||
TRANSMISSION_STATUS_CHOICES = (
|
||||
(TRANSMISSION_STATUS_PENDING, _("pending transmission")),
|
||||
(TRANSMISSION_STATUS_INFLIGHT, _("currently being transmitted")),
|
||||
(TRANSMISSION_STATUS_COMPLETED, _("transmitted")),
|
||||
(TRANSMISSION_STATUS_FAILED, _("failed")),
|
||||
(TRANSMISSION_STATUS_UNKNOWN, _("unknown")),
|
||||
(TRANSMISSION_STATUS_TESTMODE_IGNORED, _("not transmitted due to test mode")),
|
||||
)
|
||||
|
||||
order = models.ForeignKey('Order', related_name='invoices', db_index=True, on_delete=models.CASCADE)
|
||||
organizer = models.ForeignKey('Organizer', related_name='invoices', db_index=True, on_delete=models.PROTECT)
|
||||
event = models.ForeignKey('Event', related_name='invoices', db_index=True, on_delete=models.CASCADE)
|
||||
@@ -131,6 +146,7 @@ class Invoice(models.Model):
|
||||
|
||||
invoice_to = models.TextField()
|
||||
invoice_to_company = models.TextField(null=True)
|
||||
invoice_to_is_business = models.BooleanField(null=True)
|
||||
invoice_to_name = models.TextField(null=True)
|
||||
invoice_to_street = models.TextField(null=True)
|
||||
invoice_to_zipcode = models.CharField(max_length=190, null=True)
|
||||
@@ -139,9 +155,11 @@ class Invoice(models.Model):
|
||||
invoice_to_country = FastCountryField(null=True)
|
||||
invoice_to_vat_id = models.TextField(null=True)
|
||||
invoice_to_beneficiary = models.TextField(null=True)
|
||||
invoice_to_transmission_info = models.JSONField(null=True, blank=True)
|
||||
internal_reference = models.TextField(blank=True)
|
||||
custom_field = models.CharField(max_length=255, null=True)
|
||||
|
||||
created = models.DateTimeField(auto_now_add=True, null=True) # null for backwards compatibility
|
||||
date = models.DateField(default=today)
|
||||
locale = models.CharField(max_length=50, default='en')
|
||||
introductory_text = models.TextField(blank=True)
|
||||
@@ -158,14 +176,28 @@ class Invoice(models.Model):
|
||||
|
||||
shredded = models.BooleanField(default=False)
|
||||
|
||||
# The field sent_to_organizer records whether this invocie was already sent to the organizer by a configured
|
||||
# The field sent_to_organizer records whether this invoice was already sent to the organizer by a configured
|
||||
# mechanism such as email.
|
||||
# NULL: The cronjob that handles sending did not yet run.
|
||||
# True: The invoice was sent.
|
||||
# False: The invoice wasn't sent and never will, because sending was not configured at the time of the check.
|
||||
sent_to_organizer = models.BooleanField(null=True, blank=True)
|
||||
|
||||
sent_to_customer = models.DateTimeField(null=True, blank=True)
|
||||
transmission_type = models.CharField(
|
||||
max_length=255,
|
||||
default="email",
|
||||
)
|
||||
transmission_provider = models.CharField(
|
||||
max_length=255,
|
||||
null=True, blank=True,
|
||||
)
|
||||
transmission_status = models.CharField(
|
||||
max_length=255,
|
||||
choices=TRANSMISSION_STATUS_CHOICES,
|
||||
default=TRANSMISSION_STATUS_UNKNOWN,
|
||||
)
|
||||
transmission_date = models.DateTimeField(null=True, blank=True)
|
||||
transmission_info = models.JSONField(null=True, blank=True)
|
||||
|
||||
file = models.FileField(null=True, blank=True, upload_to=invoice_filename, max_length=255)
|
||||
|
||||
@@ -323,6 +355,19 @@ class Invoice(models.Model):
|
||||
def __str__(self):
|
||||
return self.full_invoice_no
|
||||
|
||||
@property
|
||||
def regenerate_allowed(self):
|
||||
return self.transmission_status in (
|
||||
Invoice.TRANSMISSION_STATUS_UNKNOWN,
|
||||
Invoice.TRANSMISSION_STATUS_PENDING,
|
||||
Invoice.TRANSMISSION_STATUS_FAILED,
|
||||
) and self.event.settings.invoice_regenerate_allowed
|
||||
|
||||
@property
|
||||
def transmission_type_instance(self):
|
||||
from pretix.base.invoicing.transmission import transmission_types
|
||||
return transmission_types.get(identifier=self.transmission_type)[0]
|
||||
|
||||
|
||||
class InvoiceLine(models.Model):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user