Price Calculation
SAP Commerce stores all possible prices for products and customers as price row objects. Every price row represents a certain price constellation, which is optionally related to a certain date range, customer, product, group of customers, or group of products.
Every PriceRow object is a potential price. When a price is required for display, the Europe1 PriceFactory retrieves all PriceRow objects related to the combination of customer and products. This is because unless an order is placed, the number of products is not determined and therefore scale prices might apply. When a price is required for an order, the Europe1 PriceFactory retrieves all PriceRow objects related to the combination of customer and products and then chooses the best matching PriceRow.
The following diagram shows the basic course of action for the ordering case.
To handle a request for a price for a product, the Europe1 PriceFactory retrieves all PriceRow objects that match the combination of user and product. The remaining subset of PriceRows is converted so that the PriceRows are comparable. The converted PriceRows are sorted by the relevance to the combination of customer and product. Finally, the best matching combination is returned as the final price.
Attributes of a PriceRow
The following table provides an overview of the attributes of a PriceRow object.
|
Attribute Name |
Attribute Type |
Mandatory |
Description |
|---|---|---|---|
|
channel |
PriceRowChannel |
no |
Channel for which the price is effective (for example, mobile or desktop). |
|
currency |
Currency |
yes |
Currency of the price. No default value. |
|
dateRange |
StandardDateRange |
no |
Date range for the PriceRow object's validity. |
|
giveAwayPrice |
java.lang.Boolean |
yes |
Specifies whether a price row has a give-away price. The default value is false. |
|
endTime |
java.util.Date |
no |
Specifies the end date of a price's validity. |
|
matchValue |
java.lang.Integer |
no |
Internally calculated value that is based on user and product information. The value is used for sorting PriceRow records by their relevance. |
|
minqtd |
java.lang.Long |
yes |
Scale price definition. A customer needs to order at least this number of units for this price to be effective. Default value is 1. |
|
net |
java.lang.Boolean |
no |
Specifies whether the price specified is net or gross. Default value is gross. |
|
pg |
ProductPriceGroup |
no |
Product Pricelist for which the price is effective. The price is applied to all members of this Product Pricelist. |
|
price |
java.lang.Double |
yes |
Price to be set. |
|
product |
Product |
no |
Product for which the price is set. |
|
productMatchQualifier |
java.lang.Long |
no |
Internally calculated value based on product information. The value is used to filter out the PriceRow records that are considered when a price is being retrieved. |
|
startTime |
java.util.Date |
no |
Specifies the start date of a price's validity. |
|
ug |
UserPriceGroup |
no |
Customer Pricelist for which the price is effective. The price is applied to all members of this Customer Pricelist. |
|
unit |
Unit |
yes |
The unit this price is measured in. No default value. |
|
unitFactor |
java.lang.Integer |
yes |
The number of individual units the price refers to. If you set the price to 50 EUR and the unitFactor to 5, the individual unit's price is 10 EUR (50 EUR / 5). Default value is 1. |
|
user |
User |
no |
Customer for which the price is set. |
|
userMatchQualifier |
java.lang.Long |
no |
Internally calculated value that is based on user information. The value is used to filter out the PriceRow records that are considered when a price is being retrieved. |
If neither the customer nor a UserPriceGroup is given for a certain PriceRow, the specified price applies to all customers in SAP Commerce. If neither the product nor ProductPriceGroup is given for a certain PriceRow, the specified price applies to all products in SAP Commerce.
Filtering PriceRows
During the filtering phase, the Europe1 PriceFactory selects all PriceRows matching the combination of customer and product. A PriceRow must match all of the following criteria to apply:
-
customer or customer group or no customer-related value (blank field)
-
product or product group or no product-related value (blank field)
-
date range
-
scale price
If a PriceRow fails to match all the criteria, it is not applied and therefore not considered by the Europe1 PriceFactory.
Customer Matching
To match a customer, a PriceRow must be one of the following:
-
empty
-
set to match the customer, or the customer's user group.
To match the customer, the PriceRow's user attribute must be set to contain the customer.
To match the customer's user group, the PriceRow's ug (user price group) must be set to contain a user group (an instance of UserPriceGroup) which contains the customer.
If there is a PriceRow that has no Customer or UserPriceGroup assigned to it, that PriceRow is applied to all customers and therefore be effective by default.
The following table lists some possible combinations and whether the respective PriceRow is applied to the customer.
|
PriceRow Assigned To |
Current Customer |
PriceRow Applies to the Current Customer? |
|---|---|---|
|
kotal |
kotal |
|
|
kotal |
abel |
|
|
customergroup |
kotal (member of customergroup) |
|
|
customergroup |
abel (not a member of customergroup) |
|
|
(no assignment) |
kotal |
|
|
(no assignment) |
abel |
|
|
(no assignment) |
kotal (member of customergroup) |
|
|
(no assignment) |
abel (not a member of customergroup) |
|
In other words:
-
If the current Customer is different from the Customer the PriceRow is assigned to, the PriceRow is not applied.
-
If the PriceRow is assigned to a UserPriceGroup and the current Customer is not a member of this UserPriceGroup, the PriceRow is not applied either.
Product Matching
To match a product, a PriceRow must be one of the following:
-
empty
-
set to match the product or the product's price group.
To match the product, the PriceRow's product attribute must be set to contain the product.
To match the product's price group, the PriceRow's pg (product price group) must be set to contain a price group (an instance of ProductPriceGroup) which contains the product.
If there is a PriceRow that has no Product or ProductPriceGroup assigned to it, that PriceRow is applied to all products and therefore be effective by default.
The following table shows you some possible combinations and whether the respective PriceRow is applied to the product.
|
PriceRow Assigned To |
Current Product |
PriceRow Applies to the Current Product? |
|---|---|---|
|
B00005LJ7N-1 |
B00005LJ7N-1 |
|
|
B00005LJ7N-1 |
C232134_0 |
|
|
cameragroup |
B00005LJ7N-1 (member of cameragroup) |
|
|
cameragroup |
C232134_0 (not a member of cameragroup) |
|
|
(no assignment) |
B00005LJ7N-1 |
|
|
(no assignment) |
C232134_0 |
|
|
(no assignment) |
B00005LJ7N-1 (member of cameragroup) |
|
|
(no assignment) |
C232134_0 (not a member of cameragroup) |
|
In other words:
-
If the current Product is different from the Product the PriceRow is assigned to, the PriceRow is not applied.
-
If the PriceRow is assigned to a ProductPriceGroup and the current Product is not a member of this ProductPriceGroup, the PriceRow is not applied either.
Scale Prices
A PriceRow object can define a scale price via its minqtd attribute. If the value is greater than 1 (one), the PriceRow defines a scale Price. Usually, higher order volumes result in a lower price per individual unit.
A PriceRow with a scale price is only applied if the customer buys the minimum units required for the scale price to be triggered. When you define scale prices, you need to pay attention to the effects of multiple PriceRow objects or you may run into a situation where it benefits the customer to order smaller amounts of the product (e.g., 1 for 7 EUR instead of 4 for 8 EUR each).
Below is an example of prices set for numerous scale price quantities. The right table displays the price per unit that is applied based on the number of units the customer purchases.
|
Scale Price Quantity |
Price per Unit |
|---|---|
|
1 |
100 € |
|
5 |
95 € |
|
20 |
90 € |
|
50 |
75 € |
|
100 |
50 € |
|
1000 |
30 € |
|
Ordered Quantity |
Effective Price per Unit |
|---|---|
|
5 |
95 € |
|
7 |
95 € |
|
20 |
90 € |
|
49 |
90 € |
|
50 |
75 € |
|
99 |
75 € |
|
100 |
50 € |
|
999 |
50 € |
|
1000 |
30 € |
Converting PriceRows
Net/Gross Prices
For each PriceRow, you can define whether it should be net or gross. The net price is the "pure" price of the product and does not include taxes, whereas the gross price is the effective cost for the customer and includes all relevant taxes. PriceRows in SAP Commerce have an attribute called net that defines whether its value is given in net or in gross format. Use the isNet() and setNet( Boolean net) methods to retrieve and specify a price's net or gross status (true = net, false = gross).
Currency Conversion
A PriceRow is always specified in a certain currency. If a PriceRow is specified in a currency different from the current customer's session, the PriceRow's value is converted automatically based on the conversion rates in SAP Commerce. The following table provides an example of how this works.
|
Price Value in PriceRow |
Session Currency |
Conversion Rate |
Effective Price |
|---|---|---|---|
|
10 USD |
USD |
1:1 |
10 USD |
|
10 USD |
EUR |
1:1 |
10 EUR |
|
10 USD |
GBP |
1.3:1 |
7.70 GBP |
Using unitFactor
The unitFactor attribute specified with a PriceRow object allows you to scale prices with units. Effectively, when calculating a price on a PriceRow, the Europe1 PriceFactory divides the value of the price attribute by the value of the unitFactor. In other words, if you define a PriceRow object with a price of 1000 EUR and a unitFactor of 500, each single unit costs 2 EUR. Two possible applications for this:
-
You can scale small prices up by a manageable factor
-
You can base prices on the lot size you receive the goods in
The following are a couple of examples:
-
In your cheese shop 100 g of cheddar has a price of 2.50 EUR. A single gram of cheddar would then cost 0.025 EUR. In your PriceRow object, you could specify the price for cheddar in EUR per grams (0.025 EUR). Alternatively, you could specify the price in EUR per kilogram and add a unitFactor of 1000, resulting in (25,00 EUR / kg) / 1000 effectively.
-
Your shop sells pre-assembled computers, 16 of which arrive on an europalette each. Every computer has a price of 250 EUR. Instead of setting up a price of 250 EUR per computer in your PriceRow object, you could alternatively set up the price for an entire palette and specify a unitFactor of 16.
In order to configure the number of digits at the base price, use the following property:
advanced.properties
#scale of the BigDecimal value to be returned. Used during a conversion of Number value to the SQL BigDecimal. jdbcmappings.big_decimal_scale=5
Sorting PriceRows and Selecting a Final Price
After the Europe1 PriceFactory has gathered all PriceRows that might apply, those PriceRows are sorted by product and customer matches. As a rule of thumb, the customer ranks higher than the product and matching individual settings rank higher than group settings. The priorities are in the following order:
-
P + C
-
PG + C
-
P + CG
-
PG + CG
-
P + C*
-
PG + C*
-
P* + C
-
P* + CG
-
P* + C*
|
P |
Product matches exactly |
|
C |
Customer matches exactly |
|
PG |
Productgroup matches exactly |
|
CG |
Customergroup matches exactly |
|
P* |
Price matches for all products |
|
C* |
Price matches for all customers |
In other words:
-
Customer-specific PriceRows override product-specific PriceRows of equivalent priority.
-
Customer-specific PriceRows override UserPriceGroup-specific PriceRows, which override global PriceRows.
-
Product-specific PriceRows override ProductPriceGroup-specific PriceRows, which override global PriceRows.
Enabling Legacy Query Strategy
Use the following property with the true value to enable the legacy query strategy for fetching user group and product ID prices parameters in DefaultPDTRowsQueryBuilder:
europe1.use.legacy.productid.query.strategy=
The property is set to false by default.