Simplifying products and services - will be reversed...

This commit is contained in:
Kumi 2020-06-06 06:33:52 +02:00
parent 1bc81e7126
commit 8cb5f2b2ce
2 changed files with 20 additions and 18 deletions

View file

@ -34,14 +34,15 @@ class Product(Model):
return None
class ProductPlan(Model):
product = ForeignKey(Product, on_delete=CASCADE)
currency = ForeignKey(Currency, on_delete=CASCADE)
class ProductPlanItem(Model):
from core.models.billable import CycleChoices
plan = ForeignKey(ProductPlan, on_delete=CASCADE)
product = ForeignKey(Product, on_delete=CASCADE)
currency = ForeignKey(Currency, on_delete=CASCADE)
cycle = PositiveIntegerField(choices=CycleChoices.choices)
count = PositiveIntegerField()
cost = CostField()
taxable = BooleanField()
setup = CostField()
taxable = BooleanField()

View file

@ -24,6 +24,7 @@ class Service(Model):
cycle = PositiveIntegerField(choices=CycleChoices.choices)
count = PositiveIntegerField()
cost = CostField()
setup = CostField()
taxable=BooleanField()
@property
@ -38,18 +39,18 @@ class Service(Model):
return None
@classmethod
def from_productplanitem(cls, productplanitem, client):
plan = cls.objects.create(client=client,
name=productplanitem.plan.product.name,
description=productplanitem.plan.product.description,
service_type=productplanitem.plan.product.product_type,
product=productplanitem.plan.product,
product_groups=productplanitem.plan.product.product_groups,
currency=productplanitem.plan.currency,
cycle=productplanitem.cycle,
count=productplanitem.count,
cost=productplanitem.cost,
taxable=productplanitem.taxable)
def from_productplan(cls, productplan, client):
cls.objects.create(client=client,
name=productplan.product.name,
description=productplan.product.description,
service_type=productplan.product.product_type,
product=productplan.product,
product_groups=productplan.product.product_groups,
currency=productplan.currency,
cycle=productplan.cycle,
count=productplan.count,
cost=productplan.cost,
taxable=productplan.taxable)
@property
def invoicable(self):