Skip to content

Instantly share code, notes, and snippets.

@paustint
Last active March 3, 2021 03:09
Show Gist options
  • Save paustint/920f7735267e635e355dae9e92e6e61e to your computer and use it in GitHub Desktop.
Save paustint/920f7735267e635e355dae9e92e6e61e to your computer and use it in GitHub Desktop.
Salesforce CPQ - Stock QCP
const DEBUG = true;
function log(...args) {
if (DEBUG) {
console.log(...args);
}
}
/**
* This method is called by the calculator when the plugin is initialized.
* @param {QuoteLineModel[]} quoteLineModels An array containing JS representations of all lines in a quote
* @returns {Promise}
*/
export function onInit(quoteLineModels) {
return new Promise((resolve, reject) => {
log("onInit()", quoteLineModels);
resolve();
});
}
/**
* This method is called by the calculator before calculation begins, but after formula fields have been evaluated.
* @param {QuoteModel} quoteModel JS representation of the quote being evaluated
* @param {QuoteLineModel[]} quoteLineModels An array containing JS representations of all lines in the quote
* @returns {Promise}
*/
export function onBeforeCalculate(quoteModel, quoteLineModels, conn) {
return new Promise((resolve, reject) => {
log("onBeforeCalculate()", quoteModel, quoteLineModels);
resolve();
});
}
/**
* This method is called by the calculator before price rules are evaluated.
* @param {QuoteModel} quoteModel JS representation of the quote being evaluated
* @param {QuoteLineModel[]} quoteLineModels An array containing JS representations of all lines in the quote
* @returns {Promise}
*/
export function onBeforePriceRules(quoteModel, quoteLineModels, conn) {
return new Promise((resolve, reject) => {
log("onBeforePriceRules()", quoteModel, quoteLineModels);
resolve();
});
}
/**
* This method is called by the calculator after price rules are evaluated.
* @param {QuoteModel} quoteModel JS representation of the quote being evaluated
* @param {QuoteLineModel[]} quoteLineModels An array containing JS representations of all lines in the quote
* @returns {Promise}
*/
export function onAfterPriceRules(quoteModel, quoteLineModels, conn) {
return new Promise((resolve, reject) => {
log("onAfterPriceRules()", quoteModel, quoteLineModels);
resolve();
});
}
/**
* This method is called by the calculator after calculation has completed, but before formula fields are
* re-evaluated.
* @param {QuoteModel} quoteModel JS representation of the quote being evaluated
* @param {QuoteLineModel[]} quoteLineModels An array containing JS representations of all lines in the quote
* @returns {Promise}
*/
export function onAfterCalculate(quoteModel, quoteLineModels, conn) {
return new Promise((resolve, reject) => {
log("onAfterCalculate()", quoteModel, quoteLineModels);
resolve();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment