Skip to main content

Price Rules

Price rules in Quantaprice provide a controlled way to adjust prices during calculation without introducing a full rule engine.
They are designed to be fast, deterministic, and easy to reason about.
Rather than acting as an open-ended scripting system, price rules serve as small, well-defined modifiers that slot into the price calculation pipeline.

Rules can target individual items, entire price lists, bundles, or groups of products through metadata.
They allow you to express common commercial logic — discounts, markups, overrides, or conditional adjustments — while keeping behaviour predictable across all replicas and environments.


Core Design Principles

Deterministic behaviour

All rules produce the same result given the same inputs.
There is no randomness, no dynamic evaluation order, and no dependencies on external state.
This is essential for replication, caching, and debugging.

Lightweight and explicit

Price rules are not a scripting language, not a workflow, and not a general-purpose engine.
They represent small, targeted modifications, kept intentionally simple to avoid unpredictable interactions or runaway complexity.

Integrated into the pipeline

Rules run in a fixed place within the pricing pipeline:

Base Price → Rule Adjustments → FX → VAT → Rounding

This ensures that rules do not interfere with structural logic such as currency conversions or VAT mode decisions.

Metadata-driven targeting

Rules can match articles or price lists by metadata.
This allows flexible segmentation without schema changes or index rebuilds.
For example:

  • Apply 5% markup to all products tagged "category": "hardware"
  • Apply discount to "brand": "Acme" for a specific customer list
  • Adjust a bundle component only if it carries a certain tag

Matching is fast because metadata filters are backed by bitmaps and cached structures.

Designed to scale

Rules evaluate efficiently even at high SKU counts and large batch queries.
The system avoids per-product rule trees, recursive evaluation, or runtime interpretation.


What Price Rules Can Do (MVP)

The current rule model supports the most important and common adjustments:

Percentage-based adjustments

  • +5% markup
  • -10% discount
  • ±X% relative to base or list price

Absolute adjustments

  • - 2.00 price reduction
  • + 3.50 surcharge

Fixed price setting

  • Force price to a specific value for targeted SKUs or metadata groups.
    Useful for campaigns, contract overrides, and correction logic.

Quantity-aware adjustments

Rules can operate on the resolved quantity tier, allowing different adjustments based on order quantity or the active break.

Bundle-aware adjustments

Rules may apply to the bundle as a whole or individual components.
For components, they can adjust the component price before bundle aggregation.


What Price Rules Do Not Do (by design)

To preserve clarity and predictability, rules intentionally do not include:

  • recursive rule evaluation
  • condition trees or nested logic
  • scripting languages
  • referencing external state
  • accessing external services
  • overrides based on dynamic user input
  • date-range logic (handled by scheduled updates instead)
  • multi-step workflows

These restrictions ensure rules remain fast, deterministic, and safe for replication.


Future Expansion (Tier-2 Rules)

Based on past discussions, advanced rules are planned for Tier-2:

  • conditional expressions:
    if metadata["brand"] == "Acme" and qty > 10 then -5%
  • rule groups with ordering
  • expression-based overrides
  • dynamic price fields (cost+, margin targets, etc.)
  • sequence-aware rules
  • mutually exclusive rules based on metadata priority

These will remain deterministic and pipeline-safe, but allow more nuanced commercial logic.


Summary

Price rules in Quantaprice provide a safe, predictable way to adjust prices without turning the system into a general-purpose rule engine.
They integrate cleanly with the pricing pipeline, scale to large catalogs, and can target products or price lists using metadata.
The result is a rule system that supports real commercial needs while avoiding the complexity and fragility of traditional rule engines.