update all routes to round to 2 decimals for units, value, and cost

This commit is contained in:
Paul Trowbridge 2021-04-19 09:20:52 -04:00
parent e3722193c5
commit 66b74e31cb
6 changed files with 34 additions and 34 deletions

View File

@ -316,11 +316,11 @@ SELECT
,b.r_rate
,b.c_currency
,b.c_rate
,b.units*s.factor*m.momix units
,b.value_loc*s.factor*m.momix value_loc
,b.value_usd*s.factor*m.momix value_usd
,b.cost_loc*s.factor*m.momix cost_loc
,b.cost_usd*s.factor*m.momix cost_usd
,round(b.units*s.factor*m.momix ,2) units
,round(b.value_loc*s.factor*m.momix,2) value_loc
,round(b.value_usd*s.factor*m.momix,2) value_usd
,round(b.cost_loc*s.factor*m.momix ,2) cost_loc
,round(b.cost_usd*s.factor*m.momix ,2) cost_usd
,b.calc_status
,b.flag
,make_date(mseq.yr + 2022,mseq.cal,m.odom) order_date
@ -407,8 +407,8 @@ SELECT
,b.c_currency
,b.c_rate
,0::numeric units
,(CASE WHEN p.factor = 0 THEN b.units * p.mod_price/b.r_rate ELSE b.value_loc*p.factor END)::numeric value_loc
,(CASE WHEN p.factor = 0 THEN b.units * p.mod_price ELSE b.value_usd*p.factor END)::numeric value_usd
,round((CASE WHEN p.factor = 0 THEN b.units * p.mod_price/b.r_rate ELSE b.value_loc*p.factor END)::numeric,2) value_loc
,round((CASE WHEN p.factor = 0 THEN b.units * p.mod_price ELSE b.value_usd*p.factor END)::numeric ,2) value_usd
,0::numeric cost_loc
,0::numeric cost_usd
,b.calc_status

View File

@ -329,11 +329,11 @@ SELECT
,rx.rate r_rate --master data
,copr.curr c_currency --master data
,cx.rate c_rate --master data
,b.units
,b.value_usd / COALESCE(rx.rate,1) --b.value is denominated in USD, need to apply currency to get to local, assume 1 if using a fake customer
,b.value_usd value_usd --b.value is already denominated in usd
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units cost_loc
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units*cx.rate cost_usd
,round(b.units ,2) units
,round(b.value_usd / COALESCE(rx.rate,1) ,2) value_loc --b.value is denominated in USD, need to apply currency to get to local, assume 1 if using a fake customer
,round(b.value_usd ,2) value_usd --b.value is already denominated in usd
,round(COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units ,2) cost_loc
,round(COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units*cx.rate,2) cost_usd
,'CLOSED' calc_status
,'SHIPMENT' flag
,b.order_date

View File

@ -152,8 +152,8 @@ target AS (select target_increment incr)
,c_currency --master data
,c_rate --master data
,0::numeric units
,(CASE WHEN s.factor = 0 THEN b.units * s.mod_price/b.r_rate ELSE b.value_loc*s.factor END)::numeric value_loc
,(CASE WHEN s.factor = 0 THEN b.units * s.mod_price ELSE b.value_usd*s.factor END)::numeric value_usd
,round((CASE WHEN s.factor = 0 THEN b.units * s.mod_price/b.r_rate ELSE b.value_loc*s.factor END)::numeric,2) value_loc
,round((CASE WHEN s.factor = 0 THEN b.units * s.mod_price ELSE b.value_usd*s.factor END)::numeric ,2) value_usd
,0::numeric cost_loc
,0::numeric cost_usd
,calc_status --0

View File

@ -180,11 +180,11 @@ target AS (select incr_qty qincr)
,r_rate --master data
,c_currency --master data
,c_rate --master data
,units*s.factor
,value_loc*s.factor value_loc
,value_usd*s.factor value_usd
,cost_loc*s.factor cost_loc
,cost_usd*s.factor cost_usd
,round(units*s.factor ,2) units
,round(value_loc*s.factor,2) value_loc
,round(value_usd*s.factor,2) value_usd
,round(cost_loc*s.factor ,2) cost_loc
,round(cost_usd*s.factor ,2) cost_usd
,calc_status --0
,flag --0
,order_date --history date mix
@ -293,4 +293,4 @@ FROM
,tag
,comment
)
SELECT json_agg(row_to_json(insagg)) x from insagg
SELECT json_agg(row_to_json(insagg)) x from insagg

View File

@ -179,11 +179,11 @@ target AS (select target_vol vincr, target_prc pincr)
,r_rate --master data
,c_currency --master data
,c_rate --master data
,units*s.factor units
,value_loc*s.factor value_loc
,value_usd*s.factor value_usd
,cost_loc*s.factor cost_loc
,cost_usd*s.factor cost_usd
,round(units*s.factor ,2) units
,round(value_loc*s.factor,2) value_loc
,round(value_usd*s.factor,2) value_usd
,round(cost_loc*s.factor ,2) cost_loc
,round(cost_usd*s.factor ,2) cost_usd
,calc_status --0
,flag --0
,order_date --history date mix
@ -261,8 +261,8 @@ FROM
,c_currency --master data
,c_rate --master data
,0::numeric units
,(CASE WHEN s.factor = 0 THEN b.units * s.mod_price/b.r_rate ELSE b.value_loc*s.factor END)::numeric value_loc
,(CASE WHEN s.factor = 0 THEN b.units * s.mod_price ELSE b.value_usd*s.factor END)::numeric value_usd
,round((CASE WHEN s.factor = 0 THEN b.units * s.mod_price/b.r_rate ELSE b.value_loc*s.factor END)::numeric,2) value_loc
,round((CASE WHEN s.factor = 0 THEN b.units * s.mod_price ELSE b.value_usd*s.factor END)::numeric ,2) value_usd
,0::numeric cost_loc
,0::numeric cost_usd
,calc_status --0

View File

@ -180,11 +180,11 @@ target AS (select target_vol vincr, target_prc pincr)
,r_rate --master data
,c_currency --master data
,c_rate --master data
,units*s.factor units
,value_loc*s.factor value_loc
,value_usd*s.factor value_usd
,cost_loc*s.factor cost_loc
,cost_usd*s.factor cost_usd
,round(units*s.factor ,2) units
,round(value_loc*s.factor,2) value_loc
,round(value_usd*s.factor,2) value_usd
,round(cost_loc*s.factor ,2) cost_loc
,round(cost_usd*s.factor ,2) cost_usd
,calc_status --0
,flag --0
,order_date --history date mix
@ -262,8 +262,8 @@ FROM
,c_currency --master data
,c_rate --master data
,0::numeric units
,(CASE WHEN s.factor = 0 THEN b.units * s.mod_price/b.r_rate ELSE b.value_loc*s.factor END)::numeric value_loc
,(CASE WHEN s.factor = 0 THEN b.units * s.mod_price ELSE b.value_usd*s.factor END)::numeric value_usd
,round((CASE WHEN s.factor = 0 THEN b.units * s.mod_price/b.r_rate ELSE b.value_loc*s.factor END)::numeric,2) value_loc
,round((CASE WHEN s.factor = 0 THEN b.units * s.mod_price ELSE b.value_usd*s.factor END)::numeric ,2) value_usd
,0::numeric cost_loc
,0::numeric cost_usd
,calc_status --0