Contract Header Logic
Contract Header logic is used when you need to:
Create input fields on:
Contract header
Contract folders
Contract items (not so common)
Hide the out-of-the-box header input fields.
Add or remove contract items and folders – e.g. modify the structure of the document.
Calculate results for:
Whole contract, e.g. summaries like grand total price or overall margin.
Folders (not so common), e.g. sub-summaries for the folders.
Items (not so common), e.g. particular results for line items.
To understand where the header logic belongs in the process, see Process of Contract Recalculation.
Logic API
Logic Nature: contractHeader
Logic Type: Calculation/Pricing
Execution Types:
Standard – It is done twice and the executions are called phases. They have different purposes, so you must distinguish these executions in the code by checking which execution it is at the moment:
pre-phase – First execution. It creates input fields on the header, folders or items, and creates/removes the items/folders.
post-phase – Second execution. It calculates summary info of items and stores them on the header, folder or items.
Information provided to the logic:
Binding variables:
cProcessor: ContractBuilder
CAUTION: When using Pricefx non-React user interface, during pre-phase the
cProcessor.contractView
will NOT contain values of outputs. The only exception are "overridable" outputs. This limitation is to optimize performance when sending data between the user interface and backend.
Context:
commandName - info about which operation caused the execution of this logic, e.g. if it was Recalculate, Submit, etc. See api.currentContext() for details.
Expected logic execution outcome:
pre-phase execution:
Definition of input fields – via the
cProcessor.addOrUpdateInput()
.Content of
api.global
created by the pre-phase header logic will be persisted and available to the Contract Item Logic when calculating the line items.
post-phase execution:
Header calculation results – via the
cProcessor.addOrUpdateOutput()
.Custom Header - via the
cProcessor.addOrUpdateOutput()
Set attributeX field values – via
cProcessor.updateField("attribute1", "value")
.Hide out-of-the-box buttons – via
cProcessor.setRenderInfo()
.Raise critical alert – if the logic creates at least one critical alert, it is considered as an exception, and the process (e.g. submission) will stop.
Note that the results of the logic elements are not stored or displayed anywhere (with the exception of testing the logic in Studio).
In general, the logic is expected to use the provided ContractBuilder object to manipulate the content of the document. For a list of allowed manipulations, see the description of the object CalculableLineItemCollectionBuilder.
Code Sample
Groovy API
There are some commonly used functions for header logics:
Check for which phase the logic is executed:
cProcessor. isPrePhase()
cProcessor. isPostPhase()
Read the data of the contract header and items:
cProcessor. getContractView()
Create input fields on header, folder or item:
cProcessor. addOrUpdateInput()
Create outputs/results on header, folder or item:
cProcessor. addOrUpdateOutput
Found an issue in documentation? Write to us.
Â