Name:
[FIX] pos_loyalty: keep reward lines on a finalized order
State:
Killed
PR State:
merged
PR Author:
Roy Le
PR Author Email:
PR:
#1230
Committer:
Roy Le
Committer Email:
roy.le@viindoo.com
Commit:
50d54ff429723c1f32cd3e57fd6e9b15b3b79872
Description:
[FIX] pos_loyalty: keep reward lines on a finalized order
Steps to reproduce:
- Install pos_loyalty + pos_online_payment.
- Configure an automatic discount program (e.g. 1% off the order) and an
online payment method.
- In the POS, add a customer eligible for the program and a product so
the
discount reward line is added automatically.
- Pay the order with the online payment method and let the customer pay.
Issue:
The receipt printed right after the online payment is missing the
loyalty
discount line: the total is shown without the discount while the amount
actually paid is the discounted amount, so the ticket looks underpaid.
Re-printing the order later shows the correct total. With a loyalty
program
that also gives points, confirming the order additionally raises:
ValueError: invalid literal for int() with base 10: 'false'
Cause:
After a successful online payment the order is rebuilt from the data
saved
on the server and selected again. Selecting an order triggers
`_updateRewards`, which calls `_updateRewardLines` to refresh the
applied
rewards. On this rebuilt order the reward lines reference a coupon that
is
no longer in the local cache (its `coupon_id` comes back as `false` for
"current" programs that don't persist a coupon), so `_updateRewardLines`
removes them and cannot re-apply them. The order then displays a wrong
total, and `_postPushOrderResolve` sends that `false` coupon id to
`confirm_coupon_programs`, which fails when casting the key to an int.
The order is already paid and saved: its reward lines are authoritative
and
must not be recomputed.
Fix:
- `_updateRewardLines`: do nothing on a finalized order
(paid/done/invoiced)
so the rewards saved on the server are kept as-is.
- `_postPushOrderResolve`: skip reward lines that have no coupon, so no
invalid coupon id is sent to `confirm_coupon_programs`.
Branch:
17.0
Instance ID:
0
Age:
Up-time:
Not finished