vault backup: 2023-11-20 15:56:18

This commit is contained in:
Paul Trowbridge 2023-11-20 15:56:18 -05:00
parent 14ee797b91
commit 062cea58a6
3 changed files with 11 additions and 4 deletions

View File

@ -116,6 +116,11 @@ export function apply_guidance(doc: any) {
let guidance = { let guidance = {
prices prices
,finalPrice ,finalPrice
,targetPrice
,listUSD
,ltp
,inflationFactor
,optimization
} }
doc.guidance = guidance; doc.guidance = guidance;
return doc; return doc;

View File

@ -60,8 +60,6 @@ AS $function$
return result.toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2}); return result.toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2});
} }
console.log(doc);
// --------------------extract incoming data------------------------------------------------------ // --------------------extract incoming data------------------------------------------------------
const targetPrice = doc.pricing?.v1tp ?? doc.pricing?.v0tp; const targetPrice = doc.pricing?.v1tp ?? doc.pricing?.v0tp;
const priceBand = doc.pricing?.v1stdv ?? doc.pricing?.v0stdv; const priceBand = doc.pricing?.v1stdv ?? doc.pricing?.v0stdv;
@ -81,7 +79,6 @@ AS $function$
const inflationFactor = iidx ? iidx[inflation] : 0; const inflationFactor = iidx ? iidx[inflation] : 0;
const list = doc.pricing?.list && doc.product?.itemrel === "2" ? doc.pricing?.list : null; const list = doc.pricing?.list && doc.product?.itemrel === "2" ? doc.pricing?.list : null;
const listUSD = list ? list * fxrate :null; const listUSD = list ? list * fxrate :null;
const fstdUSD = doc.product?.std;
// ------------------calculate price adders------------------------------------------------------ // ------------------calculate price adders------------------------------------------------------
let ltp = qty < pltq ? 0.15 : null; let ltp = qty < pltq ? 0.15 : null;
@ -124,7 +121,9 @@ AS $function$
,finalPrice ,finalPrice
,targetPrice ,targetPrice
,listUSD ,listUSD
,fstdUSD ,ltp
,inflationFactor
,optimization
} }
doc.guidance = guidance; doc.guidance = guidance;
return doc; return doc;

View File

@ -17,6 +17,9 @@ lq AS MATERIALIZED (
,(pricing->'guidance'->'finalPrice'->>'Price')::numeric guidance ,(pricing->'guidance'->'finalPrice'->>'Price')::numeric guidance
,pricing->'guidance'->'finalPrice'->>'Reason' reason ,pricing->'guidance'->'finalPrice'->>'Reason' reason
,(pricing->'product'->>'fstd_usd')::numeric fstd_usd ,(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 ,jsonb_pretty(pricing) pricing
FROM FROM
lq lq