Show numbers with 2 decimals

This commit is contained in:
Gabriel Augendre 2016-06-04 14:52:08 +02:00
parent 8367f807a3
commit 5ca8c5bde0
No known key found for this signature in database
GPG key ID: D2B6A5B41FC438B1
2 changed files with 8 additions and 3 deletions

View file

@ -2,6 +2,9 @@ from django.db import models
from django.conf import settings
from django.db.models import Sum
import logging
logger = logging.getLogger(__name__)
AUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')
@ -24,7 +27,7 @@ class Refund(models.Model):
return 0
def __str__(self) -> str:
return "{0} on {1} for {2}".format(self.title, self.date, self.eur_value())
return "{0} on {1} for {2:.2f}".format(self.title, self.date, self.eur_value())
class Payment(models.Model):
@ -45,7 +48,9 @@ class Payment(models.Model):
)
def __str__(self) -> str:
return '{0} on {1} for {2}'.format(self.title, self.date, self.value / 100)
s = '{0} on {1} for {2:.2f}'.format(self.title, self.date, self.value / 100)
logger.error(s)
return s
def eur_value(self) -> float:
return self.value / 100

View file

@ -13,7 +13,7 @@
{% else %}
<div class="list-group-item">
{% endif %}
{{ e.title }} le {{ e.date|date:"SHORT_DATE_FORMAT" }} : {{ e.eur_value }}€
{{ e.title }} le {{ e.date|date:"SHORT_DATE_FORMAT" }} : {{ e.eur_value|floatformat:2 }}€
{% if refunds or payments %}
</a>
{% else %}