From 5747984917a0bacb9d44b4c9c218c93fc9ba7e9e Mon Sep 17 00:00:00 2001
From: Dominik George <dominik.george@teckids.org>
Date: Tue, 15 Mar 2022 21:03:49 +0100
Subject: [PATCH] Expect purchased items to list net prices

---
 CHANGELOG.rst                                          | 5 +++++
 aleksis/apps/tezor/locale/de_DE/LC_MESSAGES/django.po  | 8 ++++----
 aleksis/apps/tezor/migrations/0003_manual_invoicing.py | 2 +-
 aleksis/apps/tezor/models/invoice.py                   | 6 +++---
 aleksis/apps/tezor/tables.py                           | 2 +-
 5 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index cbcb92e..dc6e4a7 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -19,6 +19,11 @@ Fixed
 
 * Add a missing dependency for Sofort payments
 
+Changed
+~~~~~~~
+
+* Purchased items are expected to list net prices
+
 `1.0.2`_ - 2022-03-14
 ---------------------
 
diff --git a/aleksis/apps/tezor/locale/de_DE/LC_MESSAGES/django.po b/aleksis/apps/tezor/locale/de_DE/LC_MESSAGES/django.po
index 33247d9..fae5821 100644
--- a/aleksis/apps/tezor/locale/de_DE/LC_MESSAGES/django.po
+++ b/aleksis/apps/tezor/locale/de_DE/LC_MESSAGES/django.po
@@ -88,8 +88,8 @@ msgid "Can send invoice by email"
 msgstr "Kann Rechnung als E-Mail versenden"
 
 #: aleksis/apps/tezor/models/invoice.py:150
-msgid "Included VAT {} %"
-msgstr "Enthaltene MwSt {} %"
+msgid "VAT {} %"
+msgstr "MWSt. {} %"
 
 #: aleksis/apps/tezor/models/invoice.py:158
 msgid "Gross total"
@@ -104,8 +104,8 @@ msgid "Purchased item"
 msgstr "Gekaufter Artikel"
 
 #: aleksis/apps/tezor/models/invoice.py:180
-msgid "Item gross price"
-msgstr "Artikel Bruttopreis"
+msgid "Item net price"
+msgstr "Artikel-Nettopreis"
 
 #: aleksis/apps/tezor/models/invoice.py:182
 msgid "Currency"
diff --git a/aleksis/apps/tezor/migrations/0003_manual_invoicing.py b/aleksis/apps/tezor/migrations/0003_manual_invoicing.py
index efff727..90b7100 100644
--- a/aleksis/apps/tezor/migrations/0003_manual_invoicing.py
+++ b/aleksis/apps/tezor/migrations/0003_manual_invoicing.py
@@ -21,7 +21,7 @@ class Migration(migrations.Migration):
                 ('extended_data', models.JSONField(default=dict, editable=False)),
                 ('sku', models.CharField(blank=True, max_length=255, verbose_name='Article no.')),
                 ('description', models.CharField(max_length=255, verbose_name='Purchased item')),
-                ('price', models.DecimalField(decimal_places=2, default='0.0', max_digits=9, verbose_name='Item gross price')),
+                ('price', models.DecimalField(decimal_places=2, default='0.0', max_digits=9, verbose_name='Item net price')),
                 ('currency', models.CharField(max_length=10, verbose_name='Currency')),
                 ('tax_rate', models.DecimalField(decimal_places=1, default='0.0', max_digits=4, verbose_name='Tax rate')),
             ],
diff --git a/aleksis/apps/tezor/models/invoice.py b/aleksis/apps/tezor/models/invoice.py
index 03978c8..b870daf 100644
--- a/aleksis/apps/tezor/models/invoice.py
+++ b/aleksis/apps/tezor/models/invoice.py
@@ -168,13 +168,13 @@ class Invoice(BasePayment, PureDjangoModel):
         tax_amounts = {}
         for item in self.get_purchased_items():
             tax_amounts.setdefault(item.tax_rate, 0)
-            tax_amounts[item.tax_rate] += item.price / (item.tax_rate + 100) * item.tax_rate
+            tax_amounts[item.tax_rate] += item.price * item.tax_rate
 
         values = []
         for tax_rate, total in tax_amounts.items():
             values.append(
                 {
-                    "name": _("Included VAT {} %").format(tax_rate),
+                    "name": _("VAT {} %").format(tax_rate),
                     "value": total,
                     "currency": self.currency,
                 }
@@ -204,7 +204,7 @@ class InvoiceItem(ExtensibleModel):
     sku = models.CharField(max_length=255, verbose_name=_("Article no."), blank=True)
     description = models.CharField(max_length=255, verbose_name=_("Purchased item"))
     price = models.DecimalField(
-        verbose_name=_("Item gross price"), max_digits=9, decimal_places=2, default="0.0"
+        verbose_name=_("Item net price"), max_digits=9, decimal_places=2, default="0.0"
     )
     currency = models.CharField(max_length=10, verbose_name=_("Currency"))
     tax_rate = models.DecimalField(
diff --git a/aleksis/apps/tezor/tables.py b/aleksis/apps/tezor/tables.py
index f1d1c23..b9f2f41 100644
--- a/aleksis/apps/tezor/tables.py
+++ b/aleksis/apps/tezor/tables.py
@@ -14,7 +14,7 @@ class PurchasedItemsTable(tables.Table):
     )
     quantity = tables.Column(verbose_name=_("Qty."), attrs={"td": {"class": "right-align"}})
     price = tables.TemplateColumn(
-        verbose_name=_("Gross"),
+        verbose_name=_("Net"),
         template_code="{{value|floatformat:2}} {{record.currency}}",
         attrs={"td": {"class": "right-align"}},
     )
-- 
GitLab