Name:
[FIX] pos_loyalty: earn loyalty points on POS orders paid online
State:
Killed
finished in 344m
PR State:
merged
PR Author:
Roy Le
PR Author Email:
PR:
#1240
Committer:
Roy Le
Committer Email:
roy.le@viindoo.com
Commit:
93c3f61237d0d9fffdec48de2aa4a06836c6f171
Description:
[FIX] pos_loyalty: earn loyalty points on POS orders paid online
Steps to reproduce:
- Install pos_loyalty + pos_online_payment.
- Configure a nominative "loyalty" program (trigger=auto,
applies_on=both) that awards points, and an online payment method.
- In the POS, add a first-time eligible customer + a product, then pay
the order with the online payment method and let the customer pay.
Issue:
The customer earns no loyalty points (no loyalty.card is even created
for a first-time buyer). Cash orders work. The loss is intermittent for
customers whose card is already cached.
Cause:
After a successful online payment the order is rebuilt from the server
data, which does not carry the client-side `couponPointChanges`, then
re-selected.
`set_order` schedules an async `_updateRewards()` recompute but does NOT
await it, and `afterPaidOrderSavedOnServer` immediately calls
`postPushOrderResolve`, so `confirm_coupon_programs` reads an empty
`couponPointChanges`. A first-time buyer additionally needs an async
`fetchLoyaltyCard` RPC, so the recompute can never win the race.
Fix:
- `_updateRewards`: return the mutex promise so it can be awaited.
- `afterPaidOrderSavedOnServer`: await the reward recompute before
confirming the coupon programs.
Branch:
17.0
Instance ID:
0
Age:
Up-time: