From affdf43e0bc6c3b525b2ef6d4872cf42454144fb Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Wed, 27 Nov 2019 14:14:33 +0100 Subject: [PATCH] Add logic in views and templates --- kfet/forms.py | 2 +- kfet/templates/kfet/category.html | 2 ++ kfet/views.py | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/kfet/forms.py b/kfet/forms.py index 2a7f111a..b6fad26f 100644 --- a/kfet/forms.py +++ b/kfet/forms.py @@ -236,7 +236,7 @@ class CheckoutStatementUpdateForm(forms.ModelForm): class CategoryForm(forms.ModelForm): class Meta: model = ArticleCategory - fields = ["name", "has_addcost"] + fields = ["name", "has_addcost", "has_reduction"] # ----- diff --git a/kfet/templates/kfet/category.html b/kfet/templates/kfet/category.html index 0a8b58be..5692725c 100644 --- a/kfet/templates/kfet/category.html +++ b/kfet/templates/kfet/category.html @@ -26,6 +26,7 @@ Nom Nombre d'articles Peut être majorée + Réduction COF appliquée @@ -38,6 +39,7 @@ {{ category.articles.all|length }} {{ category.has_addcost | yesno:"Oui,Non"}} + {{ category.has_reduction | yesno:"Oui,Non"}} {% endfor %} diff --git a/kfet/views.py b/kfet/views.py index c5d5082b..7ae1de82 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -1056,7 +1056,10 @@ def kpsul_perform_operations(request): to_addcost_for_balance += operation.addcost_amount if operationgroup.on_acc.is_cash: to_checkout_balance += -operation.amount - if operationgroup.on_acc.is_cof: + if ( + operationgroup.on_acc.is_cof + and operation.article.category.has_reduction + ): if is_addcost and operation.article.category.has_addcost: operation.addcost_amount /= cof_grant_divisor operation.amount = operation.amount / cof_grant_divisor