Refactoring to resolve circular import
Added brands field to invoices
This commit is contained in:
parent
df85d23295
commit
96cae766ed
4 changed files with 17 additions and 10 deletions
|
@ -5,7 +5,6 @@ from core.models.profiles import ClientProfile
|
|||
from core.models.brands import Brand
|
||||
from core.fields.base import LongCharField
|
||||
from core.fields.numbers import CostField
|
||||
from core.models.invoices import InvoiceItem, Invoice
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
|
@ -38,6 +37,8 @@ class Billable(Model):
|
|||
recur_count = PositiveIntegerField(null=True)
|
||||
|
||||
def next_invoicing(self):
|
||||
from core.models.invoices import InvoiceItem, Invoice
|
||||
|
||||
try:
|
||||
invoiceitems = InvoiceItem.objects.filter(billable=self)
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ from django.db.models import Model, ForeignKey, CASCADE, PositiveIntegerField, T
|
|||
|
||||
from core.fields.base import LongCharField
|
||||
from core.fields.numbers import CostField
|
||||
from core.models.services import Service
|
||||
from core.models.profiles import ClientProfile
|
||||
from core.models.local import Currency
|
||||
from core.models.billable import Billable
|
||||
from core.models.brands import Brand
|
||||
|
||||
class Invoice(Model):
|
||||
client = ForeignKey(ClientProfile, on_delete=CASCADE)
|
||||
client = ForeignKey(ClientProfile, on_delete=PROTECT)
|
||||
brand = ForeignKey(Brand, on_delete=PROTECT)
|
||||
number = LongCharField()
|
||||
created = DateField()
|
||||
due = DateField()
|
||||
|
@ -16,6 +16,9 @@ class Invoice(Model):
|
|||
currency = ForeignKey(Currency, on_delete=PROTECT)
|
||||
|
||||
class InvoiceItem(Model):
|
||||
from core.models.services import Service
|
||||
from core.models.billable import Billable
|
||||
|
||||
invoice = ForeignKey(Invoice, on_delete=CASCADE)
|
||||
sort = PositiveIntegerField()
|
||||
name = LongCharField()
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
from core.models.billable import CycleChoices
|
||||
from core.fields.base import LongCharField
|
||||
from core.fields.color import ColorField
|
||||
from core.fields.numbers import CostField
|
||||
|
||||
from django.db.models import Model, IntegerChoices, PositiveIntegerField, ForeignKey, CASCADE, CharField, TextField, ManyToManyField
|
||||
from django.db.models import Model, PositiveIntegerField, ForeignKey, CASCADE, CharField, TextField, ManyToManyField
|
||||
|
||||
from importlib import import_module
|
||||
|
||||
|
@ -34,7 +33,9 @@ class Product(Model):
|
|||
class ProductPlan(Model):
|
||||
product = ForeignKey(Product, on_delete=CASCADE)
|
||||
|
||||
class ProductPlanItem(Model):
|
||||
class ProductPlanItem(Model):
|
||||
from core.models.billable import CycleChoices
|
||||
|
||||
plan = ForeignKey(ProductPlan, on_delete=CASCADE)
|
||||
cycle = PositiveIntegerField(choices=CycleChoices.choices)
|
||||
count = PositiveIntegerField()
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from core.models.billable import CycleChoices
|
||||
from core.models.products import ProductGroup
|
||||
from core.fields.numbers import CostField
|
||||
|
||||
from django.db.models import Model, TextField, CharField, ManyToManyField, ForeignKey, CASCADE, PositiveIntegerField, OneToOneField
|
||||
|
@ -10,6 +8,8 @@ from logging import getLogger
|
|||
logger = getLogger(__name__)
|
||||
|
||||
class Service(Model):
|
||||
from core.models.products import ProductGroup
|
||||
|
||||
name = CharField(max_length=255)
|
||||
description = TextField(null=True, blank=True)
|
||||
handler_module = CharField(max_length=255, null=True, blank=True)
|
||||
|
@ -35,7 +35,9 @@ class ServicePlan(Model):
|
|||
for item in productplan.serviceplanitem_set:
|
||||
ServicePlanItem.objects.create(plan=plan, cycle=item.cycle, count=item.count, cost=item.cost)
|
||||
|
||||
class ServicePlanItem(Model):
|
||||
class ServicePlanItem(Model):
|
||||
from core.models.billable import CycleChoices
|
||||
|
||||
plan = ForeignKey(ServicePlan, on_delete=CASCADE)
|
||||
cycle = PositiveIntegerField(choices=CycleChoices.choices)
|
||||
count = PositiveIntegerField()
|
||||
|
|
Loading…
Reference in a new issue