Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Contracts

To set up a promotion, the end user must navigate to the contract detail page: Agreements & Promotions  Agreements & Promotions  New Agreement & Promotion:

capture new contract capture contract detail page
Info
In Pricefx, promotions are set up in contracts.
Tip
In Unity, the labels can be changed to display Promotions — instead of Contracts.

Similarly to the quote, a contract consists of:

  • A Header section

  • An [Line] Items section

Contract Header

Information about the contract as a whole is stored in the header. Like the quote, the header has input parameters and output values; both of which are controlled by a header logic.

capture contract detail page

In Pricefx Studio, a header logic can be added by selecting the formula nature Contract Header. In most aspects, the contract header logic works like the quote header logic, but the document is traversed by utilizing the binding variable cProcessor, which references the ContractBuilder.

Code Block
languagegroovy
themeMidnight
titleAccessing the contract, represented as a Map, from within a contract header logic.
linenumbersfalse
cProcessor.getContractView()

To ensure that the header logic is used for new contracts, navigate to Administration  Logics  Header Logics  Agreements & Promotions, and set the Default Agreement & Promotion Header Logic.

capture default contract header logic

Contract Line Items

Unlike the quote, contract line items represent a broader set of contract pricing terms, not necessarily related to only one product.

Contract terms are an abstraction of the terms and conditions of a promotion.

When the end user adds a line item, he/she selects a Contract Term Type, which is an entity that determines how the line items will be calculated.

ContractLineItemSample

A line item has input parameters — which allow the end users to specify thresholds, discounts, product ranges, etc. — and element outputs — which typically contain estimations of the impact of the promotion.

contract data model.drawio

Contract Term Types

The contract term type (Condition Type) references a contract calculation logic. This logic generates input parameters (during syntax checkinput generation) and calculates outputs during recalculation.

The contract term type also has attribute1..30 fields, which can be read by the calculation logic and used to parametrize the behavior of the logic.

contract term type data model.drawio

Contract Calculation

When the end user clicks on Recalculate, or when he/she submits the document for approval, the contract is sent to the backend for calculation. There, for each line item, the associated calculation logic is invoked and the result is saved on the line item. Thus, a big difference between quotes and contracts is that the quote’s quote type applies to the entire document, while the contract’s contract term type applies to the line item.

PromotionCalculationFlow

Typically, the result of a contract calculation logic will be twofold:

  1. Estimations of the impact of the promotion. An example of this can be to use transactional history to extrapolate future sales, and apply the promotion to obtain a simulated value.

  2. Price records (created after approval), which are used to

    1. Export the contract terms to external systems.

    2. Query the contract terms in other Pricefx modules.

contract calculation.drawio

Accessing the Contract Term Type Within the Logic

Sometimes, it can be useful to access the contract term type from within the calculation logic. For example:

  • When there is information stored in attribute fields of the contract term.

  • When a single logic is shared between multiple contract term types; the logic behaves differently depending on the associated contract term type.

In a case like this, read the line item with api.currentItem() and access the contract term type name with

Code Block
languagegroovy
themeMidnight
linenumbersfalse
String contractTermTypeName = api.currentItem().contractTermType

To read the contract term type’s attribute field values, use api.find(), with the type code CTT.

Code Block
languagegroovy
themeMidnight
linenumbersfalse
api.find('CTT', 0, 1, null, Filter.equal('uniqueName', contractTermTypeName))

Price Records

When a promotion has been set up, it needs to be used somewhere else; either in other modules, or in some external systems. Therefore, when a contract is approved, a set of price records is generated.

Each contract line item results in the creation of one price record. The values of the line item inputs — and outputs — are mapped to those price record attribute fields where the name matches. For example:

schema price record field value mapping.drawio

These price records are of the same type as for quotes; meaning that contract price records are stored together with quote price records in the same physical table. The way to distinguish between the two is by looking at the Source ID field; for quotes, it starts with “P-” — and for contracts, it starts with “C-”.

The price records can be viewed on the PromotionManager Price Record page: Agreements & Promotions  Price Records.

contract price records
Info
The Agreements & Promotions Price Record page only displays price records that originate from contracts. (Unity applies a filter on the Source ID field when it queries the Price Record table).

...