Remove orderrecord

Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
Nico Schottelius 2020-08-08 22:37:00 +02:00
commit 78d1de9031
4 changed files with 37 additions and 45 deletions

View file

@ -412,6 +412,7 @@ class Bill(models.Model):
# Calculate the start date
if last_bill:
# TODO: check that last bill is finished/closed, if not continue using it
starting_date = last_bill.end_date + datetime.timedelta(seconds=1)
else:
if first_order:
@ -436,7 +437,9 @@ class Bill(models.Model):
order=order,
starting_date=starting_date,
ending_date=ending_date)
pass
# Bill all active, recurring orders
#if order.
return bill
@ -544,42 +547,6 @@ class BillRecord(models.Model):
return f"{self.bill}: {self.quantity} x {self.order}"
class OrderRecord(models.Model):
"""
Order records store billing informations for products: the actual product
might be mutated and/or moved to another order but we do not want to loose
the details of old orders.
Used as source of trust to dynamically generate bill entries.
"""
order = models.ForeignKey(Order, on_delete=models.CASCADE)
one_time_price = models.DecimalField(default=0.0,
max_digits=AMOUNT_MAX_DIGITS,
decimal_places=AMOUNT_DECIMALS,
validators=[MinValueValidator(0)])
recurring_price = models.DecimalField(default=0.0,
max_digits=AMOUNT_MAX_DIGITS,
decimal_places=AMOUNT_DECIMALS,
validators=[MinValueValidator(0)])
description = models.TextField()
@property
def recurring_period(self):
return self.order.recurring_period
@property
def starting_date(self):
return self.order.starting_date
@property
def ending_date(self):
return self.order.ending_date
###
# Products