forked from CGM_Public/pretix_original
Allow to only require the name in the invoice address
This commit is contained in:
@@ -45,6 +45,10 @@ DEFAULTS = {
|
||||
'default': 'True',
|
||||
'type': bool,
|
||||
},
|
||||
'invoice_name_required': {
|
||||
'default': 'False',
|
||||
'type': bool,
|
||||
},
|
||||
'invoice_address_required': {
|
||||
'default': 'False',
|
||||
'type': bool,
|
||||
|
||||
@@ -436,6 +436,14 @@ class InvoiceSettingsForm(SettingsForm):
|
||||
required=False,
|
||||
widget=forms.CheckboxInput(attrs={'data-checkbox-dependency': '#id_invoice_address_asked'}),
|
||||
)
|
||||
invoice_name_required = forms.BooleanField(
|
||||
label=_("Require customer name"),
|
||||
required=False,
|
||||
widget=forms.CheckboxInput(
|
||||
attrs={'data-checkbox-dependency': '#id_invoice_address_asked',
|
||||
'data-inverse-dependency': '#id_invoice_address_required'}
|
||||
),
|
||||
)
|
||||
invoice_address_vatid = forms.BooleanField(
|
||||
label=_("Ask for VAT ID"),
|
||||
help_text=_("Does only work if an invoice address is asked for. VAT ID is not required."),
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<legend>{% trans "Invoicing" %}</legend>
|
||||
{% bootstrap_field form.invoice_address_asked layout="horizontal" %}
|
||||
{% bootstrap_field form.invoice_address_required layout="horizontal" %}
|
||||
{% bootstrap_field form.invoice_name_required layout="horizontal" %}
|
||||
{% bootstrap_field form.invoice_address_vatid layout="horizontal" %}
|
||||
{% bootstrap_field form.invoice_numbers_consecutive layout="horizontal" %}
|
||||
{% bootstrap_field form.invoice_numbers_prefix layout="horizontal" %}
|
||||
|
||||
@@ -84,9 +84,8 @@ class InvoiceAddressForm(forms.ModelForm):
|
||||
'is_business': BusinessBooleanRadio,
|
||||
'street': forms.Textarea(attrs={'rows': 2, 'placeholder': _('Street and Number')}),
|
||||
'company': forms.TextInput(attrs={'data-typocheck-source': '1',
|
||||
'data-display-dependency': '#id_is_business_1',
|
||||
'data-required-if': '#id_is_business_1'}),
|
||||
'name': forms.TextInput(attrs={'data-typocheck-source': '1', 'data-required-if': '#id_is_business_0'}),
|
||||
'data-display-dependency': '#id_is_business_1'}),
|
||||
'name': forms.TextInput(attrs={'data-typocheck-source': '1'}),
|
||||
'vat_id': forms.TextInput(attrs={'data-display-dependency': '#id_is_business_1'}),
|
||||
}
|
||||
labels = {
|
||||
@@ -105,6 +104,12 @@ class InvoiceAddressForm(forms.ModelForm):
|
||||
if 'required' in f.widget.attrs:
|
||||
del f.widget.attrs['required']
|
||||
|
||||
if event.settings.invoice_name_required:
|
||||
self.fields['name'].required = True
|
||||
else:
|
||||
self.fields['company'].widget.attrs['data-required-if'] = '#id_is_business_1'
|
||||
self.fields['name'].widget.attrs['data-required-if'] = '#id_is_business_0'
|
||||
|
||||
def clean(self):
|
||||
data = self.cleaned_data
|
||||
if not data['name'] and not data['company'] and self.event.settings.invoice_address_required:
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a class="{% if not event.settings.invoice_address_required %} collapsed {% endif %}" data-toggle="collapse" href="#invoice">
|
||||
<strong>{% trans "Invoice information" %}{% if not event.settings.invoice_address_required %}
|
||||
<a class="{% if not event.settings.invoice_address_required and not event.settings.invoice_name_required %} collapsed{% endif %}" data-toggle="collapse" href="#invoice">
|
||||
<strong>{% trans "Invoice information" %}{% if not event.settings.invoice_address_required and not event.settings.invoice_name_required %}
|
||||
{% trans "(optional)" %}
|
||||
{% endif %}</strong>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="invoice" class="panel-collapse collapse {% if event.settings.invoice_address_required %} in {% endif %}">
|
||||
<div id="invoice" class="panel-collapse collapse{% if event.settings.invoice_address_required or event.settings.invoice_name_required %} in {% endif %}">
|
||||
<div class="panel-body">
|
||||
{% bootstrap_form invoice_form layout="horizontal" %}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user