Parcourir la source

Add setup cost to pricing

Jocelyn Delande il y a 9 ans
Parent
commit
009d424aee
2 fichiers modifiés avec 32 ajouts et 1 suppressions
  1. 19 1
      costs/templates/costs/service_detail.html
  2. 13 0
      costs/views.py

+ 19 - 1
costs/templates/costs/service_detail.html

@@ -24,4 +24,22 @@
     </td>
     <td><strong>{{ unit_costs_price|price }}</strong></td>
   </tr>
-</table>
+</table>
+
+<h2>Coût de mise en place (FAS)</h2>
+<table>
+{% for good_use in goods_uses %}
+  <tr>
+    <td>{{ good_use.resource.name }}</td>
+    <td>{{ good_use.unit_value_share|price }}</td>
+  </tr>
+{% endfor %}
+  <tr>
+    <td colspan="2"><strong>Coût de mise en place par nouvel abonnement</strong></td>
+    <td><strong>{{ unit_goods_value_share|price }}</strong></td>
+  </tr>
+</table>
+
+<p>
+La mise en place équivaut à {{ months_fas_equivalent|round }} mois de coût d'abonnement.
+</p>

+ 13 - 0
costs/views.py

@@ -35,10 +35,19 @@ def detail_service(request, pk):
         (i.cost_share() for i in costs_uses),
     ))
 
+    total_goods_value_share = sum(i.value_share() for i in goods_uses)
+
     if service.subscriptions_count == 0:
         unit_costs_price = 0
+        unit_goods_value_share = 0
     else:
         unit_costs_price = total_costs_price/service.subscriptions_count
+        unit_goods_value_share = total_goods_value_share/service.subscriptions_count
+
+    if unit_costs_price > 0:
+        months_fas_equivalent = unit_goods_value_share/unit_costs_price
+    else:
+        months_fas_equivalent = 0
 
     context = {
         'service': service,
@@ -46,5 +55,9 @@ def detail_service(request, pk):
         'goods_uses': goods_uses,
         'total_costs_price': total_costs_price,
         'unit_costs_price': unit_costs_price,
+
+        'total_goods_value_share': total_goods_value_share,
+        'unit_goods_value_share': unit_goods_value_share,
+        'months_fas_equivalent': months_fas_equivalent,
     }
     return render(request, 'costs/service_detail.html', context)