in between commit
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
parent
c9a941e290
commit
a091079677
2 changed files with 21 additions and 29 deletions
|
|
@ -332,6 +332,8 @@ class Order(models.Model):
|
|||
blank=True,
|
||||
null=True)
|
||||
|
||||
|
||||
|
||||
@property
|
||||
def count_billed(self):
|
||||
"""
|
||||
|
|
@ -535,6 +537,8 @@ class Bill(models.Model):
|
|||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
class BillRecord(models.Model):
|
||||
"""
|
||||
Entry of a bill, dynamically generated from an order.
|
||||
|
|
@ -595,8 +599,6 @@ class OrderRecord(models.Model):
|
|||
###
|
||||
# Products
|
||||
|
||||
# Abstract (= no database representation) class used as parent for products
|
||||
# (e.g. uncloud_vm.models.VMProduct).
|
||||
class Product(UncloudModel):
|
||||
owner = models.ForeignKey(get_user_model(),
|
||||
on_delete=models.CASCADE,
|
||||
|
|
@ -604,15 +606,15 @@ class Product(UncloudModel):
|
|||
|
||||
description = "Generic Product"
|
||||
|
||||
status = models.CharField(max_length=32,
|
||||
choices=UncloudStatus.choices,
|
||||
default=UncloudStatus.AWAITING_PAYMENT)
|
||||
|
||||
order = models.ForeignKey(Order,
|
||||
on_delete=models.CASCADE,
|
||||
editable=False,
|
||||
null=True)
|
||||
|
||||
status = models.CharField(max_length=32,
|
||||
choices=UncloudStatus.choices,
|
||||
default=UncloudStatus.AWAITING_PAYMENT)
|
||||
|
||||
# Default period for all products
|
||||
default_recurring_period = RecurringPeriod.PER_30D
|
||||
|
||||
|
|
@ -638,14 +640,6 @@ class Product(UncloudModel):
|
|||
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
# # Make sure we only create records on creation.
|
||||
# if being_created:
|
||||
# record = OrderRecord(
|
||||
# one_time_price=self.one_time_price,
|
||||
# recurring_price=self.recurring_price,
|
||||
# description=self.description)
|
||||
# self.order.orderrecord_set.add(record, bulk=False)
|
||||
|
||||
@property
|
||||
def recurring_price(self):
|
||||
pass # To be implemented in child.
|
||||
|
|
@ -736,16 +730,3 @@ class Product(UncloudModel):
|
|||
else:
|
||||
# FIXME: use the right type of exception here!
|
||||
raise Exception("Did not implement the discounter for this case")
|
||||
|
||||
|
||||
|
||||
# Interesting snippets
|
||||
|
||||
# # Trigger initial bill generation at order creation.
|
||||
# def save(self, *args, **kwargs):
|
||||
# if self.ending_date and self.ending_date < self.starting_date:
|
||||
# raise ValidationError("End date cannot be before starting date")
|
||||
|
||||
# super().save(*args, **kwargs)
|
||||
|
||||
# Bill.generate_for(self.starting_date.year, self.starting_date.month, self.owner)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue