From 3dff9be17694b1777c4ea2cefe7f75d49f58630f Mon Sep 17 00:00:00 2001 From: Anjeel Haria Date: Tue, 10 Sep 2024 18:00:42 +0530 Subject: [PATCH] [FIX] membership_prorate: fix for calculating quantity for prorate products Changes in test script for prorate_variable_period --- membership_prorate/models/account_move_line.py | 2 +- .../tests/test_membership_prorate_variable_period.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/membership_prorate/models/account_move_line.py b/membership_prorate/models/account_move_line.py index 47f3f68d7..0277d013e 100644 --- a/membership_prorate/models/account_move_line.py +++ b/membership_prorate/models/account_move_line.py @@ -31,7 +31,7 @@ def _prepare_invoice_line_prorate_vals(self, invoice_line): if date_invoice > date_to: date_invoice = date_to theoretical_duration = date_to - date_from + timedelta(1) - real_duration = date_to - date_invoice + real_duration = date_to - date_invoice + timedelta(1) if theoretical_duration != real_duration: return { "quantity": round( diff --git a/membership_prorate_variable_period/tests/test_membership_prorate_variable_period.py b/membership_prorate_variable_period/tests/test_membership_prorate_variable_period.py index 48af0bb0d..5fd4371fd 100644 --- a/membership_prorate_variable_period/tests/test_membership_prorate_variable_period.py +++ b/membership_prorate_variable_period/tests/test_membership_prorate_variable_period.py @@ -63,7 +63,7 @@ def test_create_invoice_membership_product_prorate_fixed(self): def test_create_invoice_membership_product_prorate_week(self): invoice = self.create_invoice("2015-01-01") # It's thursday - self.assertAlmostEqual(invoice.invoice_line_ids[0].quantity, 0.43, 2) + self.assertAlmostEqual(invoice.invoice_line_ids[0].quantity, 0.57, 2) self.assertTrue(self.partner.member_lines) self.assertEqual(self.partner.member_lines[0].state, "waiting") self.assertEqual( @@ -77,7 +77,7 @@ def test_create_invoice_membership_product_prorate_week(self): def test_create_invoice_membership_product_prorate_month(self): self.product.membership_interval_unit = "months" invoice = self.create_invoice("2015-04-15") - self.assertAlmostEqual(invoice.invoice_line_ids[0].quantity, 0.5, 2) + self.assertAlmostEqual(invoice.invoice_line_ids[0].quantity, 0.53, 2) self.assertTrue(self.partner.member_lines) self.assertEqual(self.partner.member_lines[0].state, "waiting") self.assertEqual(