[REF] contract: make recurring_invoicing_offset a computed field

In preparation to making it user modifiable.
This commit is contained in:
Stéphane Bidoul (ACSONE)
2019-12-09 10:21:20 +01:00
committed by Jean-Charles Drubay
parent 3257a058f4
commit 901d934ed8
4 changed files with 112 additions and 44 deletions

View File

@@ -537,6 +537,33 @@ class TestContract(TestContractBase):
'There was an error and the view couldn\'t be opened.',
)
def test_get_default_recurring_invoicing_offset(self):
clm = self.env['contract.line']
self.assertEqual(
clm._get_default_recurring_invoicing_offset(
"pre-paid", "monthly"
),
0
)
self.assertEqual(
clm._get_default_recurring_invoicing_offset(
"post-paid", "monthly"
),
1
)
self.assertEqual(
clm._get_default_recurring_invoicing_offset(
"pre-paid", "monthlylastday"
),
0
)
self.assertEqual(
clm._get_default_recurring_invoicing_offset(
"post-paid", "monthlylastday"
),
0
)
def test_get_recurring_next_date(self):
"""Test different combination to compute recurring_next_date
Combination format
@@ -555,87 +582,92 @@ class TestContract(TestContractBase):
def error_message(
date_start,
recurring_invoicing_type,
recurring_invoicing_offset,
recurring_rule_type,
recurring_interval,
max_date_end,
):
return "Error in %s every %d %s case, start with %s (max_date_end=%s)" % (
recurring_invoicing_type,
recurring_interval,
recurring_rule_type,
date_start,
max_date_end,
return (
"Error in %s-%d every %d %s case, "
"start with %s (max_date_end=%s)" % (
recurring_invoicing_type,
recurring_invoicing_offset,
recurring_interval,
recurring_rule_type,
date_start,
max_date_end,
)
)
combinations = [
(
to_date('2018-01-01'),
(to_date('2018-01-01'), 'pre-paid', 'monthly', 1,
(to_date('2018-01-01'), 'pre-paid', 0, 'monthly', 1,
False),
),
(
to_date('2018-01-01'),
(to_date('2018-01-01'), 'pre-paid', 'monthly', 1,
(to_date('2018-01-01'), 'pre-paid', 0, 'monthly', 1,
to_date('2018-01-15')),
),
(
False,
(to_date('2018-01-16'), 'pre-paid', 'monthly', 1,
(to_date('2018-01-16'), 'pre-paid', 0, 'monthly', 1,
to_date('2018-01-15')),
),
(
to_date('2018-01-01'),
(to_date('2018-01-01'), 'pre-paid', 'monthly', 2,
(to_date('2018-01-01'), 'pre-paid', 0, 'monthly', 2,
False),
),
(
to_date('2018-02-01'),
(to_date('2018-01-01'), 'post-paid', 'monthly', 1,
(to_date('2018-01-01'), 'post-paid', 1, 'monthly', 1,
False),
),
(
to_date('2018-01-16'),
(to_date('2018-01-01'), 'post-paid', 'monthly', 1,
(to_date('2018-01-01'), 'post-paid', 1, 'monthly', 1,
to_date('2018-01-15')),
),
(
False,
(to_date('2018-01-16'), 'post-paid', 'monthly', 1,
(to_date('2018-01-16'), 'post-paid', 1, 'monthly', 1,
to_date('2018-01-15')),
),
(
to_date('2018-03-01'),
(to_date('2018-01-01'), 'post-paid', 'monthly', 2,
(to_date('2018-01-01'), 'post-paid', 1, 'monthly', 2,
False),
),
(
to_date('2018-01-31'),
(to_date('2018-01-05'), 'post-paid', 'monthlylastday', 1,
(to_date('2018-01-05'), 'post-paid', 0, 'monthlylastday', 1,
False),
),
(
to_date('2018-01-06'),
(to_date('2018-01-06'), 'pre-paid', 'monthlylastday', 1,
(to_date('2018-01-06'), 'pre-paid', 0, 'monthlylastday', 1,
False),
),
(
to_date('2018-02-28'),
(to_date('2018-01-05'), 'post-paid', 'monthlylastday', 2,
(to_date('2018-01-05'), 'post-paid', 0, 'monthlylastday', 2,
False),
),
(
to_date('2018-01-05'),
(to_date('2018-01-05'), 'pre-paid', 'monthlylastday', 2,
(to_date('2018-01-05'), 'pre-paid', 0, 'monthlylastday', 2,
False),
),
(
to_date('2018-01-05'),
(to_date('2018-01-05'), 'pre-paid', 'yearly', 1,
(to_date('2018-01-05'), 'pre-paid', 0, 'yearly', 1,
False),
),
(
to_date('2019-01-05'),
(to_date('2018-01-05'), 'post-paid', 'yearly', 1,
(to_date('2018-01-05'), 'post-paid', 1, 'yearly', 1,
False),
),
]