2020-06-22 06:47:12 +00:00
|
|
|
from django.db.models import Model, ForeignKey, CASCADE, PositiveIntegerField, TextField, BooleanField, DateField, SET_NULL, PROTECT, ManyToManyField
|
2020-06-02 15:58:20 +00:00
|
|
|
|
|
|
|
from core.fields.base import LongCharField
|
2020-06-04 06:03:35 +00:00
|
|
|
from core.fields.numbers import CostField
|
2020-06-02 15:58:20 +00:00
|
|
|
from core.models.profiles import ClientProfile
|
|
|
|
from core.models.local import Currency
|
2020-06-05 05:52:52 +00:00
|
|
|
from core.models.brands import Brand
|
2020-06-06 11:25:54 +00:00
|
|
|
from core.models.billable import BaseBillable
|
2020-06-22 06:47:12 +00:00
|
|
|
from core.models.products import ProductGroup
|
2020-06-02 15:58:20 +00:00
|
|
|
|
|
|
|
class Invoice(Model):
|
2020-06-05 05:52:52 +00:00
|
|
|
client = ForeignKey(ClientProfile, on_delete=PROTECT)
|
|
|
|
brand = ForeignKey(Brand, on_delete=PROTECT)
|
2020-06-02 15:58:20 +00:00
|
|
|
number = LongCharField()
|
|
|
|
created = DateField()
|
|
|
|
due = DateField()
|
|
|
|
payment_method = LongCharField()
|
|
|
|
currency = ForeignKey(Currency, on_delete=PROTECT)
|
|
|
|
|
|
|
|
class InvoiceItem(Model):
|
|
|
|
invoice = ForeignKey(Invoice, on_delete=CASCADE)
|
|
|
|
sort = PositiveIntegerField()
|
|
|
|
name = LongCharField()
|
|
|
|
description = TextField(blank=True, null=True)
|
2020-06-22 06:47:12 +00:00
|
|
|
product_groups = ManyToManyField(ProductGroup)
|
2020-06-04 06:03:35 +00:00
|
|
|
price = CostField()
|
|
|
|
discount = CostField()
|
2020-06-02 15:58:20 +00:00
|
|
|
taxable = BooleanField()
|
2020-06-06 11:25:54 +00:00
|
|
|
billable = ForeignKey(BaseBillable, on_delete=SET_NULL, null=True)
|