vault backup: 2023-11-10 02:59:19

This commit is contained in:
Paul Trowbridge 2023-11-10 02:59:19 -05:00
parent 5e0a1186d8
commit 1250c671e7
1 changed files with 18 additions and 12 deletions

View File

@ -117,23 +117,29 @@ export function apply_guidance(doc: any) {
// };
//}
doc.targetPrice = doc.v1tp ?? doc.v0tp ?? null;
doc.targetPrice = doc.v1tp ?? doc.v0tp;
// Determine the anchor price and source
if (doc.targetPrice !== undefined && (doc.hist.cust.early_price === undefined || doc.targetPrice < doc.hist.cust.early_price)) {
doc.anchorPrice = doc.targetPrice;
doc.anchorSource = 'Target Price';
} else if (doc.hist.cust.early_price !== undefined) {
if (doc.hist.cust?.early_price !== undefined ) {
if (doc.hist.cust.relevance !== 'customer exact') {
doc.anchorPrice = doc.hist.cust.early_price * doc.bridgePremium;
doc.anchorSource = doc.hist.cust.early_season + ' Similar (' + doc.hist.cust.ds + ') Customer Price ' + doc.hist.cust.early_price + ' x ' + doc.bridgePremium + ' = ' + doc.anchorPrice;
doc.anchorPrice = Number((doc.hist.cust.early_price * doc.bridgePremium).toFixed(5));
if (doc.targetPrice < doc.anchorPrice) {
doc.anchorPrice = doc.targetPrice;
doc.anchorSource = 'Target Price'
} else {
doc.anchorSource = doc.hist.cust.early_season + ' Similar (' + doc.hist.cust.ds + ') Customer Price ' + doc.hist.cust.early_price + ' x ' + doc.bridgePremium + ' = ' + doc.anchorPrice;
if (doc.targetPrice < doc.anchorPrice) {
doc.anchorSource = 'Target Price';
doc.anchorPrice = doc.targetPrice;
}
}
} else {
doc.anchorPrice = doc.hist.cust.early_price;
doc.anchorSource = doc.hist.cust.early_season + ' Customer Price ' + doc.hist.cust.early_price;
}
} else {
doc.anchorPrice = null;
doc.anchorSource = 'none'; // or any other default value you wish to indicate no anchor price was found
doc.anchorPrice = doc.targetPrice;
doc.anchorSource = 'Target Price';
}
const inflation = Math.max(...Object.keys(doc.iidx).map(Number));
@ -145,10 +151,10 @@ export function apply_guidance(doc: any) {
if (calcPrice >= doc.list) {
doc.calcCeiling = "Cap At List";
doc.finalPrice = doc.list;
finalReason = `${doc.anchorSource} ${doc.anchorPrice} x ${inflationFactor} = ${calcPrice} but cap at list ${doc.list}`;
finalReason = `${doc.anchorSource} x ${inflationFactor} = ${calcPrice} but cap at list ${doc.list}`;
} else {
doc.finalPrice = calcPrice;
finalReason = `${doc.anchorSource} ${doc.anchorPrice} x ${inflationFactor} = ${calcPrice}`;
finalReason = `${doc.anchorSource} x ${inflationFactor} = ${calcPrice}`;
}
doc.finalReason = finalReason;