From 47eb821dc6f71f40531906754eca69829d2cc327 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Wed, 18 Dec 2019 17:34:17 +0100 Subject: [PATCH] [IMP] - add failing test for monthlylastday, pre-paid case --- .../test_contract_line_forecast_period.py | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/contract_forecast/tests/test_contract_line_forecast_period.py b/contract_forecast/tests/test_contract_line_forecast_period.py index 702c169b..2f182ce2 100644 --- a/contract_forecast/tests/test_contract_line_forecast_period.py +++ b/contract_forecast/tests/test_contract_line_forecast_period.py @@ -158,3 +158,105 @@ class TestContractLineForecastPeriod(TestContractBase): ) self.assertTrue(self.acct_line.forecast_period_ids) self.assertEqual(len(self.acct_line.forecast_period_ids), 1) + + @mute_logger("odoo.addons.queue_job.models.base") + def test_forecast_period_on_contract_line_update_9(self): + self.acct_line.write( + { + 'date_start': "2019-01-14", + 'recurring_next_date': "2019-01-31", + 'date_end': "2020-01-14", + 'recurring_rule_type': "monthlylastday", + 'last_date_invoiced': False, + 'recurring_invoicing_type': 'post-paid', + } + ) + self.assertTrue(self.acct_line.forecast_period_ids) + self.assertEqual(len(self.acct_line.forecast_period_ids), 13) + self.assertEqual( + ( + self.acct_line.forecast_period_ids[0].date_start, + self.acct_line.forecast_period_ids[0].date_end, + self.acct_line.forecast_period_ids[0].date_invoice, + ), + ( + Date.to_date("2019-01-14"), + Date.to_date("2019-01-31"), + Date.to_date("2019-01-31"), + ), + ) + self.assertEqual( + ( + self.acct_line.forecast_period_ids[1].date_start, + self.acct_line.forecast_period_ids[1].date_end, + self.acct_line.forecast_period_ids[1].date_invoice, + ), + ( + Date.to_date("2019-02-01"), + Date.to_date("2019-02-28"), + Date.to_date("2019-02-28"), + ), + ) + self.assertEqual( + ( + self.acct_line.forecast_period_ids[-1].date_start, + self.acct_line.forecast_period_ids[-1].date_end, + self.acct_line.forecast_period_ids[-1].date_invoice, + ), + ( + Date.to_date("2020-01-01"), + Date.to_date("2020-01-14"), + Date.to_date("2020-01-14"), + ), + ) + + @mute_logger("odoo.addons.queue_job.models.base") + def test_forecast_period_on_contract_line_update_10(self): + self.acct_line.write( + { + 'date_start': "2019-01-14", + 'recurring_next_date': "2019-01-14", + 'date_end': "2020-01-14", + 'recurring_rule_type': "monthlylastday", + 'last_date_invoiced': False, + 'recurring_invoicing_type': 'pre-paid', + } + ) + self.assertTrue(self.acct_line.forecast_period_ids) + self.assertEqual(len(self.acct_line.forecast_period_ids), 13) + self.assertEqual( + ( + self.acct_line.forecast_period_ids[0].date_start, + self.acct_line.forecast_period_ids[0].date_end, + self.acct_line.forecast_period_ids[0].date_invoice, + ), + ( + Date.to_date("2019-01-14"), + Date.to_date("2019-01-31"), + Date.to_date("2019-01-14"), + ), + ) + self.assertEqual( + ( + self.acct_line.forecast_period_ids[1].date_start, + self.acct_line.forecast_period_ids[1].date_end, + self.acct_line.forecast_period_ids[1].date_invoice, + ), + ( + Date.to_date("2019-02-01"), + Date.to_date("2019-02-28"), + Date.to_date("2019-02-01"), + ), + ) + self.assertEqual( + ( + self.acct_line.forecast_period_ids[-1].date_start, + self.acct_line.forecast_period_ids[-1].date_end, + self.acct_line.forecast_period_ids[-1].date_invoice, + ), + ( + Date.to_date("2020-01-01"), + Date.to_date("2020-01-14"), + Date.to_date("2020-01-01"), + ), + )