Establishing Pricing Rules
An organization can configure a product's prices by creating a pricing matrix that determines a particular order's price based on customer type, date ranges, and other criteria, including those defined using a Filter Rule. However, an organization can choose to consolidate multiple Prices records from a matrix into a single Price Rule or use a Price Rule to define more complex pricing behavior.
Pricing rules can be set up either at the product level by linking a Pricing Rules record to the product on the Prices > Advanced tab, or at the level of each individual price record by linking a Pricing Rules record to the individual Prices record.
Note that Pricing Rules are written in VBScript. Therefore, typically a developer or an administrator will write these rules and add them to a Products record as necessary. See Example Pricing Rule Scripts.
Pricing Hierarchy
A product that uses a pricing object will use only the logic defined in the pricing object. It will override any price rules or records defined at the product or product price level.
If a pricing rule is linked to the product through the Pricing Rule field on the Prices > Advanced tab of the Products record, this overrides any price matrix configured for that product based on Prices records. It also overrides any price rule established at the Price record level.
If a pricing rule is linked to a price through the Pricing Rule field on the Prices record, the rule logic is evaluated after the correct price record is selected based on the criteria available at the price record level. (These items can be the member type, date ranges, currency types, etc. as defined on the Prices record.) The price rule criteria is in addition to the Price record criteria.
Follow these steps to add a price rule to Aptify:
- Open a new record from the Pricing Rules service.
- The Pricing Rules service is located in the Product Setup and Maintenance application.
- The Pricing Rules service is located in the Product Setup and Maintenance application.
- Enter a Name and Description for the pricing rule on the General tab.
- Select the Price Rule tab.
- Enter the VB script to define the pricing rule.
- This information must be entered before the Pricing Rules record can be saved.
- See Example Pricing Rule Scripts for information on writing pricing rule scripts.
- Since a Price Rules record uses Aptify's Scripting feature, use the Scripting icons to assist you with writing the script. See Administering Scripts for more information.
- Save and close the Pricing Rules record.
- Open the Products record for the product to which this rule applies.
- Do one of the following:
- If the rule defines all possible prices for the product, click the Prices > Advanced tab and specify the Price Rules record in the Price Rule field.
- If the rule applies to a single Prices record within the context of a larger pricing matrix, follow these steps:
- Click the Prices > General tab.
- Open the Prices record to which you want to assign the rule (or create a new one, if necessary).
- Enter the Price Rules record in the Pricing Rule field.
- Click OK to save and close the Prices record.
- If the rule defines all possible prices for the product, click the Prices > Advanced tab and specify the Price Rules record in the Price Rule field.
- Save and close the Products record.
Example Pricing Rule Scripts
By default, an administrator or developer can create a pricing rule that determines a product's price based on criteria from the following records in Aptify related to the current order:
- Persons: The current order's Bill To person.
- Orders: The current order.
- OrderLines: The current order line to which the product has been added.
- Products: The product whose unit price is being calculated.
The price rule must use the proper format and use the correct aliases, which are identified in the Available Objects and All References pop-up dialogs. These dialogs can be opened by clicking one of the scripting buttons in the Price Rule toolbar.
When writing a pricing rule, keep in mind the following important points:
- A price rule can also use data from entities other than the four listed above (such as Companies) if the script loads the Generic Entity (GE) object for that entity. For example, in Example 3 , the script loads a Company GE object and bases the price on the Ship To company's revenue.
- When writing a pricing rule for a product that is or will be displayed on an e-Business site, keep in mind that prices derived from a pricing rule based on Order characteristics will appear as zero on an e-Business product page (since the order does not exist yet when a Web User views a product page). In this case, you should design the pricing rule in such a way that if the Web User is logged in, the ID of that Person is available to use as the basis for calculating the price (for example, when available, use the Web User's PersonID if the Order object is not available or if an Order's BillToID has not been specified).
- If you are writing a pricing rule for a product whose price includes tax, the pricing rule must explicitly call the Price.IncludesTax=True attribute. This is true even if the Pricing Rule is linked to a Prices record that has the Includes Tax option selected. For example, below is a simple pricing rule that will set the product price to $20 and include any applicable tax in that price:
Price.Price = 20.00D
Price.IncludesTax=True
Result.Outcome = Aptify.Applications.OrderEntry.IProductPrice.PriceOutcome.Exist
Result.Success = True
- To successfully use the sample Pricing Rules in this section, you should add the following objects to the Pricing Rule Script Type's Repository References tab, if not already present:
- Startup.Aptify Application Object
- CRM.AptifyOBDEntity
- CRM.AptifyOrderLineControl
Example 1
The following script, specifies a Member Price of $20 and a Non-Member Price of $50 when this product is added to an order. This type of rule could apply at the top-level Prices record and if a Person did not qualify for either price, the system would fall back to the Prices records in the pricing matrix:
If gePerson isNot Nothing Then If gePerson.GetValue("MemberType") isNot Nothing Then If gePerson.GetValue("MemberType").ToString.ToLower = "member" Then Price.Price = 20.00D Result.Outcome = Aptify.Applications.OrderEntry.IProductPrice.PriceOutcome.Exist Result.Success = True Else If gePerson.GetValue("MemberType").ToString.ToLower = "non-member" Then Price.Price = 50.00D Result.Outcome = Aptify.Applications.OrderEntry.IProductPrice.PriceOutcome.Exist Result.Success = True Else Result.Outcome = Aptify.Applications.OrderEntry.IProductPrice.PriceOutcome.NotExist Result.Success = True End If
Example 2
In the second example below, this rule charges $10 to members located in California and $12 to members not in California. This rule could be entered on a Member-based Prices record, as shown in the example below.
If gePerson isNot Nothing Then If gePerson.GetValue("State") isNot Nothing Then If gePerson.GetValue("State").ToString.ToLower = "ca" Then Price.Price = 10.00D Result.Outcome = Aptify.Applications.OrderEntry.IProductPrice.PriceOutcome.Exist Result.Success = True Else If gePerson.GetValue("State").ToString.ToLower <> "ca" Then Price.Price = 12.00D Result.Outcome = Aptify.Applications.OrderEntry.IProductPrice.PriceOutcome.Exist Result.Success = True Else Result.Outcome = Aptify.Applications.OrderEntry.IProductPrice.PriceOutcome.NotExist Result.Success = True End If Else Result.Outcome = Aptify.Applications.OrderEntry.IProductPrice.PriceOutcome.NotExist Result.Success = True End If Else Result.Outcome = Aptify.Applications.OrderEntry.IProductPrice.PriceOutcome.Failure Result.Success = False Result.Message = "Person information was not available." End If
Example 3
The script in this example calculates a company's membership dues if its revenue is greater than $100 million. Note that this script is designed to operate within the context of a larger pricing matrix (which also specifies dues pricing for companies with revenue less than $100 million). Since this script is not based on one of the default objects (that is, Persons, Orders, OrderLines, and Products), it loads a Company GE object based on the order's Ship To Company.
Dim oApplication As New Aptify.Framework.Application.AptifyApplication(OrderGE.UserCredentials) Dim geCompany As Aptify.Framework.BusinessLogic.GenericEntity.AptifyGenericEntityBase If IsNumeric(OrderGE.GetValue("ShipToCompanyID")) AndAlso CLng(OrderGE.GetValue("ShipToCompanyID")) > 0 Then geCompany = oApplication.GetEntityObject("Companies", CLng(OrderGE.GetValue("ShipToCompanyID"))) Dim cRevenue As Decimal = CDec(geCompany.GetValue("Revenue")) If cRevenue < 100000000 Then Result.Message = "The Company's Revenue is less than $100,000,000. This Pricing Rule is only valid for Company's with $100,000,000 or more in Revenue." Result.Success = False Else 'Dues Formula Is $50,000 + 1/10 of one percent of the Company's Revenue. Price.Name = "Over $100 mil." Price.Price = 50000D + (cRevenue * 0.001D) Price.IncludesTax = False Result.Outcome = Aptify.Applications.OrderEntry.IProductPrice.PriceOutcome.Exist Result.Success = True End If Else Result.Message = "The Ship To Company has not been specified on the Order. Ship To Company is required for Dues Orders." Result.Success = False End If
Copyright © 2014-2017 Aptify - Confidential and Proprietary