Searching Relevant Price Records

Once the Price Records are generated (from Agreements & Promotions line items), you can use (search) them in Quotes, Price Lists, etc. to employ the conditions which they represent.

Example

You are creating a Quote, and would like to calculate the Promotion Discount for the given Customer and Product. That discount is based on the previously made Promotion Contract. You already know that the Promotion Contract is converted into Price Records. So what you really need to do in the Quote calculation logic is to find the relevant Price Records for the given Customer and Product.

But bear in mind that:

  • Price Records are NOT defined for a specific product and customer but rather for a group of products and a group of customers.
  • Potentially more Price Records can be valid at the same time for the same product and customer – so you need to figure out which conditions to use. (Here, for example, the Priority field can be used. But that is not a universal solution.)
  • Price Records are not valid indefinitely, but only for a limited time period.

How to Search for Relevant Price Records

The trickiest part is the filter for products and customers – that's what we show in the example below. You need to provide here the other filters (for Date and Priority, etc.) as well.

def productFilter = api.productToRelatedObjectsFilter("PR", api.product("sku"))
def customerFilter = api.customerToRelatedObjectsFilter("PR", api.customer("customerId"))
def priceRecordRows = api.find("PR", productFilter, customerFilter)