From 373ff1f62c8f1c4804287b88f8722dcb57c519ae Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Thu, 25 Nov 2021 14:44:40 +0100 Subject: [PATCH 01/10] Rend le surnom lisible par la personne --- kfet/templates/kfet/left_account.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/kfet/templates/kfet/left_account.html b/kfet/templates/kfet/left_account.html index aa22cb03..f97c5682 100644 --- a/kfet/templates/kfet/left_account.html +++ b/kfet/templates/kfet/left_account.html @@ -31,9 +31,7 @@

{{ account.name|title }}

- {% if account.negative %} + {% if account.negative and account.balance_ukf < 0 %}

Négatif

diff --git a/kfet/views.py b/kfet/views.py index 569e42a5..fdfb1b0d 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -14,7 +14,18 @@ from django.contrib.auth.models import Permission, User from django.contrib.messages.views import SuccessMessageMixin from django.core.exceptions import SuspiciousOperation from django.db import transaction -from django.db.models import Count, F, Max, OuterRef, Prefetch, Q, Subquery, Sum +from django.db.models import ( + Count, + DecimalField, + ExpressionWrapper, + F, + Max, + OuterRef, + Prefetch, + Q, + Subquery, + Sum, +) from django.forms import ValidationError, formset_factory from django.http import ( Http404, @@ -2013,12 +2024,23 @@ class InventoryRead(DetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - inventoryarticles = ( + inventory_articles = ( InventoryArticle.objects.select_related("article", "article__category") .filter(inventory=self.object) + .annotate( + amount_new=ExpressionWrapper( + F("stock_new") * F("article__price"), + output_field=DecimalField( + max_digits=6, decimal_places=2, default=0 + ), + ) + ) .order_by("article__category__name", "article__name") ) - context["inventoryarts"] = inventoryarticles + context["inventoryarts"] = inventory_articles + context["total_amount"] = inventory_articles.aggregate(total=Sum("amount_new"))[ + "total" + ] return context From aad37752225b13e794b6ef06b112208cb861c10f Mon Sep 17 00:00:00 2001 From: Alice Andres Date: Sat, 28 Jan 2023 15:13:55 +0100 Subject: [PATCH 07/10] fix(kfet): fix js error when cancelling already canceled operation --- kfet/static/kfet/js/history.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kfet/static/kfet/js/history.js b/kfet/static/kfet/js/history.js index 4c2a2664..57829a10 100644 --- a/kfet/static/kfet/js/history.js +++ b/kfet/static/kfet/js/history.js @@ -248,7 +248,7 @@ function KHistory(options = {}) { that.cancel_entry(entry); } if (type == "operation") { - for (let opegroup of data["opegroups_to_update"]) { + for (let opegroup of (data["opegroups_to_update"] || [])) { that.update_opegroup(opegroup) } } From 429e611daaae8e411ce68921a4638513cf26a119 Mon Sep 17 00:00:00 2001 From: Alice Andres Date: Mon, 23 Jan 2023 20:53:02 +0100 Subject: [PATCH 08/10] feat(kfet): more values and formatting --- kfet/static/kfet/css/base/misc.css | 2 +- kfet/templates/kfet/inventory_read.html | 10 ++++----- kfet/views.py | 27 +++++++++++++++++-------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/kfet/static/kfet/css/base/misc.css b/kfet/static/kfet/css/base/misc.css index fab1a33a..97c0ee7e 100644 --- a/kfet/static/kfet/css/base/misc.css +++ b/kfet/static/kfet/css/base/misc.css @@ -61,7 +61,7 @@ ul { } .table td.no-padding { - padding:0; + padding:0 !important; } .table thead { diff --git a/kfet/templates/kfet/inventory_read.html b/kfet/templates/kfet/inventory_read.html index 0d98e2d8..b9020b96 100644 --- a/kfet/templates/kfet/inventory_read.html +++ b/kfet/templates/kfet/inventory_read.html @@ -48,7 +48,6 @@ Stock avant Stock après Erreur - Valeur {% regroup inventoryarts by article.category.name as category_list %} @@ -68,16 +67,17 @@ {{ inventoryart.stock_old }} {{ inventoryart.stock_new }} - {{ inventoryart.stock_error }} - {{ inventoryart.amount_new }} + {{ inventoryart.stock_error }} / {{ inventoryart.amount_error|floatformat:"-2" }} € {% endfor %} {% endfor %} - Total - {{ total_amount }} + Valeurs totales + {{ total_amount_old|floatformat:"-2" }} € + {{ total_amount_new|floatformat:"-2" }} € + {{ total_amount_error|floatformat:"-2" }} € diff --git a/kfet/views.py b/kfet/views.py index fdfb1b0d..15bde0f7 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -2024,23 +2024,34 @@ class InventoryRead(DetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) + output_field = DecimalField(max_digits=10, decimal_places=2, default=0) inventory_articles = ( InventoryArticle.objects.select_related("article", "article__category") .filter(inventory=self.object) .annotate( - amount_new=ExpressionWrapper( - F("stock_new") * F("article__price"), - output_field=DecimalField( - max_digits=6, decimal_places=2, default=0 - ), + amount_error=ExpressionWrapper( + F("stock_error") * F("article__price"), output_field=output_field ) ) .order_by("article__category__name", "article__name") ) context["inventoryarts"] = inventory_articles - context["total_amount"] = inventory_articles.aggregate(total=Sum("amount_new"))[ - "total" - ] + stats = inventory_articles.aggregate( + new=ExpressionWrapper( + Sum(F("stock_new") * F("article__price")), output_field=output_field + ), + error=Sum("amount_error"), + old=ExpressionWrapper( + Sum(F("stock_old") * F("article__price")), output_field=output_field + ), + ) + context.update( + { + "total_amount_old": stats["old"], + "total_amount_new": stats["new"], + "total_amount_error": stats["error"], + } + ) return context From b80426c56fcdb92ef0c001b4e3a4134ce021d7b7 Mon Sep 17 00:00:00 2001 From: Alice Andres Date: Mon, 23 Jan 2023 21:47:34 +0100 Subject: [PATCH 09/10] feat(kfet): message info about prices --- kfet/templates/kfet/inventory_read.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kfet/templates/kfet/inventory_read.html b/kfet/templates/kfet/inventory_read.html index b9020b96..3b308377 100644 --- a/kfet/templates/kfet/inventory_read.html +++ b/kfet/templates/kfet/inventory_read.html @@ -37,6 +37,12 @@ {% block main %} +
+
+ Les valeurs de stock sont calculées sur la base du prix actuel des articles. +
+
+
Date: Sun, 19 Feb 2023 10:32:47 +0100 Subject: [PATCH 10/10] Version 0.13 && Update changelog --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19ed1679..e2493d1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,15 @@ adhérents ni des cotisations. ## Version ??? - ??/??/???? +## Version 0.13 - 19/02/2023 + +### K-Fêt + +- Rajoute la valeur des inventaires +- Résout les problèmes de négatif ne disparaissant pas +- Affiche son surnom s'il y en a un +- Bugfixes + ## Version 0.12.1 - 03/10/2022 ### K-Fêt