From 157a16810d27bc0644e9581ea2362ed25abd51ac Mon Sep 17 00:00:00 2001 From: Tobias Kunze Date: Mon, 22 Aug 2016 17:19:45 +0200 Subject: [PATCH] Add a net_value column to invoices TODO: localization --- src/pretix/base/models/invoices.py | 4 ++++ src/pretix/base/services/invoices.py | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/pretix/base/models/invoices.py b/src/pretix/base/models/invoices.py index 620ca527c0..7148afe78c 100644 --- a/src/pretix/base/models/invoices.py +++ b/src/pretix/base/models/invoices.py @@ -135,3 +135,7 @@ class InvoiceLine(models.Model): gross_value = models.DecimalField(max_digits=10, decimal_places=2) tax_value = models.DecimalField(max_digits=10, decimal_places=2, default=Decimal('0.00')) tax_rate = models.DecimalField(max_digits=7, decimal_places=2, default=Decimal('0.00')) + + @property + def net_value(self): + return self.gross_value - self.tax_value diff --git a/src/pretix/base/services/invoices.py b/src/pretix/base/services/invoices.py index 7e9d4005c2..98f6834bae 100644 --- a/src/pretix/base/services/invoices.py +++ b/src/pretix/base/services/invoices.py @@ -309,20 +309,26 @@ def _invoice_generate_german(invoice, f): ('LEFTPADDING', (0, 0), (0, -1), 0), ('RIGHTPADDING', (-1, 0), (-1, -1), 0), ] - tdata = [(pgettext('invoice', 'Description'), pgettext('invoice', 'Tax rate'), pgettext('invoice', 'Price'))] + tdata = [( + pgettext('invoice', 'Description'), + pgettext('invoice', 'Tax rate'), + pgettext('invoice', 'Net'), + pgettext('invoice', 'Gross'), + )] total = Decimal('0.00') for line in invoice.lines.all(): tdata.append(( line.description, lformat("%.2f", line.tax_rate) + " %", + lformat("%.2f", line.net_value) + " " + invoice.event.currency, lformat("%.2f", line.gross_value) + " " + invoice.event.currency, )) taxvalue_map[line.tax_rate] += line.tax_value grossvalue_map[line.tax_rate] += line.gross_value total += line.gross_value - tdata.append([pgettext('invoice', 'Invoice total'), '', lformat("%.2f", total) + " " + invoice.event.currency]) - colwidths = [a * doc.width for a in (.60, .20, .20)] + tdata.append([pgettext('invoice', 'Invoice total'), '', '', lformat("%.2f", total) + " " + invoice.event.currency]) + colwidths = [a * doc.width for a in (.55, .15, .15, .15)] table = Table(tdata, colWidths=colwidths, repeatRows=1) table.setStyle(TableStyle(tstyledata)) story.append(table)