27 lines
No EOL
1 KiB
Python
27 lines
No EOL
1 KiB
Python
from django.db.models import Model, ForeignKey, CASCADE, PositiveIntegerField, TextField, BooleanField, DateField, SET_NULL, PROTECT
|
|
|
|
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
|
|
|
|
class Invoice(Model):
|
|
client = ForeignKey(ClientProfile, on_delete=CASCADE)
|
|
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)
|
|
price = CostField()
|
|
discount = CostField()
|
|
taxable = BooleanField()
|
|
service = ForeignKey(Service, on_delete=SET_NULL, null=True)
|
|
billable = ForeignKey(Billable, on_delete=SET_NULL, null=True) |