Browse Source

Reword service costs table

Added a templatetags to display prices
Jocelyn Delande 9 years ago
parent
commit
43008bab41

+ 11 - 6
costs/templates/costs/service_detail.html

@@ -1,22 +1,27 @@
+{% load costs %}
+
 <h1>Service {{ service.name }}</h1>
 <h1>Service {{ service.name }}</h1>
-<p><em>({{ service.subscriptions_count }} souscriptions)</em></p>
+<p><em>({{ service.document }}, {{ service.subscriptions_count }} souscriptions)</em></p>
+
+<h2>Coût récurent (mensuel, par abonnement)</h2>
 <table>
 <table>
   {% for usage in goods_uses %}
   {% for usage in goods_uses %}
   <tr>
   <tr>
-    <td>matériel</td>
+    <td>amortissement matériel</td>
     <td>{{ usage.resource.name }}</td>
     <td>{{ usage.resource.name }}</td>
-    <td>{{ usage.unit_monthly_provision_share }}</td>
+    <td>{{ usage.unit_monthly_provision_share|price }}</td>
   </tr>
   </tr>
   {% endfor %}
   {% endfor %}
   {% for usage in costs_uses %}
   {% for usage in costs_uses %}
   <tr>
   <tr>
     <td>coût récurent</td>
     <td>coût récurent</td>
     <td>{{ usage.resource.name }}</td>
     <td>{{ usage.resource.name }}</td>
-    <td>{{ usage.unit_cost_share }}</td>
+    <td>{{ usage.unit_cost_share|price }}</td>
   </tr>
   </tr>
   {% endfor %}
   {% endfor %}
   <tr>
   <tr>
-    <td colspan="2"><strong>Coût de revient par abonnement</strong></td>
-    <td><strong>{{ unit_costs_price }}€</strong></td>
+    <td colspan="2"><strong>Coût de revient par abonnement</strong>
+    </td>
+    <td><strong>{{ unit_costs_price|price }}</strong></td>
   </tr>
   </tr>
 </table>
 </table>

+ 0 - 0
costs/templatetags/__init__.py


+ 13 - 0
costs/templatetags/costs.py

@@ -0,0 +1,13 @@
+from django import template
+
+register = template.Library()
+
+
+@register.filter
+def price(v):
+    return '{:.2f}€'.format(v)
+
+
+@register.filter
+def round(v):
+    return '{:.1f}'.format(v)