Example Advanced Price Model & Scripting Matrix Template

Overview

In this example, an Advanced Price Model and a Scripting Price Model type Pricing Matrix Templates are used to set discount corridors (or discount guideline) for Supremo product lines by setting the minimum and maximum discount amounts as shown below.

Discount Guidelines Example

Prerequisite: You have adopted multi-charges and enabled Charge Definitions.

Note: multiple charges and charge definitions are required for this example but are not required to use a new Advanced Price Model.

The process to implement enhanced scripting for charges and other extensible output values using Advanced type Price Models and Scripting Price Model type Pricing Matrix Templates involves the following steps:

Define Commerce Attributes

  1. Navigate to Admin > Process Definition > Documents > Transaction Line > Attributes

  2. Add Commerce Transaction Line attributes.

    • Maximum Discount

    • Minimum Discount

Define Pricing Lookups

  1. Navigate to Admin > Pricing Portal > Pricing Lookups.

  2. Add Pricing Lookups to define valid values for any menu type attributes you will use in your dynamic pricing.

    Document

    Attribute

    Attribute Type

    Comment

    Transaction

    Sales Channel

    Menu

    Menu Options: direct, distributor

    Transaction Line

    Part Attributes > Part Sales Product Type

    String

    Expose the Part Attributes > Part Sales Product Type in the "Part Attributes" Attribute Set. Refer to Manage Part Attributes.

Define Pricing Attributes

  1. Navigate to Admin > Pricing Portal > Pricing Attributes.

  2. Add Pricing Attributes for the input and output pricing values.

    Pricing Entity

    Name

    In/Out

    Visibility

    Mapped To

    Line

    Line Maximum Discount

    Input

     

    Data Source: <Commerce Process Name>

    Source Attribute: Maximum Discount

    Source Entity: Transaction Line

    Line

    Line Minimum Discount

    Input

     

    Data Source: <Commerce Process Name>

    Source Attribute: Minimum Discount

    Source Entity: Transaction Line

    Charge

    Maximum Discount

    Output

    Administration, Runtime

     

    Charge

    Minimum Discount

    Output

    Administration, Runtime

     

  3. Navigate to Admin > Process Definition > Documents > Transaction Line > Attributes.

  4. Click Synchronize Charge Definition.

  5. Deploy the Commerce process.

Create a Scripting Price Model - Pricing Matrix Template

Complete the following steps to create a Scripting Price Model type Pricing Matrix Template in the CPQ Pricing Portal.

  1. Navigate to Admin > Pricing Portal > Pricing Matrix Templates.

  2. Select Add from the Actions drop-down.

    1. Enter the Name.

    2. Enter the Variable Name.

    3. Select Scripting Price Model from the Template Type drop-down.

    4. (optional) Enter a Description.

    5. Click Create.

  3. Select Add from the Actions drop-down.

  4. Enter the following data to create a template column.

    1. Enter the Name.

    2. Enter the Variable Name.

    3. Select the Data Type.

    4. If applicable, select a Lookup. (Lookups are only available for String Data Types)

    5. If applicable, enter of select a Default Value.

    6. Check Default Value Overridable if the default value can be modified.

    7. Check Required to make this field mandatory.

    8. Check Key to identify this field as a unique identifier.

    9. Repeat this step to enter additional columns.

      Example Scripting Price Model - Pricing Matrix Template

  5. Enter BML Script for the Scripting Price Model - Pricing Matrix Template.

    1. Click Edit (In the Basic Details section).

    2. Expand More Details, and click the Advanced Script Edit link.

    3. Select the applicable attributes from the Pricing Document Attributes tab.

      • _currencyCode

      • salesChannel_c

      • lineMaximumDiscount_c

      • lineMinimumDiscount_c

      • salesProductType_c

      • calculationInfo

      • chargeDefinitionCode

      • chargeType

      • dynamicPricingType

      • maximumDiscount_c

      • minimumDiscount_c

      • pricePeriod

      • priceType

      • priceType

    4. Select _currentMatrix from the Special Parameters tab.

    5. Click Next.

    6. Enter the BML Script. See BML Script Example

    7. Click Save and Close.

  6. Click Update.

salesChannel = jsonget(pricingDocument, "salesChannel_c", "string", "direct");

// Loop through lines
lines = jsonget(pricingDocument, "lines", "jsonarray");
indexes = range(jsonarraysize(lines));
for index in indexes {

  line = jsonarrayget(lines, index, "json");
  salesProductType = jsonget(line, "salesProductType_c", "string", "GOODS");

// Query the Pricing Data of this price model to get the discount corridor.
// Warning: this code snippet keeps things simple to highlight the syntax to set charges.
// In practice, avoid bmlq within loops whenever possible for better performance.
minDiscount = 0.;
maxDiscount = 0
resultSet = bmql("select minDiscount, maxDiscount from $_currentMatrix where salesChannel = $salesChannel and salesProductType = $salesProductType");
  for result in resultSet {
    minDiscount = getfloat(result, "minDiscount");
    maxDiscount = getfloat(result, "maxDiscount");
  }
  
  // Apply the discount corridor on all charges
  charges = jsonget(line, "charges", "jsonarray");
  if (isnull(charges)) {
    continue;
  }
  chargeIndexes = range(jsonarraysize(charges));
  for chargeIndex in chargeIndexes {
    charge = jsonarrayget(charges, index, "json");
    isProductPrice = jsonget(charge, "isProductPrice", "boolean");
    if (isProductPrice) {
      jsonput(line, "lineMinimumDiscount_c", minDiscount);
      jsonput(line, "lineMaximumDiscount_c", maxDiscount);
    } else {
      jsonput(charge, "minimumDiscount_c", minDiscount);
      jsonput(charge, "maximumDiscount_c", maxDiscount);
    }
  }
}
return pricingDocument;

Create an Advanced Price Model

Complete the following steps to create an Advanced Price Model in the CPQ Pricing Portal.

  1. Navigate to Admin > Pricing Portal > Price Models.

  2. Select Add from the Actions drop-down.

    1. Enter the Name.

    2. Enter the Variable Name.

    3. Select Advanced from the List Type drop-down.

    4. Select the applicable Scripting Price Model - Pricing Matrix Template from the Template drop-down.

    5. (optional) Select a Start date. This effective start date value will apply to all child Price Model Items.

    6. (optional) Select an End date. This effective end date value will apply to all child Price Model Items.

    7. (optional) Enter a Description.

    8. Click Create.

  3. Select Edit from the Actions drop-down.

  4. Click Add, and then define the values for the row. See Advanced Price Model Example

    1. Select values from available drop-downs and define the appropriate data values for the row.

    2. Repeat this step to enter additional rows.

  5. Click Update.

Example Advanced Price Model

Link Advanced Price Model to Pricing Rule

Complete the following steps to create an Advanced Price Model in the CPQ Pricing Portal.

  1. Navigate to Admin > Pricing Portal > Pricing Rules.

  2. Click on the applicable Pricing Rule. (e.g. Base Pricing Rule)

  3. Select Add from the Linked Price Models Actions drop-down.

  4. Select the applicable Price Model (e.g. Supremo North America Discount Corridors.

  5. Click Add.

 

Related Topics

Related Topics Link IconSee Also