From 12b963b22f5b13128c17475a1cb3e4c1e91c853d Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Fri, 10 Nov 2023 11:25:21 -0500 Subject: [PATCH] vault backup: 2023-11-10 11:25:21 --- apply_guidance.ts | 7 +++++-- sql/get_guidance.pg.sql | 4 +++- sql/get_guidance_dseg.pg.sql | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apply_guidance.ts b/apply_guidance.ts index a39ad26..e538c2c 100644 --- a/apply_guidance.ts +++ b/apply_guidance.ts @@ -135,8 +135,8 @@ export function apply_guidance(doc: any) { anchorSource = doc.hist.cust.early_season + ' Similar (' + doc.hist.cust.ds + ') Customer Price ' + earlyPrice + ' x ' + doc.bridgePremium + ' = ' + anchorPrice; } } else { - anchorPrice = doc.targetPrice; - anchorSource = 'Target Price'; + anchorPrice = targetPrice; + anchorSource = `Target Price ${targetPrice}`; } const inflation = Math.max(...Object.keys(doc.iidx).map(Number)); @@ -151,9 +151,12 @@ export function apply_guidance(doc: any) { doc.finalPrice = calcPrice; finalReason = `${anchorSource} x ${inflationFactor} = ${calcPrice}`; } + doc.anchorPrice = anchorPrice; doc.anchorSource = anchorSource; doc.inflationFactor = inflationFactor; doc.finalReason = finalReason; + doc.bridgePremium = bridgePremium; + doc.targetPrice = targetPrice; return doc; } diff --git a/sql/get_guidance.pg.sql b/sql/get_guidance.pg.sql index 812ff88..554763b 100644 --- a/sql/get_guidance.pg.sql +++ b/sql/get_guidance.pg.sql @@ -13,6 +13,7 @@ DECLARE _mold text; _stlc text; _cust text; + _curr text; _v1ds text; _v0ds text; _v1tp jsonb; @@ -58,7 +59,8 @@ BEGIN ----------------customer------------------------------------ SELECT dba INTO _cust FROM rlarp.cust WHERE code = CASE WHEN _chan = 'DRP' THEN _ship ELSE _bill END ; - _rslt = _rslt||jsonb_build_object('cust',_cust); + SELECT currency INTO _curr FROM rlarp.cust WHERE code = _bill; + _rslt = _rslt||jsonb_build_object('cust',_cust,'curr',_curr); --RAISE NOTICE 'cust %', _cust; ----------------price history------------------------------- diff --git a/sql/get_guidance_dseg.pg.sql b/sql/get_guidance_dseg.pg.sql index f048cba..5804f7f 100644 --- a/sql/get_guidance_dseg.pg.sql +++ b/sql/get_guidance_dseg.pg.sql @@ -14,6 +14,7 @@ DECLARE _mold text; _item text; _cust text; + _curr text; _v1ds text; _v0ds text; _v1tp jsonb; @@ -74,7 +75,8 @@ BEGIN ----------------customer------------------------------------ SELECT dba INTO _cust FROM rlarp.cust WHERE code = CASE WHEN _chan = 'DRP' THEN _ship ELSE _bill END ; - _rslt = _rslt||jsonb_build_object('cust',_cust); + SELECT currency INTO _curr FROM rlarp.cust WHERE code = _bill; + _rslt = _rslt||jsonb_build_object('cust',_cust,'curr',_curr); RAISE NOTICE 'cust %', _cust; ----------------price history-------------------------------