Discount Calculation
SAP Commerce Cloud stores all possible discounts for products and customers as DiscountRow objects. EveryDiscountRow represents a certain discount constellation, which is optionally related to a certain date range, customer, product, group of customers, or group of products.
Every DiscountRow object is a potential discount. Unlike prices, which can only be applied one at a time, taxes and discounts accumulate. If more than one tax or discount is eligible for a certain order entry or an entire order, every single one of those taxes and discounts are taken into effect. In the case of discounts, let's assume the customer cust is assigned an individual discount rate of 20% and the product prod is also assigned an individual discount rate of 20%. If cust orders prod, the order entry for prod contains two discount entries for 20% - one from cust and one from prod. If cust orders the product otherprod (which has no individual discount rate), the order entry for otherprod contains one discount entry for 20% - the one from cust.
If you want to reduce or remove a discount assigned to a product or a customer, you have to assign another discount with a negative value to that product or customer. For example, a discount of -15% increases the price by 15%.
When a discount is required, the Europe1 PriceFactory retrieves all DiscountRow objects related to the combination of customer and products. The following diagram shows the basic course of action.
To handle a request for a discount for a product ( 1 and 1.1 ), the Europe1 PriceFactory retrieves all DiscountRow objects that match the combination of user and product ( 1.1.1 ).
Attributes of a DiscountRow
The following is an overview of the DiscountRow object attributes.
|
Attribute Name |
Attribute Type |
Mandatory |
Description |
|---|---|---|---|
|
absolute |
java.lang.Boolean |
no |
Jalo-only attribute |
|
currency |
Currency |
no |
|
|
dateRange |
de.hybris.platform.util.StandardDateRange |
no |
Jalo-only attribute |
|
discount |
Discount |
yes |
|
|
discountString |
java.lang.String |
no |
Jalo-only attribute |
|
endTime |
java.util.Date |
no |
|
|
pg |
ProductDiscountGroup |
no |
|
|
product |
Product |
no |
|
|
productMatchQualifier |
java.lang.Long |
no |
|
|
startTime |
java.util.Date |
no |
|
|
user |
User |
no |
|
|
userMatchQualifier |
java.lang.Long |
no |
|
|
ug |
UserDiscountGroup |
no |
|
|
value |
java.lang.Double |
no |
If neither a customer nor a UserDiscountGroup is given for a certain DiscountRow, the specified discount applies to all customers in SAP Commerce Cloud. If neither a product nor a ProductDiscountGroup is given for a certain DiscountRow, the specified discount applies to all products in SAP Commerce Cloud.
The following is an overview of the GlobalDiscountRow object attributes.
|
Attribute Name |
Attribute Type |
Mandatory |
Description |
|---|---|---|---|
|
absolute |
java.lang.Boolean |
no |
Jalo-only attribute |
|
currency |
Currency |
no |
|
|
discount |
Discount |
yes |
|
|
discountString |
java.lang.String |
no |
Jalo-only attribute |
|
dateRange |
de.hybris.platform.util.StandardDateRange |
no |
Jalo-only attribute |
|
endTime |
java.util.Date |
no |
|
|
pg |
ProductDiscountGroup |
no |
|
|
product |
Product |
no |
|
|
productMatchQualifier |
java.lang.Long |
no |
|
|
startTime |
java.util.Date |
no |
|
|
ug |
UserDiscountGroup |
no |
|
|
user |
User |
no |
|
|
userMatchQualifier |
java.lang.Long |
no |
|
|
value |
java.lang.Double |
no |
If neither a customer nor a UserDiscountGroup is given for a certain GlobalDiscountRow, the specified discount applies to all customers in SAP Commerce Cloud. If neither a product nor a ProductDiscountGroup is given for a certain GlobalDiscountRow, the specified discount applies to all products in SAP Commerce Cloud.
Filtering DiscountRows
During the filtering phase, the Europe1 PriceFactory selects all DiscountRows matching the combination of customer and product. A DiscountRow 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
If a DiscountRow fails to match all the criteria, it is not applied and therefore not considered by the Europe1 PriceFactory. The following sections provide details on these criteria.
Customer Matching
If there is a DiscountRow that has no Customer or UserDiscountGroup assigned to it, that DiscountRow is applied to all the customers and is therefore effective by default.
To match a customer, a DiscountRow must be one of the following:
- Empty
- Set to match the customer
- Set to match the customer's user group
To match the customer, the DiscountRow's user attribute must be set to contain the customer.
To match the customer's user group, the DiscountRow's ug (user discount group) must be set to contain a user group (an instance of UserDiscountGroup) which contains the customer.
The following table lists some possible combinations and whether the respective DiscountRow is applied to the customer or not.
|
DiscountRow assigned to |
Current Customer |
DiscountRow 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 DiscountRow is assigned to, the DiscountRow is not applied.
- If the DiscountRow is assigned to a UserDiscountGroup and the current Customer is not a member of this UserDiscountGroup, the DiscountRow is not applied.
Product Matching
If there is a DiscountRow that has no Product or ProductDiscountGroup assigned to it, that DiscountRow is applied to all products and is therefore effective by default.
To match a product, a DiscountRow must be one of the following:
- Empty
- Set to match the product
- Set to match the product's Discount group
To match the product, the DiscountRow's product attribute must be set to contain the product.
To match the product's discount group, the DiscountRow's pg (product discount group) must be set to contain a discount group (an instance of ProductDiscountGroup) which contains the product.
The following table displays some possible combinations and whether the respective DiscountRow is applied to the product.
|
DiscountRow Assigned To |
Current Product |
DiscountRow 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 DiscountRow is assigned to, the DiscountRow is not applied.
- If the DiscountRow is assigned to a ProductDiscountGroup and the current Product is not a member of this ProductDiscountGroup, the DiscountRow is not applied.