From ca7c3d5452b85592e76e3ee2bef7bfedd695d3e4 Mon Sep 17 00:00:00 2001 From: Glandos Date: Sun, 10 May 2020 23:05:48 +0200 Subject: [PATCH] use currency format everywhere (#619) This should unify the number formats, along with #618 --- ihatemoney/templates/settle_bills.html | 2 +- ihatemoney/templates/statistics.html | 6 +++--- ihatemoney/tests/tests.py | 10 ++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ihatemoney/templates/settle_bills.html b/ihatemoney/templates/settle_bills.html index 7ec5e290..30f64d03 100644 --- a/ihatemoney/templates/settle_bills.html +++ b/ihatemoney/templates/settle_bills.html @@ -25,7 +25,7 @@ {{ bill.ower }} {{ bill.receiver }} - {{ "%0.2f"|format(bill.amount) }} + {{ bill.amount|currencyformat_nc(g.project.default_currency) }} {% endfor %} diff --git a/ihatemoney/templates/statistics.html b/ihatemoney/templates/statistics.html index b38abb12..af3d9d5b 100644 --- a/ihatemoney/templates/statistics.html +++ b/ihatemoney/templates/statistics.html @@ -30,8 +30,8 @@ {% for stat in members_stats|sort(attribute='member.name') %} {{ stat.member.name }} - {{ "%0.2f"|format(stat.paid) }} - {{ "%0.2f"|format(stat.spent) }} + {{ stat.paid|currencyformat_nc(g.project.default_currency) }} + {{ stat.spent|currencyformat_nc(g.project.default_currency) }} {% endfor %} @@ -43,7 +43,7 @@ {% for month in months %} {{ _(month.strftime("%B")) }} {{ month.year }} - {{ "%0.2f"|format(monthly_stats[month.year][month.month]) }} + {{ monthly_stats[month.year][month.month]|currencyformat_nc(g.project.default_currency) }} {% endfor %} diff --git a/ihatemoney/tests/tests.py b/ihatemoney/tests/tests.py index b13c7c07..4cdf3164 100644 --- a/ihatemoney/tests/tests.py +++ b/ihatemoney/tests/tests.py @@ -942,16 +942,18 @@ class BudgetTestCase(IhatemoneyTestCase): response = self.client.get("/raclette/statistics") regex = r"{}\s+{}\s+{}" self.assertRegex( - response.data.decode("utf-8"), regex.format("zorglub", "20.00", "31.67"), + response.data.decode("utf-8"), + regex.format("zorglub", r"\$20\.00", r"\$31\.67"), ) self.assertRegex( - response.data.decode("utf-8"), regex.format("fred", "20.00", "5.83"), + response.data.decode("utf-8"), + regex.format("fred", r"\$20\.00", r"\$5\.83"), ) self.assertRegex( - response.data.decode("utf-8"), regex.format("tata", "0.00", "2.50"), + response.data.decode("utf-8"), regex.format("tata", r"\$0\.00", r"\$2\.50"), ) self.assertRegex( - response.data.decode("utf-8"), regex.format("pépé", "0.00", "0.00"), + response.data.decode("utf-8"), regex.format("pépé", r"\$0\.00", r"\$0\.00"), ) # Check that the order of participants in the sidebar table is the