Invoice settings: Reorder and explain recommended options (#3572)

This commit is contained in:
Raphael Michel
2023-09-05 16:42:16 +02:00
committed by GitHub
parent c1ebbfe82a
commit 6a36efd18c
2 changed files with 26 additions and 5 deletions
+3 -3
View File
@@ -1033,10 +1033,10 @@ DEFAULTS = {
widget=forms.RadioSelect, widget=forms.RadioSelect,
choices=( choices=(
('False', _('Do not generate invoices')), ('False', _('Do not generate invoices')),
('admin', _('Only manually in admin panel')), ('paid', _('Automatically after payment or when required by payment method')),
('True', _('Automatically before payment for all created orders')),
('user', _('Automatically on user request')), ('user', _('Automatically on user request')),
('True', _('Automatically for all created orders')), ('admin', _('Only manually in admin panel')),
('paid', _('Automatically on payment or when required by payment method')),
), ),
help_text=_("Invoices will never be automatically generated for free orders.") help_text=_("Invoices will never be automatically generated for free orders.")
) )
+23 -2
View File
@@ -49,7 +49,7 @@ from django.forms import (
) )
from django.urls import reverse from django.urls import reverse
from django.utils.functional import cached_property from django.utils.functional import cached_property
from django.utils.html import escape from django.utils.html import escape, format_html
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.timezone import get_current_timezone_name from django.utils.timezone import get_current_timezone_name
from django.utils.translation import gettext, gettext_lazy as _, pgettext_lazy from django.utils.translation import gettext, gettext_lazy as _, pgettext_lazy
@@ -66,7 +66,7 @@ from pretix.base.models import Event, Organizer, TaxRule, Team
from pretix.base.models.event import EventFooterLink, EventMetaValue, SubEvent from pretix.base.models.event import EventFooterLink, EventMetaValue, SubEvent
from pretix.base.reldate import RelativeDateField, RelativeDateTimeField from pretix.base.reldate import RelativeDateField, RelativeDateTimeField
from pretix.base.settings import ( from pretix.base.settings import (
COUNTRIES_WITH_STATE_IN_ADDRESS, PERSON_NAME_SCHEMES, COUNTRIES_WITH_STATE_IN_ADDRESS, DEFAULTS, PERSON_NAME_SCHEMES,
PERSON_NAME_TITLE_GROUPS, validate_event_settings, PERSON_NAME_TITLE_GROUPS, validate_event_settings,
) )
from pretix.base.validators import multimail_validate from pretix.base.validators import multimail_validate
@@ -900,6 +900,27 @@ class InvoiceSettingsForm(EventSettingsValidationMixin, SettingsForm):
) )
self.fields['invoice_numbers_counter_length'].validators.append(MaxValueValidator(15)) self.fields['invoice_numbers_counter_length'].validators.append(MaxValueValidator(15))
pps = [str(pp.verbose_name) for pp in event.get_payment_providers().values() if pp.requires_invoice_immediately]
if pps:
generate_paid_help_text = _('An invoice will be issued before payment if the customer selects one of the following payment methods: {list}').format(
list=', '.join(pps)
)
else:
generate_paid_help_text = _('None of the currently configured payment methods will cause an invoice to be issued before payment.')
generate_choices = list(DEFAULTS['invoice_generate']['form_kwargs']['choices'])
idx = [i for i, t in enumerate(generate_choices) if t[0] == 'paid'][0]
generate_choices[idx] = (
'paid',
format_html(
'{} <span class="label label-success">{}</span><br><span class="text-muted">{}</span>',
generate_choices[idx][1],
_('Recommended'),
generate_paid_help_text
)
)
self.fields['invoice_generate'].choices = generate_choices
def contains_web_channel_validate(val): def contains_web_channel_validate(val):
if "web" not in val: if "web" not in val: