aboutsummaryrefslogtreecommitdiff
path: root/budget/templates/list_bills.html
diff options
context:
space:
mode:
authorBaptiste Jonglez <git@bitsofnetworks.org>2017-01-02 14:55:48 +0100
committerBaptiste Jonglez <git@bitsofnetworks.org>2017-01-03 21:37:19 +0100
commitd6cf89008fdb5e40395d3ccc879db2255f13e461 (patch)
treee38797044f50d1f5398857a85cd9bf9ab3ab0762 /budget/templates/list_bills.html
parentb507a5afa1b4e3594a3a35f3aae08f7f38989338 (diff)
downloadihatemoney-mirror-d6cf89008fdb5e40395d3ccc879db2255f13e461.zip
ihatemoney-mirror-d6cf89008fdb5e40395d3ccc879db2255f13e461.tar.gz
ihatemoney-mirror-d6cf89008fdb5e40395d3ccc879db2255f13e461.tar.bz2
Workaround rounding issues when displaying balance of users
A user with a "0.00" balance would have either a "+0.00" in green or a "-0.00" in red, depending on the exact value of the floating-point value. Fix this by simply rounding to 2 digits before comparing to zero.
Diffstat (limited to 'budget/templates/list_bills.html')
-rw-r--r--budget/templates/list_bills.html6
1 files changed, 3 insertions, 3 deletions
diff --git a/budget/templates/list_bills.html b/budget/templates/list_bills.html
index f081334..72b9032 100644
--- a/budget/templates/list_bills.html
+++ b/budget/templates/list_bills.html
@@ -65,7 +65,7 @@
<div id="table_overflow">
<table class="balance table">
{% set balance = g.project.balance %}
- {% for member in g.project.members | sort(attribute='name') if member.activated or balance[member.id] != 0 %}
+ {% for member in g.project.members | sort(attribute='name') if member.activated or balance[member.id]|round(2) != 0 %}
<tr id="bal-member-{{ member.id }}" action={% if member.activated %}delete{% else %}reactivate{% endif %}>
<td class="balance-name">{{ member.name }}
<span class="light{% if not g.project.uses_weights %} extra-info{% endif %}">(x{{ member.weight|minimal_round(1) }})</span>
@@ -82,8 +82,8 @@
<form class="action reactivate" action="{{ url_for(".reactivate", member_id=member.id) }}" method="POST">
<button type="submit">{{ _("reactivate") }}</button></form></td>
{% endif %}
- <td class="balance-value {% if balance[member.id] > 0 %}positive{% elif balance[member.id] < 0 %}negative{% endif %}">
- {% if balance[member.id] > 0 %}+{% endif %}{{ "%.2f" | format(balance[member.id]) }}
+ <td class="balance-value {% if balance[member.id]|round(2) > 0 %}positive{% elif balance[member.id]|round(2) < 0 %}negative{% endif %}">
+ {% if balance[member.id]|round(2) > 0 %}+{% endif %}{{ "%.2f" | format(balance[member.id]) }}
</td>
</tr>
{% endfor %}