from django.db.models import Model, ForeignKey, CASCADE, TextField, PositiveIntegerField, BooleanField, DateField, ManyToManyField 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 core.models.products import ProductGroup 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): product_groups = ManyToManyField(ProductGroup)