|
@@ -85,6 +85,13 @@ class CostUse(AbstractUse):
|
|
|
def cost_share(self):
|
|
|
return self.share*self.resource.price
|
|
|
|
|
|
+ def unit_cost_share(self):
|
|
|
+ subscriptions_count = self.service.subscriptions_count
|
|
|
+ if subscriptions_count == 0:
|
|
|
+ return 0
|
|
|
+ else:
|
|
|
+ return self.cost_share()/self.service.subscriptions_count
|
|
|
+
|
|
|
|
|
|
class GoodUse(AbstractUse):
|
|
|
resource = models.ForeignKey(Good)
|
|
@@ -92,6 +99,14 @@ class GoodUse(AbstractUse):
|
|
|
def monthly_provision_share(self):
|
|
|
return self.real_share()*self.resource.monthly_provision()
|
|
|
|
|
|
+ def unit_monthly_provision_share(self):
|
|
|
+ subscriptions_count = self.service.subscriptions_count
|
|
|
+ monthly_share = self.monthly_provision_share()
|
|
|
+ if subscriptions_count == 0:
|
|
|
+ return 0
|
|
|
+ else:
|
|
|
+ return monthly_share/subscriptions_count
|
|
|
+
|
|
|
|
|
|
class Service(AbstractItem):
|
|
|
""" A service we sell
|
|
@@ -108,5 +123,7 @@ class Service(AbstractItem):
|
|
|
related_name='using_services')
|
|
|
# services = models.ManyToMany('Service') #TODO
|
|
|
|
|
|
+ subscriptions_count = models.PositiveIntegerField(default=0)
|
|
|
+
|
|
|
def get_absolute_url(self):
|
|
|
return reverse('detail-service', kwargs={'pk': self.pk})
|