mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[IMP] contract: support pre-paid for monthlylastday
monthlylastday is (almost) not a special case anymore \o/. montlylastday is simply a montly period where the periods are aligned on month boundaries. The last bit of special casing is that postpaid generates invoice the day after the last dasy of the period, except for monthlylastday where the invoice is generated on the last day of the period. This last exception will disappear when we put the offset under user control. This is a breaking change because the post-paid/pre-paid mode becomes relevant for monthlylastday invoicing. The field becomes visible in the UI. Code that generate monthlylastday contract lines must now correctly set the pre-paid/post-paid mode too. Some tests have had to be adapted to reflect that.
This commit is contained in:
committed by
Francisco Ivan Anton Prieto
parent
4b2f0d2e25
commit
7649f5b385
@@ -614,12 +614,17 @@ class TestContract(TestContractBase):
|
||||
False),
|
||||
),
|
||||
(
|
||||
to_date('2018-01-31'),
|
||||
to_date('2018-01-06'),
|
||||
(to_date('2018-01-06'), 'pre-paid', 'monthlylastday', 1,
|
||||
False),
|
||||
),
|
||||
(
|
||||
to_date('2018-02-28'),
|
||||
(to_date('2018-01-05'), 'post-paid', 'monthlylastday', 2,
|
||||
False),
|
||||
),
|
||||
(
|
||||
to_date('2018-01-05'),
|
||||
(to_date('2018-01-05'), 'pre-paid', 'monthlylastday', 2,
|
||||
False),
|
||||
),
|
||||
@@ -1363,7 +1368,7 @@ class TestContract(TestContractBase):
|
||||
len(invoice_lines),
|
||||
)
|
||||
|
||||
def test_get_period_to_invoice_monthlylastday(self):
|
||||
def test_get_period_to_invoice_monthlylastday_postpaid(self):
|
||||
self.acct_line.date_start = '2018-01-05'
|
||||
self.acct_line.recurring_invoicing_type = 'post-paid'
|
||||
self.acct_line.recurring_rule_type = 'monthlylastday'
|
||||
@@ -1394,6 +1399,37 @@ class TestContract(TestContractBase):
|
||||
self.assertEqual(last, to_date('2018-03-15'))
|
||||
self.acct_line.manual_renew_needed = True
|
||||
|
||||
def test_get_period_to_invoice_monthlylastday_prepaid(self):
|
||||
self.acct_line.date_start = '2018-01-05'
|
||||
self.acct_line.recurring_invoicing_type = 'pre-paid'
|
||||
self.acct_line.recurring_rule_type = 'monthlylastday'
|
||||
self.acct_line.date_end = '2018-03-15'
|
||||
self.acct_line._onchange_date_start()
|
||||
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.assertEqual(first, to_date('2018-01-05'))
|
||||
self.assertEqual(last, to_date('2018-01-31'))
|
||||
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.assertEqual(first, to_date('2018-02-01'))
|
||||
self.assertEqual(last, 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.assertEqual(first, to_date('2018-03-01'))
|
||||
self.assertEqual(last, to_date('2018-03-15'))
|
||||
self.acct_line.manual_renew_needed = True
|
||||
|
||||
def test_get_period_to_invoice_monthly_pre_paid_2(self):
|
||||
self.acct_line.date_start = '2018-01-05'
|
||||
self.acct_line.recurring_invoicing_type = 'pre-paid'
|
||||
|
||||
Reference in New Issue
Block a user