feat: use unique rewardCode as reward_group_id to prevent visual merging of distinct loyalty claims in POS UI

This commit is contained in:
Suherdy Yacob 2026-05-25 10:04:07 +07:00
parent 56af841052
commit adb7b5e1d3
2 changed files with 10 additions and 4 deletions

View File

@ -1,11 +1,17 @@
# POS Loyalty Discount Before Tax # POS Loyalty Discount Before Tax
## Overview ## Overview
This custom Odoo 19 module modifies the standard Point of Sale (POS) loyalty reward calculation. By default, Odoo may calculate certain loyalty discounts after taxes. This module ensures that loyalty discounts are applied **before** tax calculations, meaning the tax is calculated based on the discounted subtotal. This custom Odoo 19 module modifies the standard Point of Sale (POS) loyalty reward calculation and display. By default, Odoo may calculate certain loyalty discounts after taxes. This module ensures that loyalty discounts are applied **before** tax calculations, meaning the tax is calculated based on the discounted subtotal.
## Features ## Features
- Overrides standard loyalty reward logic in the POS frontend. - **Before-Tax Calculation**: Overrides standard loyalty reward logic in the POS frontend, ensuring tax amounts accurately reflect the post-discount price.
- Ensures tax amounts accurately reflect the post-discount price. - **Split-Tax UI Grouping**: When Odoo splits a single reward discount line into multiple rows in the database to accommodate different tax categories, this module groups them back together in the POS UI.
- **Per-Claim Separation**: Uses a unique per-claim identifier (`rewardCode`) as the `reward_group_id`. This prevents distinct claims of the same reward (e.g. claiming a "cheapest product" discount twice) from visually merging in the POS interface, maintaining parity between the POS screen and the printed receipt.
## Technical Details
- Patches `PosOrder` in `loyalty.js` to calculate discountable amounts before tax, generate unique `rewardCode` groups, and inject the layout-grouping attributes `is_reward_group_member`, `is_reward_group_head`, and `reward_group_id`.
- Patches `PosOrderline` in `orderline.js` to aggregate prices and quantities of member lines under the group head, and hide secondary grouped lines using the `d-none` class.
## Author ## Author
- **Suherdy Yacob** - **Suherdy Yacob**

View File

@ -259,7 +259,7 @@ patch(PosOrder.prototype, {
is_reward_group_member : true, is_reward_group_member : true,
is_reward_group_head : false, is_reward_group_head : false,
reward_group_id : reward.id, reward_group_id : rewardCode,
}); });
return lst; return lst;
}, []); }, []);