pass first 2 bill tests

Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
Nico Schottelius 2020-08-08 22:31:43 +02:00
commit db1a69561b
2 changed files with 18 additions and 13 deletions

View file

@ -399,8 +399,8 @@ class Bill(models.Model):
@property
def sum(self):
return 0
# for self.billrecord_set.
bill_records = BillRecord.objects.filter(bill=self)
return sum([ br.sum for br in bill_records ])
@classmethod
@ -525,9 +525,10 @@ class BillRecord(models.Model):
starting_date = models.DateTimeField()
ending_date = models.DateTimeField()
@property
def quantity(self):
""" Determine the quantity by the duration"""
if self.order.is_recurring:
if self.order.is_one_time:
return 1
record_delta = self.ending_date - self.starting_date
@ -535,6 +536,7 @@ class BillRecord(models.Model):
return record_delta.total_seconds()/self.order.recurring_period
@property
def sum(self):
return self.order.price * self.quantity