I want to calcul the contracted price, how to do it?
In custom script
Custom field
Custom script
export function onBeforePriceRules(_quoteModel, quoteLineModels) {
return new Promise((resolve, reject) => {
try {
updateLineItemPrices(quoteLineModels);
resolve(); // Resolves the promise upon successful completion
} catch (error) {
reject(error); // Rejects the promise if an error occurs
}
});
}
function updateLineItemPrices(quoteLineModels) {
quoteLineModels.forEach(line => {
if (line.record.SBQQ__ContractedPrice__c != null && !line.record.ContractedPriceInsert__c) {
line.record['SBQQ__ListPrice__c'] = line.record.ContractedListPrice__c;
line.record.ContractedPriceInsert__c = true;
}
if (line.record.SBQQ__ContractedPrice__c != null && line.record.ContractedPriceInsert__c) {
line.record['SBQQ__SpecialPrice__c'] = line.record['SBQQ__ListPrice__c'];
line.record['SBQQ__SpecialPriceType__c'] = 'Custom';
}
});
}
Things you need to think about
In the object contracted price, you can have a discount for this product, you need to modify the custom script according to this use case too.
The result
the link for the github : https://github.com/AourLegacy/AourFactory/tree/contracted-price-custom-script
Using flow
you can also give a contracted price according to a PB
Assign price book to a opportunity according a catalogue from account
Custom field
In account
In price book
Flow
Result
The link for the github: https://github.com/AourLegacy/AourFactory/tree/Assign-price-book-to-a-opportunity-according-a-catalogue-from-account
Using Price rule
Price rule
Price condition
Price action
Upgrade time
This usecase is not optimal, the best is to separate into two price rule or do a custom script
Result
the link for the github : https://github.com/AourLegacy/AourFactory/tree/Calcul-Contracted-prices
Comments