-
Notifications
You must be signed in to change notification settings - Fork 4
/
QCP_OrderOfOperationsForCalculationSequenceOrDebug_Info.js
62 lines (47 loc) · 2.56 KB
/
QCP_OrderOfOperationsForCalculationSequenceOrDebug_Info.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* READ ME **
CPQ Pricing Order of Operations with in-line Custom Script (QCP).
Function: Displays field and data during various steps of calculation sequence. Helpful for debugging and advanced pricing development.
Numbers designate a pricing step executing.
Note: This must be populated in a Custom Script record. Input the name of the Custom Script record under Installed Packages > CPQ > Plugins > Quote Calculator Plugin
Remove or comment the printModels lines before deployment.
*/
// Salesforce loads related records
//1. Price Rules with Calculator Evaluation Event "On Init" execute
//2. QCP onInit executes
export function onInit(quoteLineModels, conn) {
printModels('onInit', quoteLineModels, conn);
return Promise.resolve();
}
// Salesforce reloads related records, including computing Quote Line Formulas
// 3. Price Rules Calculator Evaluation Event "on before calculate" execute
// 4. QCP onBeforeCalculate executes
export function onBeforeCalculate(quoteModel, quoteLineModels, conn) {
printModels('onBeforeCalculate', quoteModel, quoteLineModels, conn);
return Promise.resolve();
}
// Salesforce reloads related records, and calculates quote line quantities
// 5. QCP onBeforePriceRules executes
export function onBeforePriceRules(quoteModel, quoteLineModels, conn) {
printModels('onBeforePriceRules', quoteModel, quoteLineModels, conn);
return Promise.resolve();
}
// 6. Price Rules with Calculator Evaluation Event "On Calculate" Execute
// 7. QCP onAfterPriceRules executes
export function onAfterPriceRules(quoteModel, quoteLineModels, conn) {
printModels('onAfterPriceRules', quoteModel, quoteLineModels, conn);
return Promise.resolve();
}
// Salesforce reloads related records, including internal pricing logic.
// NOTE: Internal pricing logic includes system discounts (i.e. discount schedules), additional disc (manual user-entered discounts), partner and distributor discounting, and special price and contracted price discounting.
// 8. Price rules with Calculator Evaluation Event "After Calculate" Execute
// 9. QCP OnAfterCalculate executes
export function onAfterCalculate(quoteModel, quoteLineModels, conn) {
printModels('OnAfterCalculate', quoteModel, quoteLineModels, conn);
return Promise.resolve();
}
// Salesforce reloads related records and calculates all formulas
function printModels (calcStep, quoteModel, quoteLineModels, conn){
console.log('=====START ===== ' + calcStep);
console.log('Models: ', quoteModel, quoteLineModels, conn);
console.log('=====END ===== ' + calcStep);
}