Searching for Relevant Price Records

Once the Price Records have been generated from Agreements and Promotions line items, you can search for these records in Quotes, Price Lists, and other areas to utilize the conditions they represent.

Example

When creating a Quote, you may wish to calculate the Promotion Discount for a specific Customer and Product based on an existing Promotion Contract. Since you know that the Promotion Contract has been converted into Price Records, your task in the Quote calculation logic is to identify the relevant Price Records for the specified Customer and Product.

However, keep in mind the following considerations:

  • Price Records are not defined for individual products and customers; rather, they apply to groups of products and customers.

  • It is possible for multiple Price Records to be valid simultaneously for the same product and customer. Thus, it is important to determine which conditions to apply (the Priority field can be useful in this context, although it is not a universal solution).

  • Price Records have a limited validity period and are not effective indefinitely.

How to Search for Relevant Price Records

The most challenging aspect is filtering for products and customers, as demonstrated in the example below. It is also essential to include additional filters for Date, Priority, and other relevant criteria.

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

The methods api.product() and api.customer() have been deprecated in version 14.0; however, it will remain available to ensure backward compatibility. We strongly recommend starting to adopt the queryApi() with the QapiProduct and QapiCustomer for new implementations. Note that while the deprecated method does not entail the removal of functionality, it will no longer be maintained. For more information see the example queryApi() implementation. For more information see the following example queryApi() implementations.