adjust scale_vp route to create 2 iteration for v and p respectively

This commit is contained in:
Paul Trowbridge 2019-03-14 12:08:37 -04:00
parent c536dee56d
commit 4ba6aaa2d0

View File

@ -315,8 +315,7 @@ target AS (select target_vol vincr, target_prc pincr)
SELECT
(SELECT pincr::numeric FROM target) incr
,(SELECT sum(fb_val_loc * r_rate) FROM volume) base
,(SELECT pincr::numeric FROM target)/(SELECT sum(fb_val_loc) FROM volume) factor
,(select SUM(fb_qty) from volume) tvol
,((SELECT pincr::numeric FROM target) - (SELECT sum(fb_val_loc * r_rate) FROM volume))/(SELECT sum(fb_val_loc * r_rate) FROM volume) factor
)
--select * from pscale
,pricing AS (
@ -381,10 +380,10 @@ target AS (select target_vol vincr, target_prc pincr)
,b.ddqtsi --0
,b.fgqshp --0
,b.diqtsh --0
,b.fb_qty
,b.fb_cst_loc
,b.fb_cst_loc_cur
,b.fb_cst_loc_fut
,0 fb_qty
,0 fb_cst_loc
,0 fb_cst_loc_cur
,0 fb_cst_loc_fut
,b.fb_val_loc*s.factor fb_val_loc
,b.fb_val_loc_pl*s.factor fb_val_loc_pl
,b.calc_status --0
@ -395,11 +394,11 @@ target AS (select target_vol vincr, target_prc pincr)
,b.adj_orderdate
,b.adj_requestdate
,b.adj_shipdate
,b.version --calculated
,b.iter --calculated
,'replace_version' "version" --calculated
,'replace_source'||' price' iter
-----------------------ui columns--------------------------------
,b.iterdet
,b.iterdef
,'replace_iterdet' iterdet
,$$replace_iterdef$$::jsonb iterdef
,b.order_season
,b.order_month
,b.ship_season
@ -426,16 +425,16 @@ target AS (select target_vol vincr, target_prc pincr)
,b.director_descr
,(b.fb_val_loc*s.factor)::numeric value_loc
,(b.fb_val_loc*s.factor*r_rate)::numeric value_usd
,b.cost_loc
,b.cost_usd
,b.units
,0 cost_loc
,0 cost_usd
,0 units
FROM
volume b
CROSS JOIN pscale s
)
--select sum(value_usd), sum(fb_qty) from pricing
, ins AS (
INSERT INTO rlarp.osm_fcpool SELECT * FROM pricing RETURNING *
INSERT INTO rlarp.osm_fcpool (SELECT * FROM pricing UNION ALL SELECT * FROM volume) RETURNING *
)
,insagg AS (
SELECT