def test_create_subscription_with_trial_with_correct_period(self): subscription = frappe.new_doc('Subscription') subscription.party_type = 'Customer' subscription.party = '_Test Customer' subscription.trial_period_start = nowdate() subscription.trial_period_end = add_days(nowdate(), 30) subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.save() self.assertEqual(subscription.trial_period_start, nowdate()) self.assertEqual(subscription.trial_period_end, add_days(nowdate(), 30)) self.assertEqual(add_days(subscription.trial_period_end, 1), get_date_str(subscription.current_invoice_start)) self.assertEqual(add_days(subscription.current_invoice_start, 30), get_date_str(subscription.current_invoice_end)) self.assertEqual(subscription.invoices, []) self.assertEqual(subscription.status, 'Trialling') subscription.delete()
def test_create_subscription_with_trial_with_correct_period(self): subscription = frappe.new_doc("Subscription") subscription.party_type = "Customer" subscription.party = "_Test Customer" subscription.trial_period_start = nowdate() subscription.trial_period_end = add_months(nowdate(), 1) subscription.append("plans", {"plan": "_Test Plan Name", "qty": 1}) subscription.save() self.assertEqual(subscription.trial_period_start, nowdate()) self.assertEqual(subscription.trial_period_end, add_months(nowdate(), 1)) self.assertEqual( add_days(subscription.trial_period_end, 1), get_date_str(subscription.current_invoice_start) ) self.assertEqual( add_to_date(subscription.current_invoice_start, months=1, days=-1), get_date_str(subscription.current_invoice_end), ) self.assertEqual(subscription.invoices, []) self.assertEqual(subscription.status, "Trialling") subscription.delete()
def test_subscription_with_follow_calendar_months(self): subscription = frappe.new_doc('Subscription') subscription.party_type = 'Supplier' subscription.party = '_Test Supplier' subscription.generate_invoice_at_period_start = 1 subscription.follow_calendar_months = 1 # select subscription start date as '2018-01-15' subscription.start_date = '2018-01-15' subscription.end_date = '2018-07-15' subscription.append('plans', {'plan': '_Test Plan Name 4', 'qty': 1}) subscription.save() # even though subscription starts at '2018-01-15' and Billing interval is Month and count 3 # First invoice will end at '2018-03-31' instead of '2018-04-14' self.assertEqual(get_date_str(subscription.current_invoice_end), '2018-03-31')