Domain Model (Spec)
The domain model of the External Pricing-API consists of the core object types PricingEngineContext
and PricingEngineResult
. A PricingEngineContext
is sent to the external pricing logic which is expected to return a PricingEngineResult
.
Line items
Both PricingEngineContext
and PricingEngineResult
mainly consist of items. In case of the context, those are of type PricingEngineContextLineItem
. For the result, the items are either PricingEngineResultItem
or PricingEngineResultAdditionalItem
objects.
Line item dependencies
In most cases, a line item is a stand alone item and fully describes the order position by itself. In some cases, though, a position is complex enough to need additional items to be expressed. Those items are not independent items but are depending on a "root item".
For example, consider a sales order at a burger restaurant:
Id | Dependency | Qty | Product | BasePrice | Price |
---|---|---|---|---|---|
1 | 1x | Softdrink | 3€/1x | 3€ | |
2 | 1x | Burger | 8€/1x | 8€ | |
3 | 2 / OPTION | 1x | Bacon | 1,50€/1x | 1,50€ |
4 | 2 / OPTION | 1x | Extra Cheese | 1€/1x | 1€ |
5 | 2 / OPTION | 1x | Well done | 0€/1x | 0€ |
Here, the Burger is a configurable BTO (built to order) product with a "base price" of € 8,00 and the specific sale includes the options Bacon
, Extra Cheese
, and Well done
.
Line item dependency types
The enfore platform supports different types of line item dependencies.
OPTION
The most common line item dependency type is OPTION
. An option represents a dynamic choice made by the user at runtime when adding a product an order.
Items of type OPTION
are included when computing the line item total and are shown in the client UI and printed on business documents as sub-items for their main item.
DEPOSIT
For modelling deposits, the enfore platform uses the line item dependency type DEPOSIT
. Deposits are configured on the product via the client UI and cannot be modified by the user at runtime when adding a product an order.
Items of type DEPOSIT
are included when computing the line item total and are shown in the client UI and printed on business documents as sub-items for their main item.
CONTENT_COMPOSITION
For describing the contents of a sold item, the line item dependency type CONTENT_COMPOSITION
can be used.
This dependency type is currently only usable by the external pricing logic, there is no way to create such items via the product configuration or client UI.
Items of type CONTENT_COMPOSITION
are ignored when computing the line item total and are not shown in the client UI nor printed on the generic enfore documents.
Custom document templates may choose to display those items in addition (or even in place) of the main item. When the items are to be displayed in place of the main item, care must be taken to ensure that the combined prices of the CONTENT_COMPOSITION
items match the price of the main item so that the overall price displayed stays the same. See the depdency typen PRICING_COMPOSITION
for more information.
PRICING_COMPOSITION
For describing how the price of a line item was computed, the line item dependency type PRICING_COMPOSITION
can be used.
This dependency type is currently only usable by the external pricing logic, there is no way to create such items via the product configuration or client UI.
Items of type PRICING_COMPOSITION
are ignored when computing the line item total and are not shown in the client UI nor printed on the generic enfore documents.
Custom document templates may choose to display those items in place or in addition of the main item. As those items are used to visualize the price computation, care must be taken to ensure that the combined prices of the PRICING_COMPOSITION
items match the price of the main item so that the overall price displayed stays the same.
Specifically, discounts applied to the main item must be present at the PRICING_COMPOSITION
items as well.
For example, assume a main item for the product Box of flowers
whose price is computed from the products Rose
(2x per Box) and Tulip
(5x per Box):
Id | Dependency | Qty | Product | BasePrice | Price |
---|---|---|---|---|---|
1 | 1x | Box of flowers | 9€/1x | 9€ | |
2 | 1 / PRICING_COMPOSITION | 2x | Rose | 2€/1x | 4€ |
3 | 1 / PRICING_COMPOSITION | 5x | Tulip | 1€/1x | 5€ |
Increasing the quantity on the main item must also update the quantities on the PRICING_COMPOSITION
items:
Id | Dependency | Qty | Product | BasePrice | Price |
---|---|---|---|---|---|
1 | 5x | Box of flowers | 9€/1x | 45€ | |
2 | 1 / PRICING_COMPOSITION | 10x | Rose | 2€/1x | 20€ |
3 | 1 / PRICING_COMPOSITION | 25x | Tulip | 1€/1x | 25€ |
Discounts present on the PRICING_COMPOSITION
items must be present on the main item as well:
Id | Dependency | Qty | Product | BasePrice | Discount | Price |
---|---|---|---|---|---|---|
1 | 5x | Box of flowers | 9€/1x | 10% New Customer | 40,50€ | |
2 | 1 / PRICING_COMPOSITION | 10x | Rose | 2€/1x | 10% New Customer | 18,00€ |
3 | 1 / PRICING_COMPOSITION | 25x | Tulip | 1€/1x | 10% New Customer | 22,50€ |
Note that different discounts can be present for each PRICING_COMPOSITION
item. The important thing is that all discounts from the sub items must be present on the main item as well:
Id | Dependency | Qty | Product | BasePrice | Discount | Price |
---|---|---|---|---|---|---|
1 | 5x | Box of flowers | 9€/1x | 5€ Rose Day 2€ Tulip Special | 38€ | |
2 | 1 / PRICING_COMPOSITION | 10x | Rose | 2€/1x | 5€ Rose Day | 15€ |
3 | 1 / PRICING_COMPOSITION | 25x | Tulip | 1€/1x | 2€ Tulip Special | 23€ |