Skip to content

Commit

Permalink
[FIX] membership_prorate: fix for calculating quantity for prorate pr…
Browse files Browse the repository at this point in the history
…oducts

Changes in test script for prorate_variable_period
  • Loading branch information
ByteMeAsap committed Sep 10, 2024
1 parent 299c370 commit 3dff9be
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion membership_prorate/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit 3dff9be

Please sign in to comment.