Use quantity instead of usage_count
This commit is contained in:
parent
8a17ee6de5
commit
126d9da764
3 changed files with 23 additions and 5 deletions
|
|
@ -336,7 +336,7 @@ class Order(models.Model):
|
|||
This logic is mainly thought to be for recurring bills, but also works for one time bills
|
||||
"""
|
||||
|
||||
return sum([ br.usage_count for br in self.bill_records.all() ])
|
||||
return sum([ br.quantity for br in self.bill_records.all() ])
|
||||
|
||||
|
||||
def active_before(self, ending_date):
|
||||
|
|
@ -502,7 +502,7 @@ class Bill(models.Model):
|
|||
bill_records=None):
|
||||
|
||||
bill_record = BillRecord.objects.create(bill=self,
|
||||
usage_count=1,
|
||||
quantity=1,
|
||||
starting_date=order.starting_date,
|
||||
ending_date=order.starting_date + timedelta(seconds=order.recurring_period))
|
||||
|
||||
|
|
@ -539,7 +539,7 @@ class BillRecord(models.Model):
|
|||
order = models.ForeignKey(Order, on_delete=models.CASCADE)
|
||||
|
||||
# How many times the order has been used in this record
|
||||
usage_count = models.IntegerField(default=1)
|
||||
quantity = models.IntegerField(default=1)
|
||||
|
||||
# The timeframe the bill record is for can (and probably often will) differ
|
||||
# from the bill time
|
||||
|
|
@ -548,7 +548,7 @@ class BillRecord(models.Model):
|
|||
ending_date = models.DateTimeField()
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.bill}: {self.usage_count} x {self.order}"
|
||||
return f"{self.bill}: {self.quantity} x {self.order}"
|
||||
|
||||
|
||||
class OrderRecord(models.Model):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue