Show numbers with 2 decimals
This commit is contained in:
parent
8367f807a3
commit
5ca8c5bde0
2 changed files with 8 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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 %}
|
||||
|
|
Loading…
Reference in a new issue