Add logic in views and templates

This commit is contained in:
Ludovic Stephan 2019-11-27 14:14:33 +01:00
parent 20ceec0e64
commit affdf43e0b
3 changed files with 7 additions and 2 deletions

View file

@ -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"]
# -----

View file

@ -26,6 +26,7 @@
<td>Nom</td>
<td class="text-right">Nombre d'articles</td>
<td class="text-right" data-sorter="yesno">Peut être majorée</td>
<td class="text-right" data-sorter="yesno">Réduction COF appliquée</td>
</tr>
</thead>
<tbody>
@ -38,6 +39,7 @@
</td>
<td class="text-right">{{ category.articles.all|length }}</td>
<td class="text-right">{{ category.has_addcost | yesno:"Oui,Non"}}</td>
<td class="text-right">{{ category.has_reduction | yesno:"Oui,Non"}}</td>
</tr>
{% endfor %}
</tbody>

View file

@ -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