expephalon/core/models/billable.py
2020-06-06 13:25:54 +02:00

33 lines
1.2 KiB
Python

from django.db.models import Model, ForeignKey, CASCADE, TextField, PositiveIntegerField, BooleanField, DateField
from django.utils import timezone
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.local import Currency
from core.mixins.billable import RecurMixin
from dateutil.relativedelta import relativedelta
from polymorphic.models import PolymorphicModel
class BaseBillable(PolymorphicModel):
name = LongCharField()
description = TextField(blank=True, null=True)
amount = CostField()
count = PositiveIntegerField(default=1)
currency = ForeignKey(Currency, on_delete=CASCADE)
taxable = BooleanField()
client = ForeignKey(ClientProfile, on_delete=CASCADE)
brand = ForeignKey(Brand, on_delete=CASCADE)
@property
def next_invoicing(self):
raise NotImplementedError(f"{type(self)} does not implement property next_invoicing!")
@property
def can_invoice(self):
raise NotImplementedError(f"{type(self)} does not implement property can_invoice!")
class Billable(RecurMixin, BaseBillable):
pass