pass first 2 bill tests
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
parent
9bf0a99f6a
commit
db1a69561b
2 changed files with 18 additions and 13 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue