erpnext icon indicating copy to clipboard operation
erpnext copied to clipboard

fix: tiered loyalty program

Open blaggacao opened this issue 1 year ago • 13 comments

... what the name says.

blaggacao avatar May 21 '24 05:05 blaggacao

@deepeshgarg007 Could you have a look? I have no idea for how many years this was actually broken :eyes:

blaggacao avatar May 22 '24 15:05 blaggacao

Test failure prior to fix (revert fix commit and check):

❯ bench run-tests --doctype "Company"
❯ bench run-tests --doctype "Customer"
❯ bench run-tests --module "erpnext.accounts.doctype.loyalty_program.test_loyalty_program"
/nix/store/srn5qp23ili0a1gbq2q8v2yqyshqfkws-python3-3.11.9-env/lib/python3.11/site-packages/passlib/utils/__init__.py:854: DeprecationWarning: 'crypt' is deprecated and slated for removal in Python 3.13
  from crypt import crypt as _crypt

test_cancel_sales_invoice (erpnext.accounts.doctype.loyalty_program.test_loyalty_program.TestLoyaltyProgram.test_cancel_sales_invoice)
cancelling the sales invoice should cancel the earned points (2.21s)
.....FFF
======================================================================
FAIL: test_tier_selection (erpnext.accounts.doctype.loyalty_program.test_loyalty_program.TestLoyaltyProgram.test_tier_selection) (total_spent=0, current_transaction_amount=6000)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/blaggacao/src/gitlab.com/pristina/infraestructura/apps/erpnext/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py", line 255, in test_tier_selection
    self.assertEqual(
AssertionError: 'Silver' != 'Bronze'
- Silver
+ Bronze
 : Expected tier Bronze for total_spent 0 and current_transaction_amount 6000, but got Silver

======================================================================
FAIL: test_tier_selection (erpnext.accounts.doctype.loyalty_program.test_loyalty_program.TestLoyaltyProgram.test_tier_selection) (total_spent=0, current_transaction_amount=15000)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/blaggacao/src/gitlab.com/pristina/infraestructura/apps/erpnext/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py", line 255, in test_tier_selection
    self.assertEqual(
AssertionError: 'Gold' != 'Silver'
- Gold
+ Silver
 : Expected tier Silver for total_spent 0 and current_transaction_amount 15000, but got Gold

======================================================================
FAIL: test_tier_selection (erpnext.accounts.doctype.loyalty_program.test_loyalty_program.TestLoyaltyProgram.test_tier_selection) (total_spent=8000, current_transaction_amount=3000)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/blaggacao/src/gitlab.com/pristina/infraestructura/apps/erpnext/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py", line 255, in test_tier_selection
    self.assertEqual(
AssertionError: 'Gold' != 'Silver'
- Gold
+ Silver
 : Expected tier Silver for total_spent 8000 and current_transaction_amount 3000, but got Gold

----------------------------------------------------------------------
Ran 6 tests in 5.229s

FAILED (failures=3)

blaggacao avatar Sep 05 '24 10:09 blaggacao

Since this fixes a long standing misbehaviour, I removed the hotfix to 15, which I think needs more discussion. See inline comments... (tbd)

blaggacao avatar Sep 05 '24 12:09 blaggacao