vault backup: 2023-11-10 11:14:12

This commit is contained in:
Paul Trowbridge 2023-11-10 11:14:12 -05:00
parent e3c1367e51
commit fcc1ade2cf

View File

@ -119,7 +119,7 @@ export function apply_guidance(doc: any) {
const targetPrice = doc.v1tp ?? doc.v0tp; const targetPrice = doc.v1tp ?? doc.v0tp;
const earlyPrice = doc.hist.cust.early_price; const earlyPrice = doc.hist?.cust?.early_price;
let anchorPrice = null; let anchorPrice = null;
let anchorSource = null; let anchorSource = null;
let bridgePremium = doc.bridgePremium ?? 1.00000; let bridgePremium = doc.bridgePremium ?? 1.00000;
@ -127,6 +127,7 @@ export function apply_guidance(doc: any) {
if (earlyPrice) { if (earlyPrice) {
// translate alternate product history to current product quoted // translate alternate product history to current product quoted
anchorPrice = Number((earlyPrice * bridgePremium).toFixed(5)); anchorPrice = Number((earlyPrice * bridgePremium).toFixed(5));
// after the early price is translated see if target is still less
if (targetPrice < anchorPrice) { if (targetPrice < anchorPrice) {
anchorSource = 'Target Price'; anchorSource = 'Target Price';
anchorPrice = targetPrice; anchorPrice = targetPrice;
@ -137,15 +138,12 @@ export function apply_guidance(doc: any) {
anchorPrice = doc.targetPrice; anchorPrice = doc.targetPrice;
anchorSource = 'Target Price'; anchorSource = 'Target Price';
} }
doc.anchorSource = anchorSource;
const inflation = Math.max(...Object.keys(doc.iidx).map(Number)); const inflation = Math.max(...Object.keys(doc.iidx).map(Number));
const inflationFactor = doc.iidx[inflation] + 1; const inflationFactor = doc.iidx[inflation] + 1;
doc.inflationFactor = inflationFactor; var calcPrice = parseFloat((anchorPrice * inflationFactor).toFixed(5));
var calcPrice = anchorPrice * doc.inflationFactor;
calcPrice = parseFloat(calcPrice.toFixed(5));
let finalReason = ""; let finalReason = "";
if (calcPrice >= doc.list) { if (calcPrice >= doc.list && doc.list) {
doc.calcCeiling = "Cap At List"; doc.calcCeiling = "Cap At List";
doc.finalPrice = doc.list; doc.finalPrice = doc.list;
finalReason = `${anchorSource} x ${inflationFactor} = ${calcPrice} but cap at list ${doc.list}`; finalReason = `${anchorSource} x ${inflationFactor} = ${calcPrice} but cap at list ${doc.list}`;
@ -153,6 +151,8 @@ export function apply_guidance(doc: any) {
doc.finalPrice = calcPrice; doc.finalPrice = calcPrice;
finalReason = `${anchorSource} x ${inflationFactor} = ${calcPrice}`; finalReason = `${anchorSource} x ${inflationFactor} = ${calcPrice}`;
} }
doc.anchorSource = anchorSource;
doc.inflationFactor = inflationFactor;
doc.finalReason = finalReason; doc.finalReason = finalReason;
return doc; return doc;