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

  1. Users create the rule in /form/salesproductrewardrules.
  2. 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.
  3. Transaction-category rules are attached to Customer and are calculated once for the transaction.
  4. Users click Recalc Reward in the Reward and Points tab in Sales or Sales Order. POS calculates rewards during transaction processing.
  5. 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

  1. Open General / Rules / Product Reward Rules.
  2. Click Add to create a new rule.
  3. Fill in Code, Description, and Display Name.
  4. Choose Product category for item reward, or Transaction category for invoice-level reward.
  5. Choose the Reward Product.
  6. Choose Department for the reward line.
  7. Use Variables to copy valid variable names.
  8. Write the reward quantity formula.
  9. Save the rule and attach it to Customer and Product according to its category.
  10. Test a transaction and click Recalc Reward to review the reward line.

Form Fields

FieldRequiredExplanation
Code (id)YesNumeric rule code stored in Customer or Product reward rule lists.
Description (description)YesFull rule name, for example "Buy 10 get 1 bottle".
Display Name (displayname)YesShort display name with a maximum of 20 characters.
Category (category)YesProduct for detail-line rules. Transaction for invoice-level rules.
Reward Product (productid)YesProduct given as a reward when the formula returns quantity greater than 0.
Department (departement)YesDepartment used on the reward line.
Formula (formula)YesExpression that returns reward quantity. Decimal quantity can be used if the company allows fractional quantity.
Variables and FunctionsNoAutocomplete 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

  1. The formula returns reward quantity.
  2. For Product category, the formula is evaluated from the detail line context.
  3. For Transaction category, the formula is evaluated from transaction summary context.
  4. 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 GroupExamplesNotes
Product detailproductid, qty, unit, subtotalUsed for buy X get Y promotions.
Customercustomerid, customergroupUsed for customer-limited rewards.
Transactiongrossamount, brandgross, suppliergrossUsed 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

FunctionExampleUse
roundround(grossamount / 1000) * 1000Round a calculated value.
floorfloor(qty / 10)Return a whole number, commonly used for buy X get Y rules.
ceilceil(qty / 12)Round up when a minimum package should count as one.
min / maxmin(10, percentdisc)Limit a result to a safe range.
stackeddiscountstackeddiscount(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

NeedExample FormulaResult
Buy 10 get 1floor(qty / 10)Returns 1 reward for every 10 purchased.
Reward only for large invoicegrossamount >= 2000000 ? 1 : 0Returns one reward item.
No reward below thresholdqty >= 5 ? 1 : 0Returns 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.