Implement ending/replacing date logic

This commit is contained in:
Nico Schottelius 2020-08-27 22:00:54 +02:00
commit 18f9a3848a
2 changed files with 49 additions and 5 deletions

View file

@ -416,7 +416,7 @@ class ModifyProductTestCase(TestCase):
def test_bill_for_modified_product(self):
"""
The bill should NOT contain a partial amount -- this is a BILL TEST :-)
Modify a product, see one pro rata entry
"""
price = 5
@ -429,16 +429,32 @@ class ModifyProductTestCase(TestCase):
ending_date = timezone.make_aware(datetime.datetime(2019,3,31))
change_date = timezone.make_aware(datetime.datetime(2019,4,17))
product.create_order(starting_date)
bill_ending_date = timezone.make_aware(datetime.datetime(2019,4,30))
bills = Bill.create_next_bills_for_user(self.user,
ending_date=ending_date)
product.create_order(starting_date)
product.rc_price = 10
product.save()
product.create_or_update_recurring_order(when_to_start=change_date)
bills = Bill.create_next_bills_for_user(self.user,
ending_date=bill_ending_date)
# Sum:
# recurring1 = 5 CHF -> for 30days
# recurring2 = 5 CHF -> from 3rd of April to 3rd of May
# recurring3 = 10 CHF -> from 17th of April to ... 17th of May?
# If replacing lower order with higher:
# - close the lower order NOW
# - start higher order NOW+1s
# If replacing higher order with lower order:
# higher order continues until its end
# lower order starts after higher order+1s
self.assertEqual(bills[0].sum, price)
# expeted result:
# 1x 5 chf bill record
# 1x 5 chf bill record