2020-06-04 06:03:35 +00:00
|
|
|
from django.db.models import Model, ForeignKey, CASCADE, PositiveIntegerField, TextField, BooleanField, DateField, SET_NULL, PROTECT
|
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-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):
|
2020-06-05 05:52:52 +00:00
|
|
|
from core.models.services import Service
|
|
|
|
from core.models.billable import Billable
|
|
|
|
|
2020-06-02 15:58:20 +00:00
|
|
|
invoice = ForeignKey(Invoice, on_delete=CASCADE)
|
|
|
|
sort = PositiveIntegerField()
|
|
|
|
name = LongCharField()
|
|
|
|
description = TextField(blank=True, null=True)
|
2020-06-04 06:03:35 +00:00
|
|
|
price = CostField()
|
|
|
|
discount = CostField()
|
2020-06-02 15:58:20 +00:00
|
|
|
taxable = BooleanField()
|
2020-06-05 05:04:09 +00:00
|
|
|
service = ForeignKey(Service, on_delete=SET_NULL, null=True)
|
|
|
|
billable = ForeignKey(Billable, on_delete=SET_NULL, null=True)
|