• Building a feature
  • Clean architecture
  • Worfklows

    • Synchronization
    • Discarding a visit
  • Prices
  • Documents
  • Building a feature
  • Clean architecture
  • Worfklows

    • Synchronization
    • Discarding a visit
  • Prices
  • Documents
  • Engineering

    • Building a feature
    • Clean architecture
    • Worfklows

      • Synchronization
      • Discarding a visit
  • Specifications

    • Prices
    • Documents

Prices

This module manages the pricing logic within the system, covering base material prices, as well as special prices and discounts that apply to specific trader groups or material groups.

The database schema related to the prices is depicted below. Although some tables (marked in green) are not directly part of the pricing schema, they are essential dependencies for defining the price logic.

Prices Schema

Price Catalogs

Image

Price catalogs are collections of material prices that are valid for a defined period. They do not apply any specific rules or conditions beyond this timeframe. Multiple price catalogs can overlap and apply during the same period.

If a material has defined prices in both catalogs, both catalogs will be considered when determining the final price according to the pricing policy defined.

When a new price is added for a material that already has a price set in a catalog, the system will move the existing price to the previous_price field. This ensures that historical price information is retained but only for the previous edit.

If Material X has a price of 100€ in Price Catalog A and is later updated to 120€, the system will save 100€ as the previous price.

Pricing Policy

Pricing Policy Schema

Pricing policies define the rules for how prices are selected and applied across catalogs. There are two primary approaches for defining a pricing policy defined below.

Pricing Policy by Order

In this approach, pricing is based on a defined order of price catalogs. The system selects the price of a material from the first available catalog in the ordered list. The search proceeds in order until it finds the first valid price for the material (the smaller the sequence column value the higher appears on the list). No negative values are allowed to the sequence.

Suppose Material X exists in Price Catalog A and Price Catalog B, and the pricing policy orders them as follows:

  1. Price Catalog B
  2. Price Catalog A

When looking for the price of Material X, the system first checks Price Catalog B. If it finds a price there, it uses that price. If no price is found, it then checks Price Catalog A.

Pricing Policy by Matrix

The matrix approach allows for more detailed and specific pricing rules by combining conditions based on trader groups, material groups, individual traders, and individual materials.

The matrix approach starts with a base Pricing Policy by Order and adds rules to refine the pricing further based on specific criteria, such as:

  • Trader Site Group – Groups of traders or retail sites
  • Material Group – Categories of materials
  • Trader Site – Individual traders or retail locations
  • Material – Individual materials

These additional rules allow for more flexible pricing strategies by overriding the base catalog prices with specific discounts or special prices. However, there are some restrictions:

  • Trader Site Group cannot be combined with Trader Site within the same policy.
  • Material Group cannot be combined with Material within the same policy.

All discounts or special prices defined in a policy are applied on top of the base price found using the Pricing Policy by Order. When multiple discounts can be applied, they are now applied in ascending order of their DiscountSequence. If multiple discounts have the same DiscountSequence, they are applied to the same price. Otherwise, discounts are applied in sequence to the result of the previously applied discount. The logic follows this structure:

  1. DiscountSequence determines the order in which discounts are applied.
  2. Discounts with the same DiscountSequence are applied simultaneously to the result of the previous discount or if no discounts have been appliued to the base price.
  3. Discounts with different sequences are applied in order, with each subsequent discount applied to the result of the previous discount.
  4. If not DiscountSequence is defined by the user the system sets the value of 0. No negative values are allowed.

Defining a matrix policy for Material X in Price Catalog A:

  • Base price for Material X in Price Catalog A: 100€
  • Matrix rules:
  1. Apply a 10% discount for Trader Site Group Y and Material Group Z (DiscountSequence 0)
  2. Apply a 7% discount for Material Group Z and Trader Site W (DiscountSequence 0)
  3. Apply a 5% discount for Material X and Trader Site W (DiscountSequence 1)

The system first determines the base price for Material X using the Pricing Policy by Order, > which is 100€. Then, it applies the discounts as follows:

  1. The 10% discount (DiscountSequence 0) reduces the price to 100€ - 10% = 90€.
  2. The 7% discount (DiscountSequence 0) is applied again to the base price, reducing the price to 100€ - 7% = 93€. After the two discounts applied the new price will be 100€ - 10€ - 7€ = 83€ .
  3. Finally, the 5% discount (DiscountSequence 1) is applied, resulting in a final price of 79€.

If all discounts had the same DiscountSequence, they would be applied together on the original base > price. For example, if all had DiscountSequence 0, the calculation would be:

  • 100€ - 10% - 7% - 5% = 78€ directly from the base price.
Last Updated:
Contributors: gabriels, Gabriel Samolis
Next
Documents