Add field internal_reference to invoice addresses

This commit is contained in:
Raphael Michel
2017-10-27 00:49:56 +02:00
parent 2b8d12f987
commit b857157c7b
14 changed files with 73 additions and 8 deletions
+8
View File
@@ -41,6 +41,7 @@ foreign_currency_rate decimal (string) If ``foreign_cu
invoicing time, it is stored here.
foreign_currency_rate_date date If ``foreign_currency_rate`` is set, this signifies the
date at which the currency rate was obtained.
internal_reference string Customer's reference to be printed on the invoice.
===================================== ========================== =======================================================
@@ -57,6 +58,11 @@ foreign_currency_rate_date date If ``foreign_cu
``foreign_currency_rate_date`` have been added.
.. versionchanged:: 1.9
The attribute ``internal_reference`` has been added.
Endpoints
---------
@@ -95,6 +101,7 @@ Endpoints
"refers": null,
"locale": "en",
"introductory_text": "thank you for your purchase of the following items:",
"internal_reference": "",
"additional_text": "We are looking forward to see you on our conference!",
"payment_provider_text": "Please transfer the money to our account ABC…",
"footer_text": "Big Events LLC - Registration No. 123456 - VAT ID: EU0987654321",
@@ -158,6 +165,7 @@ Endpoints
"refers": null,
"locale": "en",
"introductory_text": "thank you for your purchase of the following items:",
"internal_reference": "",
"additional_text": "We are looking forward to see you on our conference!",
"payment_provider_text": "Please transfer the money to our account ABC…",
"footer_text": "Big Events LLC - Registration No. 123456 - VAT ID: EU0987654321",
+7
View File
@@ -43,6 +43,7 @@ invoice_address object Invoice address
├ zipcode string Customer ZIP code
├ city string Customer city
├ country string Customer country
├ internal_reference string Customer's internal reference to be printed on the invoice
├ vat_id string Customer VAT ID
└ vat_id_validated string ``True``, if the VAT ID has been validated against the
EU VAT service and validation was successful. This only
@@ -80,6 +81,10 @@ downloads list of objects List of ticket
The attributes ``order.payment_fee``, ``order.payment_fee_tax_rate`` and ``order.payment_fee_tax_value`` have been
deprecated in favour of the new ``fees`` attribute but will still be served and removed in 1.9.
.. versionchanged:: 1.9
The attribute ``invoice_address.internal_reference`` has been added.
Order position resource
-----------------------
@@ -170,6 +175,7 @@ Order endpoints
"zipcode": "12345",
"city": "Testington",
"country": "Testikistan",
"internal_reference": "",
"vat_id": "EU123456789",
"vat_id_validated": False
},
@@ -275,6 +281,7 @@ Order endpoints
"zipcode": "12345",
"city": "Testington",
"country": "Testikistan",
"internal_reference": "",
"vat_id": "EU123456789",
"vat_id_validated": False
},
+3 -2
View File
@@ -26,7 +26,7 @@ class InvoiceAdddressSerializer(I18nAwareModelSerializer):
class Meta:
model = InvoiceAddress
fields = ('last_modified', 'is_business', 'company', 'name', 'street', 'zipcode', 'city', 'country', 'vat_id',
'vat_id_validated')
'vat_id_validated', 'internal_reference')
class AnswerSerializer(I18nAwareModelSerializer):
@@ -153,4 +153,5 @@ class InvoiceSerializer(I18nAwareModelSerializer):
model = Invoice
fields = ('order', 'number', 'is_cancellation', 'invoice_from', 'invoice_to', 'date', 'refers', 'locale',
'introductory_text', 'additional_text', 'payment_provider_text', 'footer_text', 'lines',
'foreign_currency_display', 'foreign_currency_rate', 'foreign_currency_rate_date')
'foreign_currency_display', 'foreign_currency_rate', 'foreign_currency_rate_date',
'internal_reference')
+6
View File
@@ -331,6 +331,12 @@ class ClassicInvoiceRenderer(BaseReportlabInvoiceRenderer):
NextPageTemplate('OtherPages'),
]
if self.invoice.internal_reference:
story.append(Paragraph(
pgettext('invoice', 'Your reference: {reference}').format(reference=self.invoice.internal_reference),
self.stylesheet['Normal']
))
if self.invoice.introductory_text:
story.append(Paragraph(self.invoice.introductory_text, self.stylesheet['Normal']))
story.append(Spacer(1, 10 * mm))
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-10-26 22:13
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pretixbase', '0081_quota_cached_availability_paid_orders'),
]
operations = [
migrations.AddField(
model_name='invoiceaddress',
name='internal_reference',
field=models.TextField(blank=True, help_text='This reference will be printed on your invoice for your convenience.', verbose_name='Internal reference'),
),
migrations.AddField(
model_name='invoice',
name='internal_reference',
field=models.TextField(blank=True),
),
]
+1
View File
@@ -81,6 +81,7 @@ class Invoice(models.Model):
foreign_currency_rate = models.DecimalField(decimal_places=4, max_digits=10, null=True, blank=True)
foreign_currency_rate_date = models.DateField(null=True, blank=True)
file = models.FileField(null=True, blank=True, upload_to=invoice_filename)
internal_reference = models.TextField(blank=True)
@staticmethod
def _to_numeric_invoice_number(number):
+5
View File
@@ -881,6 +881,11 @@ class InvoiceAddress(models.Model):
vat_id = models.CharField(max_length=255, blank=True, verbose_name=_('VAT ID'),
help_text=_('Only for business customers within the EU.'))
vat_id_validated = models.BooleanField(default=False)
internal_reference = models.TextField(
verbose_name=_('Internal reference'),
help_text=_('This reference will be printed on your invoice for your convenience.'),
blank=True
)
def cachedticket_name(instance, filename: str) -> str:
+6 -5
View File
@@ -54,13 +54,14 @@ def build_invoice(invoice: Invoice) -> Invoice:
{i.zipcode} {i.city}
{country}""")
invoice.invoice_to = addr_template.format(
i=invoice.order.invoice_address,
country=invoice.order.invoice_address.country.name if invoice.order.invoice_address.country else invoice.order.invoice_address.country_old
i=ia,
country=ia.country.name if ia.country else ia.country_old
).strip()
if invoice.order.invoice_address.vat_id:
invoice.invoice_to += "\n" + pgettext("invoice", "VAT-ID: %s") % invoice.order.invoice_address.vat_id
invoice.internal_reference = ia.internal_reference
if ia.vat_id:
invoice.invoice_to += "\n" + pgettext("invoice", "VAT-ID: %s") % ia.vat_id
cc = str(invoice.order.invoice_address.country)
cc = str(ia.country)
if cc in EU_CURRENCIES and EU_CURRENCIES[cc] != invoice.event.currency:
invoice.foreign_currency_display = EU_CURRENCIES[cc]
@@ -393,6 +393,8 @@
{% endif %}
</dd>
{% endif %}
<dt>{% trans "Internal reference" %}</dt>
<dd>{{ order.invoice_address.internal_reference }}</dd>
</dl>
</div>
</div>
+3 -1
View File
@@ -85,7 +85,8 @@ class InvoiceAddressForm(forms.ModelForm):
class Meta:
model = InvoiceAddress
fields = ('is_business', 'company', 'name', 'street', 'zipcode', 'city', 'country', 'vat_id')
fields = ('is_business', 'company', 'name', 'street', 'zipcode', 'city', 'country', 'vat_id',
'internal_reference')
widgets = {
'is_business': BusinessBooleanRadio,
'street': forms.Textarea(attrs={'rows': 2, 'placeholder': _('Street and Number')}),
@@ -93,6 +94,7 @@ class InvoiceAddressForm(forms.ModelForm):
'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'}),
'internal_reference': forms.TextInput,
}
labels = {
'is_business': ''
@@ -90,6 +90,8 @@
<dt>{% trans "VAT ID" %}</dt>
<dd>{{ addr.vat_id }}</dd>
{% endif %}
<dt>{% trans "Internal reference" %}</dt>
<dd>{{ addr.internal_reference }}</dd>
</dl>
</div>
</div>
@@ -188,6 +188,8 @@
<dt>{% trans "VAT ID" %}</dt>
<dd>{{ order.invoice_address.vat_id }}</dd>
{% endif %}
<dt>{% trans "Internal Reference" %}</dt>
<dd>{{ order.invoice_address.internal_reference }}</dd>
</dl>
</div>
</div>
+1
View File
@@ -409,6 +409,7 @@ class OrderInvoiceCreate(EventViewMixin, OrderDetailMixin, View):
class OrderModify(EventViewMixin, OrderDetailMixin, QuestionsViewMixin, TemplateView):
template_name = "pretixpresale/event/order_modify.html"
@cached_property
def _positions_for_questions(self):
return self.positions
+2
View File
@@ -106,6 +106,7 @@ TEST_ORDER_RES = {
"zipcode": "",
"city": "",
"country": "NZ",
"internal_reference": "",
"vat_id": "",
"vat_id_validated": False
},
@@ -294,6 +295,7 @@ TEST_INVOICE_RES = {
"refers": None,
"locale": "en",
"introductory_text": "",
"internal_reference": "",
"additional_text": "",
"payment_provider_text": "",
"footer_text": "",