From 062cea58a6b78d59b166a9732c45d003828d376d Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Mon, 20 Nov 2023 15:56:18 -0500 Subject: [PATCH] vault backup: 2023-11-20 15:56:18 --- apply_guidance.ts | 5 +++++ sql/apply_guidance.pg.sql | 7 +++---- sql/livequotes.pg.sql | 3 +++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apply_guidance.ts b/apply_guidance.ts index 8393024..a9528d9 100644 --- a/apply_guidance.ts +++ b/apply_guidance.ts @@ -116,6 +116,11 @@ export function apply_guidance(doc: any) { let guidance = { prices ,finalPrice + ,targetPrice + ,listUSD + ,ltp + ,inflationFactor + ,optimization } doc.guidance = guidance; return doc; diff --git a/sql/apply_guidance.pg.sql b/sql/apply_guidance.pg.sql index 568d3de..599a41b 100644 --- a/sql/apply_guidance.pg.sql +++ b/sql/apply_guidance.pg.sql @@ -60,8 +60,6 @@ AS $function$ return result.toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2}); } - console.log(doc); - // --------------------extract incoming data------------------------------------------------------ const targetPrice = doc.pricing?.v1tp ?? doc.pricing?.v0tp; const priceBand = doc.pricing?.v1stdv ?? doc.pricing?.v0stdv; @@ -81,7 +79,6 @@ AS $function$ const inflationFactor = iidx ? iidx[inflation] : 0; const list = doc.pricing?.list && doc.product?.itemrel === "2" ? doc.pricing?.list : null; const listUSD = list ? list * fxrate :null; - const fstdUSD = doc.product?.std; // ------------------calculate price adders------------------------------------------------------ let ltp = qty < pltq ? 0.15 : null; @@ -124,7 +121,9 @@ AS $function$ ,finalPrice ,targetPrice ,listUSD - ,fstdUSD + ,ltp + ,inflationFactor + ,optimization } doc.guidance = guidance; return doc; diff --git a/sql/livequotes.pg.sql b/sql/livequotes.pg.sql index d738bfe..2d1299a 100644 --- a/sql/livequotes.pg.sql +++ b/sql/livequotes.pg.sql @@ -17,6 +17,9 @@ lq AS MATERIALIZED ( ,(pricing->'guidance'->'finalPrice'->>'Price')::numeric guidance ,pricing->'guidance'->'finalPrice'->>'Reason' reason ,(pricing->'product'->>'fstd_usd')::numeric fstd_usd + ,(pricing->'guidance'->>'ltp')::numeric ltp + ,(pricing->'guidance'->>'optimization')::numeric optimization + ,(pricing->'guidance'->>'inflationFactor')::numeric inflation ,jsonb_pretty(pricing) pricing FROM lq