forked from CGM_Public/pretix_original
Add beneficiaries to invoice addresses
This commit is contained in:
@@ -275,10 +275,11 @@ class BaseInvoiceAddressForm(forms.ModelForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = InvoiceAddress
|
model = InvoiceAddress
|
||||||
fields = ('is_business', 'company', 'name_parts', 'street', 'zipcode', 'city', 'country', 'vat_id',
|
fields = ('is_business', 'company', 'name_parts', 'street', 'zipcode', 'city', 'country', 'vat_id',
|
||||||
'internal_reference')
|
'internal_reference', 'beneficiary')
|
||||||
widgets = {
|
widgets = {
|
||||||
'is_business': BusinessBooleanRadio,
|
'is_business': BusinessBooleanRadio,
|
||||||
'street': forms.Textarea(attrs={'rows': 2, 'placeholder': _('Street and Number')}),
|
'street': forms.Textarea(attrs={'rows': 2, 'placeholder': _('Street and Number')}),
|
||||||
|
'beneficiary': forms.Textarea(attrs={'rows': 3}),
|
||||||
'company': forms.TextInput(attrs={'data-display-dependency': '#id_is_business_1'}),
|
'company': forms.TextInput(attrs={'data-display-dependency': '#id_is_business_1'}),
|
||||||
'vat_id': forms.TextInput(attrs={'data-display-dependency': '#id_is_business_1'}),
|
'vat_id': forms.TextInput(attrs={'data-display-dependency': '#id_is_business_1'}),
|
||||||
'internal_reference': forms.TextInput,
|
'internal_reference': forms.TextInput,
|
||||||
@@ -325,6 +326,9 @@ class BaseInvoiceAddressForm(forms.ModelForm):
|
|||||||
self.fields['name_parts'].widget.attrs['data-no-required-attr'] = '1'
|
self.fields['name_parts'].widget.attrs['data-no-required-attr'] = '1'
|
||||||
self.fields['company'].widget.attrs['data-required-if'] = '#id_is_business_1'
|
self.fields['company'].widget.attrs['data-required-if'] = '#id_is_business_1'
|
||||||
|
|
||||||
|
if not event.settings.invoice_address_beneficiary:
|
||||||
|
del self.fields['beneficiary']
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
data = self.cleaned_data
|
data = self.cleaned_data
|
||||||
if not data.get('is_business'):
|
if not data.get('is_business'):
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from decimal import Decimal
|
|||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
|
import bleach
|
||||||
import vat_moss.exchange_rates
|
import vat_moss.exchange_rates
|
||||||
from django.contrib.staticfiles import finders
|
from django.contrib.staticfiles import finders
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
@@ -392,6 +393,13 @@ class ClassicInvoiceRenderer(BaseReportlabInvoiceRenderer):
|
|||||||
self.stylesheet['Normal']
|
self.stylesheet['Normal']
|
||||||
))
|
))
|
||||||
|
|
||||||
|
if self.invoice.invoice_to_beneficiary:
|
||||||
|
story.append(Paragraph(
|
||||||
|
pgettext('invoice', 'Beneficiary') + ':<br />' +
|
||||||
|
bleach.clean(self.invoice.invoice_to_beneficiary, tags=[]).replace("\n", "<br />\n"),
|
||||||
|
self.stylesheet['Normal']
|
||||||
|
))
|
||||||
|
|
||||||
if self.invoice.introductory_text:
|
if self.invoice.introductory_text:
|
||||||
story.append(Paragraph(self.invoice.introductory_text, self.stylesheet['Normal']))
|
story.append(Paragraph(self.invoice.introductory_text, self.stylesheet['Normal']))
|
||||||
story.append(Spacer(1, 10 * mm))
|
story.append(Spacer(1, 10 * mm))
|
||||||
|
|||||||
27
src/pretix/base/migrations/0105_auto_20190112_1512.py
Normal file
27
src/pretix/base/migrations/0105_auto_20190112_1512.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Generated by Django 2.1 on 2019-01-12 15:12
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
import jsonfallback.fields
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
import pretix.base.models.fields
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('pretixbase', '0104_auto_20181114_1526'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='invoiceaddress',
|
||||||
|
name='beneficiary',
|
||||||
|
field=models.TextField(blank=True, verbose_name='Beneficiary'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='invoice',
|
||||||
|
name='invoice_to_beneficiary',
|
||||||
|
field=models.TextField(blank=True, null=True, verbose_name='Beneficiary'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -91,6 +91,7 @@ class Invoice(models.Model):
|
|||||||
invoice_to_city = models.TextField(null=True)
|
invoice_to_city = models.TextField(null=True)
|
||||||
invoice_to_country = CountryField(null=True)
|
invoice_to_country = CountryField(null=True)
|
||||||
invoice_to_vat_id = models.TextField(null=True)
|
invoice_to_vat_id = models.TextField(null=True)
|
||||||
|
invoice_to_beneficiary = models.TextField(null=True)
|
||||||
date = models.DateField(default=today)
|
date = models.DateField(default=today)
|
||||||
locale = models.CharField(max_length=50, default='en')
|
locale = models.CharField(max_length=50, default='en')
|
||||||
introductory_text = models.TextField(blank=True)
|
introductory_text = models.TextField(blank=True)
|
||||||
|
|||||||
@@ -1643,6 +1643,10 @@ class InvoiceAddress(models.Model):
|
|||||||
help_text=_('This reference will be printed on your invoice for your convenience.'),
|
help_text=_('This reference will be printed on your invoice for your convenience.'),
|
||||||
blank=True
|
blank=True
|
||||||
)
|
)
|
||||||
|
beneficiary = models.TextField(
|
||||||
|
verbose_name=_('Beneficiary'),
|
||||||
|
blank=True
|
||||||
|
)
|
||||||
|
|
||||||
def save(self, **kwargs):
|
def save(self, **kwargs):
|
||||||
if self.order:
|
if self.order:
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ def build_invoice(invoice: Invoice) -> Invoice:
|
|||||||
invoice.invoice_to_zipcode = ia.zipcode
|
invoice.invoice_to_zipcode = ia.zipcode
|
||||||
invoice.invoice_to_city = ia.city
|
invoice.invoice_to_city = ia.city
|
||||||
invoice.invoice_to_country = ia.country
|
invoice.invoice_to_country = ia.country
|
||||||
|
invoice.invoice_to_beneficiary = ia.beneficiary
|
||||||
|
|
||||||
if ia.vat_id:
|
if ia.vat_id:
|
||||||
invoice.invoice_to += "\n" + pgettext("invoice", "VAT-ID: %s") % ia.vat_id
|
invoice.invoice_to += "\n" + pgettext("invoice", "VAT-ID: %s") % ia.vat_id
|
||||||
@@ -310,6 +311,7 @@ def build_preview_invoice_pdf(event):
|
|||||||
invoice.invoice_to_name, invoice.invoice_to_street,
|
invoice.invoice_to_name, invoice.invoice_to_street,
|
||||||
invoice.invoice_to_zipcode, invoice.invoice_to_city
|
invoice.invoice_to_zipcode, invoice.invoice_to_city
|
||||||
)
|
)
|
||||||
|
invoice.invoice_to_beneficiary = ''
|
||||||
invoice.file = None
|
invoice.file = None
|
||||||
invoice.save()
|
invoice.save()
|
||||||
invoice.lines.all().delete()
|
invoice.lines.all().delete()
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ DEFAULTS = {
|
|||||||
'default': 'False',
|
'default': 'False',
|
||||||
'type': bool,
|
'type': bool,
|
||||||
},
|
},
|
||||||
|
'invoice_address_beneficiary': {
|
||||||
|
'default': 'False',
|
||||||
|
'type': bool,
|
||||||
|
},
|
||||||
'invoice_address_vatid': {
|
'invoice_address_vatid': {
|
||||||
'default': 'False',
|
'default': 'False',
|
||||||
'type': bool,
|
'type': bool,
|
||||||
|
|||||||
@@ -567,6 +567,11 @@ class InvoiceSettingsForm(SettingsForm):
|
|||||||
widget=forms.CheckboxInput(attrs={'data-checkbox-dependency': '#id_invoice_address_asked'}),
|
widget=forms.CheckboxInput(attrs={'data-checkbox-dependency': '#id_invoice_address_asked'}),
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
|
invoice_address_beneficiary = forms.BooleanField(
|
||||||
|
label=_("Ask for beneficiary"),
|
||||||
|
widget=forms.CheckboxInput(attrs={'data-checkbox-dependency': '#id_invoice_address_asked'}),
|
||||||
|
required=False
|
||||||
|
)
|
||||||
invoice_include_free = forms.BooleanField(
|
invoice_include_free = forms.BooleanField(
|
||||||
label=_("Show free products on invoices"),
|
label=_("Show free products on invoices"),
|
||||||
help_text=_("Note that invoices will never be generated for orders that contain only free "
|
help_text=_("Note that invoices will never be generated for orders that contain only free "
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
{% bootstrap_field form.invoice_name_required layout="control" %}
|
{% bootstrap_field form.invoice_name_required layout="control" %}
|
||||||
{% bootstrap_field form.invoice_address_company_required layout="control" %}
|
{% bootstrap_field form.invoice_address_company_required layout="control" %}
|
||||||
{% bootstrap_field form.invoice_address_vatid layout="control" %}
|
{% bootstrap_field form.invoice_address_vatid layout="control" %}
|
||||||
|
{% bootstrap_field form.invoice_address_beneficiary layout="control" %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{% trans "Your invoice details" %}</legend>
|
<legend>{% trans "Your invoice details" %}</legend>
|
||||||
|
|||||||
Reference in New Issue
Block a user