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 = {
prices
,finalPrice
,targetPrice
,listUSD
,ltp
,inflationFactor
,optimization
}
doc.guidance = guidance;
return doc;

View File

@ -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;

View File

@ -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