diff --git a/contract/models/contract_line.py b/contract/models/contract_line.py index 1a5fa3d0..aacb2c1d 100644 --- a/contract/models/contract_line.py +++ b/contract/models/contract_line.py @@ -664,7 +664,7 @@ class ContractLine(models.Model): self.ensure_one() first_date_invoiced = False if not recurring_next_date: - return first_date_invoiced, last_date_invoiced, recurring_next_date + return first_date_invoiced, False, recurring_next_date first_date_invoiced = ( last_date_invoiced + relativedelta(days=1) if last_date_invoiced diff --git a/contract/tests/test_contract.py b/contract/tests/test_contract.py index e6bf09ec..b9ed4edd 100644 --- a/contract/tests/test_contract.py +++ b/contract/tests/test_contract.py @@ -1412,6 +1412,10 @@ class TestContract(TestContractBase): ) self.assertEqual(first, to_date('2018-01-05')) self.assertEqual(last, to_date('2018-01-31')) + self.assertEqual(recurring_next_date, to_date('2018-01-05')) + self.assertEqual( + self.acct_line.recurring_next_date, to_date('2018-01-05') + ) self.contract.recurring_create_invoice() first, last, recurring_next_date = \ self.acct_line._get_period_to_invoice( @@ -1420,6 +1424,13 @@ class TestContract(TestContractBase): ) self.assertEqual(first, to_date('2018-02-01')) self.assertEqual(last, to_date('2018-02-28')) + self.assertEqual(recurring_next_date, to_date('2018-02-01')) + self.assertEqual( + self.acct_line.recurring_next_date, to_date('2018-02-01') + ) + self.assertEqual( + self.acct_line.last_date_invoiced, to_date('2018-01-31') + ) self.contract.recurring_create_invoice() first, last, recurring_next_date = \ self.acct_line._get_period_to_invoice( @@ -1428,7 +1439,26 @@ class TestContract(TestContractBase): ) self.assertEqual(first, to_date('2018-03-01')) self.assertEqual(last, to_date('2018-03-15')) - self.acct_line.manual_renew_needed = True + self.assertEqual(recurring_next_date, to_date('2018-03-01')) + self.assertEqual( + self.acct_line.recurring_next_date, to_date('2018-03-01') + ) + self.assertEqual( + self.acct_line.last_date_invoiced, to_date('2018-02-28') + ) + self.contract.recurring_create_invoice() + first, last, recurring_next_date = \ + self.acct_line._get_period_to_invoice( + self.acct_line.last_date_invoiced, + self.acct_line.recurring_next_date, + ) + self.assertFalse(first) + self.assertFalse(last) + self.assertFalse(recurring_next_date) + self.assertFalse(self.acct_line.recurring_next_date) + self.assertEqual( + self.acct_line.last_date_invoiced, to_date('2018-03-15') + ) def test_get_period_to_invoice_monthly_pre_paid_2(self): self.acct_line.date_start = '2018-01-05'