Product Reward Rules
Guide for creating product gift rules for sales transactions with formulas evaluated by ExpressionCalc.
Menu Route
General Rules
/form/salesproductrewardrules
When to Use This Form
Use this form to create product reward rules in sales transactions. The formula result is the reward quantity, and the system creates reward lines in the Reward and Points tab.
Buy X Get Y
Give a product reward based on the quantity of specific items purchased by the customer.
Invoice Promotion
Give a reward when transaction total, brand, supplier, or factory reaches the target.
Reward Campaign
Give seasonal rewards based on customer, salesperson, date, or other transaction conditions.
This form only manages product rewards. Customer points use Point Reward Rules.
System Overview
- Users create the rule in
/form/salesproductrewardrules. - Product-category rules are attached to Customer and Product. A rule is calculated when the same rule ID exists in the customer and the product line.
- Transaction-category rules are attached to Customer and are calculated once for the transaction.
- Users click Recalc Reward in the Reward and Points tab in Sales or Sales Order. POS calculates rewards during transaction processing.
- The system evaluates the formula and adds reward lines using the reward product and department set in the rule.
If several rules produce the same reward product, reward quantity is combined. If the formula result is 0 or negative, no reward line is created.
Before Creating a Rule
Requirement
Customer and Product reward rule fields are active in the application package.
Requirement
The reward product exists, is active, and has a base unit with quantity 1.
Requirement
The reward department is correct because it is used on the reward line.
Requirement
The formula is designed to return reward quantity, not a money amount.
Workflow
- Open General / Rules / Product Reward Rules.
- Click Add to create a new rule.
- Fill in Code, Description, and Display Name.
- Choose Product category for item reward, or Transaction category for invoice-level reward.
- Choose the Reward Product.
- Choose Department for the reward line.
- Use Variables to copy valid variable names.
- Write the reward quantity formula.
- Save the rule and attach it to Customer and Product according to its category.
- Test a transaction and click Recalc Reward to review the reward line.
Form Fields
| Field | Required | Explanation |
|---|---|---|
Code (id) | Yes | Numeric rule code stored in Customer or Product reward rule lists. |
Description (description) | Yes | Full rule name, for example "Buy 10 get 1 bottle". |
Display Name (displayname) | Yes | Short display name with a maximum of 20 characters. |
Category (category) | Yes | Product for detail-line rules. Transaction for invoice-level rules. |
Reward Product (productid) | Yes | Product given as a reward when the formula returns quantity greater than 0. |
Department (departement) | Yes | Department used on the reward line. |
Formula (formula) | Yes | Expression that returns reward quantity. Decimal quantity can be used if the company allows fractional quantity. |
| Variables and Functions | No | Autocomplete helpers for writing valid formulas. |
Attaching the Rule to Master Data
Attach Product-category rules to both Customer and Product. Attach Transaction-category rules to Customer. This prevents a product reward from running for every customer when the promotion is limited.
How the Formula Works
- The formula returns reward quantity.
- For Product category, the formula is evaluated from the detail line context.
- For Transaction category, the formula is evaluated from transaction summary context.
- The result is converted into reward detail using the reward product, department, and base unit.
Reward quantity = formula result.
0 or negative result means no reward.
Use floor(qty / x) for buy X get Y promotions.
Available Variables
| Variable Group | Examples | Notes |
|---|---|---|
| Product detail | productid, qty, unit, subtotal | Used for buy X get Y promotions. |
| Customer | customerid, customergroup | Used for customer-limited rewards. |
| Transaction | grossamount, brandgross, suppliergross | Used for invoice-level reward campaigns. |
Use the variable selector in the form to copy valid variable names. Variable names are case-sensitive.
Functions and Formula Syntax
| Function | Example | Use |
|---|---|---|
round | round(grossamount / 1000) * 1000 | Round a calculated value. |
floor | floor(qty / 10) | Return a whole number, commonly used for buy X get Y rules. |
ceil | ceil(qty / 12) | Round up when a minimum package should count as one. |
min / max | min(10, percentdisc) | Limit a result to a safe range. |
stackeddiscount | stackeddiscount(10, 5) | Calculate stacked discount logic when it is enabled in the expression engine. |
Write one expression that returns one value. Avoid multiple statements. Test the formula with realistic transaction data before using it in daily operations.
Formula Examples
| Need | Example Formula | Result |
|---|---|---|
| Buy 10 get 1 | floor(qty / 10) | Returns 1 reward for every 10 purchased. |
| Reward only for large invoice | grossamount >= 2000000 ? 1 : 0 | Returns one reward item. |
| No reward below threshold | qty >= 5 ? 1 : 0 | Returns 0 when quantity is less than 5. |
Testing Checklist
- Test a customer and product that both have the rule.
- Check the Reward and Points tab after Recalc Reward.
- Test quantity below and above the reward threshold.
- Check stock and department for the reward product.
Common Issues
- Reward does not appear: check whether the rule is attached to Customer and Product.
- Wrong reward product: check Reward Product in the rule.
- Reward quantity is wrong: check formula and rounding function.
- Reward appears for the wrong customer: check where the rule is attached.