pos_loyalty_discount_before.../README.md

18 lines
1.5 KiB
Markdown
Executable File

# POS Loyalty Discount Before Tax
## Overview
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
- **Before-Tax Calculation**: Overrides standard loyalty reward logic in the POS frontend, ensuring 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
- **Suherdy Yacob**