forked from CGM_Public/pretix_original
Invoices: Allow issuing invoices only to businesses (Z#23220397) (#5807)
* Invoices: Allow issuing invoices only to businesses In situations where every invoice has a significant accounting cost and consumers usually do not need invoices, this can save a lot of money or effort. * Improve backend UI if not qualified for invoice
This commit is contained in:
@@ -521,9 +521,20 @@ def invoice_pdf_task(invoice: int):
|
||||
|
||||
|
||||
def invoice_qualified(order: Order):
|
||||
if order.total == Decimal('0.00') or order.require_approval or \
|
||||
order.sales_channel.identifier not in order.event.settings.get('invoice_generate_sales_channels'):
|
||||
if order.total == Decimal('0.00'):
|
||||
return False
|
||||
if order.require_approval:
|
||||
return False
|
||||
if order.sales_channel.identifier not in order.event.settings.invoice_generate_sales_channels:
|
||||
return False
|
||||
if order.status in (Order.STATUS_CANCELED, Order.STATUS_EXPIRED):
|
||||
return False
|
||||
if order.event.settings.invoice_generate_only_business:
|
||||
try:
|
||||
ia = order.invoice_address
|
||||
return ia.is_business
|
||||
except InvoiceAddress.DoesNotExist:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -1225,6 +1225,15 @@ DEFAULTS = {
|
||||
'default': json.dumps(['web']),
|
||||
'type': list
|
||||
},
|
||||
'invoice_generate_only_business': {
|
||||
'default': 'False',
|
||||
'type': bool,
|
||||
'form_class': forms.BooleanField,
|
||||
'serializer_class': serializers.BooleanField,
|
||||
'form_kwargs': dict(
|
||||
label=_("Only issue invoices to business customers"),
|
||||
)
|
||||
},
|
||||
'invoice_address_from': {
|
||||
'default': '',
|
||||
'type': str,
|
||||
|
||||
Reference in New Issue
Block a user