eboutic: fix account amount

This commit is contained in:
tleb 2019-10-24 14:40:26 +02:00
parent 6b06b647bc
commit 00c96f5b71
3 changed files with 15 additions and 2 deletions

View File

@ -33,10 +33,13 @@
</ul> </ul>
<p> <p>
<strong>{% trans %}Basket amount: {% endtrans %}{{ "%0.2f"|format(basket.get_total()) }} €</strong> <strong>{% trans %}Basket amount: {% endtrans %}{{ "%0.2f"|format(basket.get_total()) }} €</strong>
{% 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>
<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 %}
</p> </p>
<form method="post" action="{{ url('eboutic:command') }}"> <form method="post" action="{{ url('eboutic:command') }}">

View File

@ -27,12 +27,16 @@
{% endfor %} {% endfor %}
<tbody> <tbody>
</table> </table>
<p> <p>
<strong>{% trans %}Basket amount: {% endtrans %}{{ "%0.2f"|format(basket.get_total()) }} €</strong> <strong>{% trans %}Basket amount: {% endtrans %}{{ "%0.2f"|format(basket.get_total()) }} €</strong>
{% 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>
<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 %}
</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 }}">

View File

@ -107,7 +107,10 @@ class EbouticMain(TemplateView):
kwargs["basket"] = self.basket kwargs["basket"] = self.basket
kwargs["eboutic"] = Counter.objects.filter(type="EBOUTIC").first() kwargs["eboutic"] = Counter.objects.filter(type="EBOUTIC").first()
kwargs["categories"] = ProductType.objects.all() kwargs["categories"] = ProductType.objects.all()
kwargs["customer_amount"] = self.request.user.customer.amount if hasattr(self.request.user, "customer"):
kwargs["customer_amount"] = self.request.user.customer.amount
else:
kwargs["customer_amount"] = None
if not self.request.user.was_subscribed: if not self.request.user.was_subscribed:
kwargs["categories"] = kwargs["categories"].exclude( kwargs["categories"] = kwargs["categories"].exclude(
id=settings.SITH_PRODUCTTYPE_SUBSCRIPTION id=settings.SITH_PRODUCTTYPE_SUBSCRIPTION
@ -151,7 +154,10 @@ class EbouticCommand(TemplateView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(EbouticCommand, self).get_context_data(**kwargs) kwargs = super(EbouticCommand, self).get_context_data(**kwargs)
kwargs["customer_amount"] = self.request.user.customer.amount if hasattr(self.request.user, "customer"):
kwargs["customer_amount"] = self.request.user.customer.amount
else:
kwargs["customer_amount"] = None
kwargs["et_request"] = OrderedDict() kwargs["et_request"] = OrderedDict()
kwargs["et_request"]["PBX_SITE"] = settings.SITH_EBOUTIC_PBX_SITE kwargs["et_request"]["PBX_SITE"] = settings.SITH_EBOUTIC_PBX_SITE
kwargs["et_request"]["PBX_RANG"] = settings.SITH_EBOUTIC_PBX_RANG kwargs["et_request"]["PBX_RANG"] = settings.SITH_EBOUTIC_PBX_RANG