Browse Source

Rename *costs_price to *recurring_price

Jocelyn Delande 9 years ago
parent
commit
15b8ffc1c8
3 changed files with 17 additions and 17 deletions
  1. 6 6
      costs/models.py
  2. 1 1
      costs/templates/costs/service_detail.html
  3. 10 10
      costs/tests/test_models.py

+ 6 - 6
costs/models.py

@@ -237,7 +237,7 @@ class Service(AbstractResource):
 
 
     @property
     @property
     def price(self):
     def price(self):
-        return self.get_prices()['total_costs_price']
+        return self.get_prices()['total_recurring_price']
 
 
     def save(self, *args, **kwargs):
     def save(self, *args, **kwargs):
         if self.reusable:
         if self.reusable:
@@ -256,7 +256,7 @@ class Service(AbstractResource):
         goods_uses = GoodUse.objects.filter(service=self)
         goods_uses = GoodUse.objects.filter(service=self)
         services_uses = ServiceUse.objects.filter(service=self)
         services_uses = ServiceUse.objects.filter(service=self)
 
 
-        total_costs_price = sum(chain(
+        total_recurring_price = sum(chain(
             (i.monthly_provision_share() for i in goods_uses),
             (i.monthly_provision_share() for i in goods_uses),
             (i.cost_share() for i in costs_uses),
             (i.cost_share() for i in costs_uses),
             (i.cost_share() for i in services_uses)
             (i.cost_share() for i in services_uses)
@@ -265,15 +265,15 @@ class Service(AbstractResource):
         total_goods_value_share = sum(i.value_share() for i in goods_uses)
         total_goods_value_share = sum(i.value_share() for i in goods_uses)
 
 
         if self.subscriptions_count == 0:
         if self.subscriptions_count == 0:
-            unit_costs_price = 0
+            unit_recurring_price = 0
             unit_goods_value_share = 0
             unit_goods_value_share = 0
         else:
         else:
-            unit_costs_price = total_costs_price/self.subscriptions_count
+            unit_recurring_price = total_recurring_price/self.subscriptions_count
             unit_goods_value_share = \
             unit_goods_value_share = \
                 total_goods_value_share/self.subscriptions_count
                 total_goods_value_share/self.subscriptions_count
         return {
         return {
-            'total_costs_price': total_costs_price,
-            'unit_costs_price': unit_costs_price,
+            'total_recurring_price': total_recurring_price,
+            'unit_recurring_price': unit_recurring_price,
             'total_goods_value_share': total_goods_value_share,
             'total_goods_value_share': total_goods_value_share,
             'unit_goods_value_share': unit_goods_value_share,
             'unit_goods_value_share': unit_goods_value_share,
         }
         }

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

@@ -132,7 +132,7 @@ matériel et des investissements à l'échéance de leur durée de vie.
     <tfoot>
     <tfoot>
       <tr>
       <tr>
         <th colspan="2"><strong>Coût de revient par abonnement</strong></th>
         <th colspan="2"><strong>Coût de revient par abonnement</strong></th>
-        <th class="right aligned"><strong>{{ unit_costs_price|price }}</strong></th>
+        <th class="right aligned"><strong>{{ unit_recurring_price|price }}</strong></th>
       </tr>
       </tr>
     </tfoot>
     </tfoot>
   </table>
   </table>

+ 10 - 10
costs/tests/test_models.py

@@ -25,8 +25,8 @@ class ServiceTests(TestCase):
     def test_get_prices_zero(self):
     def test_get_prices_zero(self):
         s = Service.objects.create(name='Foo', document=self.doc)
         s = Service.objects.create(name='Foo', document=self.doc)
         self.assertEqual(s.get_prices(), {
         self.assertEqual(s.get_prices(), {
-            'total_costs_price': 0,
-            'unit_costs_price': 0,
+            'total_recurring_price': 0,
+            'unit_recurring_price': 0,
             'unit_goods_value_share': 0,
             'unit_goods_value_share': 0,
             'total_goods_value_share': 0,
             'total_goods_value_share': 0,
         })
         })
@@ -38,8 +38,8 @@ class ServiceTests(TestCase):
             service=s, resource=self.electricity_cost, share=0.4)
             service=s, resource=self.electricity_cost, share=0.4)
 
 
         self.assertEqual(s.get_prices(), {
         self.assertEqual(s.get_prices(), {
-            'total_costs_price': 10,
-            'unit_costs_price': 0,
+            'total_recurring_price': 10,
+            'unit_recurring_price': 0,
             'unit_goods_value_share': 0,
             'unit_goods_value_share': 0,
             'total_goods_value_share': 0,
             'total_goods_value_share': 0,
         })
         })
@@ -48,8 +48,8 @@ class ServiceTests(TestCase):
         s.save()
         s.save()
 
 
         self.assertEqual(s.get_prices(), {
         self.assertEqual(s.get_prices(), {
-            'total_costs_price': 10,
-            'unit_costs_price': 5,
+            'total_recurring_price': 10,
+            'unit_recurring_price': 5,
             'unit_goods_value_share': 0,
             'unit_goods_value_share': 0,
             'total_goods_value_share': 0,
             'total_goods_value_share': 0,
         })
         })
@@ -62,8 +62,8 @@ class ServiceTests(TestCase):
             service=s, resource=self.server, share=0.4)
             service=s, resource=self.server, share=0.4)
 
 
         self.assertEqual(s.get_prices(), {
         self.assertEqual(s.get_prices(), {
-            'total_costs_price': 10/(365*3)*365.25/12,
-            'unit_costs_price': 0,
+            'total_recurring_price': 10/(365*3)*365.25/12,
+            'unit_recurring_price': 0,
             'unit_goods_value_share': 0,
             'unit_goods_value_share': 0,
             'total_goods_value_share': 10.0,
             'total_goods_value_share': 10.0,
         })
         })
@@ -72,8 +72,8 @@ class ServiceTests(TestCase):
         s.save()
         s.save()
 
 
         self.assertEqual(s.get_prices(), {
         self.assertEqual(s.get_prices(), {
-            'total_costs_price': 10/(365*3)*365.25/12,
-            'unit_costs_price': 10/(365*3)*365.25/12/2,
+            'total_recurring_price': 10/(365*3)*365.25/12,
+            'unit_recurring_price': 10/(365*3)*365.25/12/2,
             'unit_goods_value_share': 5,
             'unit_goods_value_share': 5,
             'total_goods_value_share': 10,
             'total_goods_value_share': 10,
         })
         })