fix issue with price adjustment
This commit is contained in:
parent
d3332cc778
commit
22841d3671
@ -198,7 +198,7 @@ SELECT
|
|||||||
,CASE WHEN (SELECT sum(fb_val_loc * r_rate) FROM basemix) = 0 THEN
|
,CASE WHEN (SELECT sum(fb_val_loc * r_rate) FROM basemix) = 0 THEN
|
||||||
0
|
0
|
||||||
ELSE
|
ELSE
|
||||||
((SELECT incr::numeric FROM target) - (SELECT sum(fb_val_loc * r_rate) FROM basemix))/(SELECT sum(fb_val_loc * r_rate) FROM basemix)
|
(SELECT incr::numeric FROM target)/(SELECT sum(fb_val_loc * r_rate) FROM basemix)
|
||||||
END factor
|
END factor
|
||||||
,CASE WHEN (SELECT sum(fb_val_loc * r_rate) FROM basemix) = 0 THEN
|
,CASE WHEN (SELECT sum(fb_val_loc * r_rate) FROM basemix) = 0 THEN
|
||||||
CASE WHEN ((SELECT incr::numeric FROM target) - (SELECT sum(fb_val_loc * r_rate) FROM basemix)) <> 0 THEN
|
CASE WHEN ((SELECT incr::numeric FROM target) - (SELECT sum(fb_val_loc * r_rate) FROM basemix)) <> 0 THEN
|
||||||
@ -277,8 +277,10 @@ SELECT
|
|||||||
,0 fb_cst_loc
|
,0 fb_cst_loc
|
||||||
,0 fb_cst_loc_cur
|
,0 fb_cst_loc_cur
|
||||||
,0 fb_cst_loc_fut
|
,0 fb_cst_loc_fut
|
||||||
,b.fb_val_loc*s.factor fb_val_loc
|
--,b.fb_val_loc*s.factor fb_val_loc
|
||||||
,b.fb_val_loc_pl*s.factor fb_val_loc_pl
|
,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price/b.r_rate ELSE b.fb_val_loc*s.factor END)::numeric fb_val_loc
|
||||||
|
,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price/b.r_rate ELSE b.fb_val_loc_pl*s.factor END)::numeric fb_val_loc_pl
|
||||||
|
--,b.fb_val_loc_pl*s.factor fb_val_loc_pl
|
||||||
,b.calc_status --0
|
,b.calc_status --0
|
||||||
,b.flag --0
|
,b.flag --0
|
||||||
,b.orderdate
|
,b.orderdate
|
||||||
@ -317,7 +319,7 @@ SELECT
|
|||||||
,b.quota_rep_descr
|
,b.quota_rep_descr
|
||||||
,b.director_descr
|
,b.director_descr
|
||||||
,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price/b.r_rate ELSE b.fb_val_loc*s.factor END)::numeric value_loc
|
,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price/b.r_rate ELSE b.fb_val_loc*s.factor END)::numeric value_loc
|
||||||
,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price ELSE b.fb_val_loc*s.factor END)::numeric value_usd
|
,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price ELSE b.fb_val_loc*s.factor*r_rate END)::numeric value_usd
|
||||||
,0 cost_loc
|
,0 cost_loc
|
||||||
,0 cost_usd
|
,0 cost_usd
|
||||||
,0 units
|
,0 units
|
||||||
@ -398,4 +400,4 @@ GROUP BY
|
|||||||
,version
|
,version
|
||||||
,iter
|
,iter
|
||||||
)
|
)
|
||||||
SELECT json_agg(row_to_json(insagg)) x from insagg
|
SELECT json_agg(row_to_json(insagg)) x from insagg
|
||||||
|
@ -360,7 +360,7 @@ target AS (select target_vol vincr, target_prc pincr)
|
|||||||
,CASE WHEN (SELECT sum(fb_val_loc * r_rate) FROM volume) = 0 THEN
|
,CASE WHEN (SELECT sum(fb_val_loc * r_rate) FROM volume) = 0 THEN
|
||||||
0
|
0
|
||||||
ELSE
|
ELSE
|
||||||
((SELECT pincr::numeric FROM target) - (SELECT sum(fb_val_loc * r_rate) FROM volume))/(SELECT sum(fb_val_loc * r_rate) FROM volume)
|
(SELECT pincr::numeric FROM target)/(SELECT sum(fb_val_loc * r_rate) FROM volume)
|
||||||
END factor
|
END factor
|
||||||
,CASE WHEN (SELECT sum(fb_val_loc * r_rate) FROM volume) = 0 THEN
|
,CASE WHEN (SELECT sum(fb_val_loc * r_rate) FROM volume) = 0 THEN
|
||||||
CASE WHEN ((SELECT pincr::numeric FROM target) - (SELECT sum(fb_val_loc * r_rate) FROM volume)) <> 0 THEN
|
CASE WHEN ((SELECT pincr::numeric FROM target) - (SELECT sum(fb_val_loc * r_rate) FROM volume)) <> 0 THEN
|
||||||
@ -440,8 +440,10 @@ target AS (select target_vol vincr, target_prc pincr)
|
|||||||
,0 fb_cst_loc
|
,0 fb_cst_loc
|
||||||
,0 fb_cst_loc_cur
|
,0 fb_cst_loc_cur
|
||||||
,0 fb_cst_loc_fut
|
,0 fb_cst_loc_fut
|
||||||
,b.fb_val_loc*s.factor fb_val_loc
|
--,b.fb_val_loc*s.factor fb_val_loc
|
||||||
,b.fb_val_loc_pl*s.factor fb_val_loc_pl
|
,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price/b.r_rate ELSE b.fb_val_loc*s.factor END)::numeric fb_val_loc
|
||||||
|
,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price/b.r_rate ELSE b.fb_val_loc_pl*s.factor END)::numeric fb_val_loc_pl
|
||||||
|
--,b.fb_val_loc_pl*s.factor fb_val_loc_pl
|
||||||
,b.calc_status --0
|
,b.calc_status --0
|
||||||
,b.flag --0
|
,b.flag --0
|
||||||
,b.orderdate
|
,b.orderdate
|
||||||
@ -480,7 +482,7 @@ target AS (select target_vol vincr, target_prc pincr)
|
|||||||
,b.quota_rep_descr
|
,b.quota_rep_descr
|
||||||
,b.director_descr
|
,b.director_descr
|
||||||
,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price/b.r_rate ELSE b.fb_val_loc*s.factor END)::numeric value_loc
|
,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price/b.r_rate ELSE b.fb_val_loc*s.factor END)::numeric value_loc
|
||||||
,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price ELSE b.fb_val_loc*s.factor END)::numeric value_usd
|
,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price ELSE b.fb_val_loc*s.factor*b.r_rate END)::numeric value_usd
|
||||||
,0 cost_loc
|
,0 cost_loc
|
||||||
,0 cost_usd
|
,0 cost_usd
|
||||||
,0 units
|
,0 units
|
||||||
@ -561,4 +563,4 @@ GROUP BY
|
|||||||
,version
|
,version
|
||||||
,iter
|
,iter
|
||||||
)
|
)
|
||||||
SELECT json_agg(row_to_json(insagg)) x from insagg
|
SELECT json_agg(row_to_json(insagg)) x from insagg
|
||||||
|
Loading…
Reference in New Issue
Block a user