Sales discount calculator
Loyalty, volume pricing and PIX on the same order. Which saves the most?
Try the calculator3 rules, 1 best totalinternal tool delivered to the sales team
The story
When closing an order, the sales team had to compare loyalty pricing, volume pricing and PIX. The calculator compares the options and shows the lowest total.

Each unit receives a single discount.
Toggle PIX on this sample order and watch the total change. You can also adjust quantities.
Standard
—
PIX
—
Why did this total win?
The rules
- Loyalty pricing depends on the gross order amount. Volume pricing depends on the quantity of each reference.
- The engine compares the available discounts for each reference and applies one.
- The PIX discount is rounded on the eligible total so the cents reconcile across the order.
- For every scenario: gross − savings = final.
How the engine decides
- Validate quantities and represent amounts as integer cents.
- Find the loyalty tier from the gross order amount.
- Apply volume pricing by reference and quantity.
- Calculate the PIX scenario separately.
- The largest savings win. The standard scenario wins a tie.
- Verify that gross − savings = final.
Rules, calculations and interface code live in separate files, so the business logic can be tested without a browser. The interface was tested in both themes at 1440, 390 and 320 px. The order stays in browser memory.