31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from django.db.models import IntegerChoices, Model, ForeignKey, CASCADE, TextField, PositiveIntegerField, BooleanField, DateField
|
|
|
|
from core.models.profiles import ClientProfile
|
|
from core.models.brands import Brand
|
|
from core.fields.base import LongCharField
|
|
from core.fields.numbers import CostField
|
|
|
|
class ActionChoices(IntegerChoices):
|
|
WAIT = 0, "Do not invoice for now"
|
|
NEXT = 1, "Add to client's next invoice"
|
|
CRON = 2, "Invoice at next cron run"
|
|
DATE = 3, "Invoice at date"
|
|
|
|
class CycleChoices(IntegerChoices):
|
|
DAYS = 0, "Days"
|
|
WEEKS = 1, "Weeks"
|
|
MONTHS = 2, "Months"
|
|
YEARS = 3, "Years"
|
|
|
|
class Billable(Model):
|
|
client = ForeignKey(ClientProfile, on_delete=CASCADE)
|
|
brand = ForeignKey(Brand, on_delete=CASCADE)
|
|
name = LongCharField()
|
|
description = TextField()
|
|
individual_cost = CostField()
|
|
amount = PositiveIntegerField()
|
|
taxable = BooleanField()
|
|
action = PositiveIntegerField(choices=ActionChoices.choices)
|
|
date = DateField(null=True)
|
|
recur_cycle = PositiveIntegerField(choices=CycleChoices.choices, null=True)
|
|
recur_count = PositiveIntegerField(null=True)
|