mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 02:24:26 +00:00
eboutic: don't display future account balance if contains refilling item
This commit is contained in:
parent
129f2e53ee
commit
3501703c15
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
from django.db import models, DataError
|
from django.db import models, DataError
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from django.utils.functional import cached_property
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from accounting.models import CurrencyField
|
from accounting.models import CurrencyField
|
||||||
@ -68,6 +69,12 @@ class Basket(models.Model):
|
|||||||
if item.quantity <= 0:
|
if item.quantity <= 0:
|
||||||
item.delete()
|
item.delete()
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def contains_refilling_item(self):
|
||||||
|
return self.items.filter(
|
||||||
|
type_id=settings.SITH_COUNTER_PRODUCTTYPE_REFILLING
|
||||||
|
).exists()
|
||||||
|
|
||||||
def get_total(self):
|
def get_total(self):
|
||||||
total = 0
|
total = 0
|
||||||
for i in self.items.all():
|
for i in self.items.all():
|
||||||
|
@ -37,9 +37,12 @@
|
|||||||
{% if customer_amount != None %}
|
{% if customer_amount != None %}
|
||||||
<br>
|
<br>
|
||||||
{% trans %}Current account amount: {% endtrans %}<strong>{{ "%0.2f"|format(customer_amount) }} €</strong>
|
{% trans %}Current account amount: {% endtrans %}<strong>{{ "%0.2f"|format(customer_amount) }} €</strong>
|
||||||
|
|
||||||
|
{% if not basket.contains_refilling_item %}
|
||||||
<br>
|
<br>
|
||||||
{% trans %}Remaining account amount: {% endtrans %}<strong>{{ "%0.2f"|format(customer_amount - basket.get_total()) }} €</strong>
|
{% trans %}Remaining account amount: {% endtrans %}<strong>{{ "%0.2f"|format(customer_amount - basket.get_total()) }} €</strong>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<form method="post" action="{{ url('eboutic:command') }}">
|
<form method="post" action="{{ url('eboutic:command') }}">
|
||||||
|
@ -34,9 +34,12 @@
|
|||||||
{% if customer_amount != None %}
|
{% if customer_amount != None %}
|
||||||
<br>
|
<br>
|
||||||
{% trans %}Current account amount: {% endtrans %}<strong>{{ "%0.2f"|format(customer_amount) }} €</strong>
|
{% trans %}Current account amount: {% endtrans %}<strong>{{ "%0.2f"|format(customer_amount) }} €</strong>
|
||||||
|
|
||||||
|
{% if not basket.contains_refilling_item %}
|
||||||
<br>
|
<br>
|
||||||
{% trans %}Remaining account amount: {% endtrans %}<strong>{{ "%0.2f"|format(customer_amount - basket.get_total()) }} €</strong>
|
{% trans %}Remaining account amount: {% endtrans %}<strong>{{ "%0.2f"|format(customer_amount - basket.get_total()) }} €</strong>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
{% if settings.SITH_EBOUTIC_CB_ENABLED %}
|
{% if settings.SITH_EBOUTIC_CB_ENABLED %}
|
||||||
<form method="post" action="{{ settings.SITH_EBOUTIC_ET_URL }}">
|
<form method="post" action="{{ settings.SITH_EBOUTIC_ET_URL }}">
|
||||||
@ -48,7 +51,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if basket.items.filter(type_id=settings.SITH_COUNTER_PRODUCTTYPE_REFILLING).exists() %}
|
{% if basket.contains_refilling_item %}
|
||||||
<p>{% trans %}AE account payment disabled because your basket contains refilling items.{% endtrans %}</p>
|
<p>{% trans %}AE account payment disabled because your basket contains refilling items.{% endtrans %}</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<form method="post" action="{{ url('eboutic:pay_with_sith') }}">
|
<form method="post" action="{{ url('eboutic:pay_with_sith') }}">
|
||||||
|
Loading…
Reference in New Issue
Block a user