Compare commits
2 Commits
1f96081a41
...
c9811e69db
Author | SHA1 | Date | |
---|---|---|---|
c9811e69db | |||
66b74e31cb |
@ -316,11 +316,11 @@ SELECT
|
|||||||
,b.r_rate
|
,b.r_rate
|
||||||
,b.c_currency
|
,b.c_currency
|
||||||
,b.c_rate
|
,b.c_rate
|
||||||
,b.units*s.factor*m.momix units
|
,round(b.units*s.factor*m.momix ,2) units
|
||||||
,b.value_loc*s.factor*m.momix value_loc
|
,round(b.value_loc*s.factor*m.momix,2) value_loc
|
||||||
,b.value_usd*s.factor*m.momix value_usd
|
,round(b.value_usd*s.factor*m.momix,2) value_usd
|
||||||
,b.cost_loc*s.factor*m.momix cost_loc
|
,round(b.cost_loc*s.factor*m.momix ,2) cost_loc
|
||||||
,b.cost_usd*s.factor*m.momix cost_usd
|
,round(b.cost_usd*s.factor*m.momix ,2) cost_usd
|
||||||
,b.calc_status
|
,b.calc_status
|
||||||
,b.flag
|
,b.flag
|
||||||
,make_date(mseq.yr + 2022,mseq.cal,m.odom) order_date
|
,make_date(mseq.yr + 2022,mseq.cal,m.odom) order_date
|
||||||
@ -407,8 +407,8 @@ SELECT
|
|||||||
,b.c_currency
|
,b.c_currency
|
||||||
,b.c_rate
|
,b.c_rate
|
||||||
,0::numeric units
|
,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
|
,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
|
||||||
,(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 ELSE b.value_usd*p.factor END)::numeric ,2) value_usd
|
||||||
,0::numeric cost_loc
|
,0::numeric cost_loc
|
||||||
,0::numeric cost_usd
|
,0::numeric cost_usd
|
||||||
,b.calc_status
|
,b.calc_status
|
||||||
|
@ -329,11 +329,11 @@ SELECT
|
|||||||
,rx.rate r_rate --master data
|
,rx.rate r_rate --master data
|
||||||
,copr.curr c_currency --master data
|
,copr.curr c_currency --master data
|
||||||
,cx.rate c_rate --master data
|
,cx.rate c_rate --master data
|
||||||
,b.units
|
,round(b.units ,2) 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
|
,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
|
||||||
,b.value_usd value_usd --b.value is already denominated in usd
|
,round(b.value_usd ,2) value_usd --b.value is already denominated in usd
|
||||||
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units cost_loc
|
,round(COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units ,2) cost_loc
|
||||||
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units*cx.rate cost_usd
|
,round(COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units*cx.rate,2) cost_usd
|
||||||
,'CLOSED' calc_status
|
,'CLOSED' calc_status
|
||||||
,'SHIPMENT' flag
|
,'SHIPMENT' flag
|
||||||
,b.order_date
|
,b.order_date
|
||||||
|
@ -152,8 +152,8 @@ target AS (select target_increment incr)
|
|||||||
,c_currency --master data
|
,c_currency --master data
|
||||||
,c_rate --master data
|
,c_rate --master data
|
||||||
,0::numeric units
|
,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
|
,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
|
||||||
,(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 ELSE b.value_usd*s.factor END)::numeric ,2) value_usd
|
||||||
,0::numeric cost_loc
|
,0::numeric cost_loc
|
||||||
,0::numeric cost_usd
|
,0::numeric cost_usd
|
||||||
,calc_status --0
|
,calc_status --0
|
||||||
|
@ -180,11 +180,11 @@ target AS (select incr_qty qincr)
|
|||||||
,r_rate --master data
|
,r_rate --master data
|
||||||
,c_currency --master data
|
,c_currency --master data
|
||||||
,c_rate --master data
|
,c_rate --master data
|
||||||
,units*s.factor
|
,round(units*s.factor ,2) units
|
||||||
,value_loc*s.factor value_loc
|
,round(value_loc*s.factor,2) value_loc
|
||||||
,value_usd*s.factor value_usd
|
,round(value_usd*s.factor,2) value_usd
|
||||||
,cost_loc*s.factor cost_loc
|
,round(cost_loc*s.factor ,2) cost_loc
|
||||||
,cost_usd*s.factor cost_usd
|
,round(cost_usd*s.factor ,2) cost_usd
|
||||||
,calc_status --0
|
,calc_status --0
|
||||||
,flag --0
|
,flag --0
|
||||||
,order_date --history date mix
|
,order_date --history date mix
|
||||||
@ -293,4 +293,4 @@ FROM
|
|||||||
,tag
|
,tag
|
||||||
,comment
|
,comment
|
||||||
)
|
)
|
||||||
SELECT json_agg(row_to_json(insagg)) x from insagg
|
SELECT json_agg(row_to_json(insagg)) x from insagg
|
||||||
|
@ -179,11 +179,11 @@ target AS (select target_vol vincr, target_prc pincr)
|
|||||||
,r_rate --master data
|
,r_rate --master data
|
||||||
,c_currency --master data
|
,c_currency --master data
|
||||||
,c_rate --master data
|
,c_rate --master data
|
||||||
,units*s.factor units
|
,round(units*s.factor ,2) units
|
||||||
,value_loc*s.factor value_loc
|
,round(value_loc*s.factor,2) value_loc
|
||||||
,value_usd*s.factor value_usd
|
,round(value_usd*s.factor,2) value_usd
|
||||||
,cost_loc*s.factor cost_loc
|
,round(cost_loc*s.factor ,2) cost_loc
|
||||||
,cost_usd*s.factor cost_usd
|
,round(cost_usd*s.factor ,2) cost_usd
|
||||||
,calc_status --0
|
,calc_status --0
|
||||||
,flag --0
|
,flag --0
|
||||||
,order_date --history date mix
|
,order_date --history date mix
|
||||||
@ -261,8 +261,8 @@ FROM
|
|||||||
,c_currency --master data
|
,c_currency --master data
|
||||||
,c_rate --master data
|
,c_rate --master data
|
||||||
,0::numeric units
|
,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
|
,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
|
||||||
,(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 ELSE b.value_usd*s.factor END)::numeric ,2) value_usd
|
||||||
,0::numeric cost_loc
|
,0::numeric cost_loc
|
||||||
,0::numeric cost_usd
|
,0::numeric cost_usd
|
||||||
,calc_status --0
|
,calc_status --0
|
||||||
|
@ -180,11 +180,11 @@ target AS (select target_vol vincr, target_prc pincr)
|
|||||||
,r_rate --master data
|
,r_rate --master data
|
||||||
,c_currency --master data
|
,c_currency --master data
|
||||||
,c_rate --master data
|
,c_rate --master data
|
||||||
,units*s.factor units
|
,round(units*s.factor ,2) units
|
||||||
,value_loc*s.factor value_loc
|
,round(value_loc*s.factor,2) value_loc
|
||||||
,value_usd*s.factor value_usd
|
,round(value_usd*s.factor,2) value_usd
|
||||||
,cost_loc*s.factor cost_loc
|
,round(cost_loc*s.factor ,2) cost_loc
|
||||||
,cost_usd*s.factor cost_usd
|
,round(cost_usd*s.factor ,2) cost_usd
|
||||||
,calc_status --0
|
,calc_status --0
|
||||||
,flag --0
|
,flag --0
|
||||||
,order_date --history date mix
|
,order_date --history date mix
|
||||||
@ -262,8 +262,8 @@ FROM
|
|||||||
,c_currency --master data
|
,c_currency --master data
|
||||||
,c_rate --master data
|
,c_rate --master data
|
||||||
,0::numeric units
|
,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
|
,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
|
||||||
,(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 ELSE b.value_usd*s.factor END)::numeric ,2) value_usd
|
||||||
,0::numeric cost_loc
|
,0::numeric cost_loc
|
||||||
,0::numeric cost_usd
|
,0::numeric cost_usd
|
||||||
,calc_status --0
|
,calc_status --0
|
||||||
|
Loading…
Reference in New Issue
Block a user