forked from uncloud/uncloud
Fix tests for billing
This commit is contained in:
parent
89519e48a9
commit
6a928a2b2a
2 changed files with 12 additions and 4 deletions
|
@ -327,7 +327,7 @@ class Order(models.Model):
|
||||||
One time orders have a recurring period of 0, so this work universally
|
One time orders have a recurring period of 0, so this work universally
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return self.starting_date + timedelta(seconds=self.recurring_period)
|
return self.starting_date + datetime.timedelta(seconds=self.recurring_period)
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -438,7 +438,7 @@ class Bill(models.Model):
|
||||||
starting_date = last_bill.starting_date
|
starting_date = last_bill.starting_date
|
||||||
ending_date = bill.ending_date
|
ending_date = bill.ending_date
|
||||||
else:
|
else:
|
||||||
starting_date = last_bill.end_date + datetime.timedelta(seconds=1)
|
starting_date = last_bill.ending_date + datetime.timedelta(seconds=1)
|
||||||
else:
|
else:
|
||||||
if first_order:
|
if first_order:
|
||||||
starting_date = first_order.starting_date
|
starting_date = first_order.starting_date
|
||||||
|
@ -566,6 +566,13 @@ class Bill(models.Model):
|
||||||
# For each recurring order get the usage and bill it
|
# For each recurring order get the usage and bill it
|
||||||
|
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
"""
|
||||||
|
Close/finish a bill
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.is_final = True
|
||||||
|
self.save()
|
||||||
|
|
||||||
class BillRecord(models.Model):
|
class BillRecord(models.Model):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -188,9 +188,10 @@ class BillAndOrderTestCase(TestCase):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for ending_date in self.bill_dates:
|
for ending_date in self.bill_dates:
|
||||||
Bill.create_next_bill_for_user(self.recurring_user, ending_date)
|
b = Bill.create_next_bill_for_user(self.recurring_user, ending_date)
|
||||||
|
b.close()
|
||||||
|
|
||||||
bills_count = Bill.objects.filter(owner=self.recurring_user).count()
|
bill_count = Bill.objects.filter(owner=self.recurring_user).count()
|
||||||
|
|
||||||
self.assertEqual(len(self.bill_dates), bill_count)
|
self.assertEqual(len(self.bill_dates), bill_count)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue