Browse Source

[FIX] contract: Improve unit tests

pull/434/head
sbejaoui 5 years ago
committed by Stéphane Bidoul (ACSONE)
parent
commit
a90e18b092
No known key found for this signature in database GPG Key ID: BCAB2555446B5B92
  1. 2
      contract/models/contract_line.py
  2. 32
      contract/tests/test_contract.py

2
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

32
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'

Loading…
Cancel
Save