diff --git a/apply_guidance.ts b/apply_guidance.ts index caa3d87..ef704fc 100644 --- a/apply_guidance.ts +++ b/apply_guidance.ts @@ -122,16 +122,13 @@ export function apply_guidance(doc: any) { // Determine the anchor price and source if (doc.hist.cust?.early_price !== undefined ) { if (doc.hist.cust.relevance !== 'customer exact') { + // translate alternate product history to current product quoted 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; diff --git a/sql/db_apply.pg.sql b/sql/db_apply.pg.sql new file mode 100644 index 0000000..9833bed --- /dev/null +++ b/sql/db_apply.pg.sql @@ -0,0 +1,5 @@ +SELECT + rlarp.get_guidance(lq.billto, lq.shipto, lq.part, lq.units_each, 2024) +FROM + pricequote.live_quotes lq +LIMIT 100