break out add-month volume and price impact

This commit is contained in:
Paul Trowbridge 2019-03-14 11:59:35 -04:00
parent fcf422abb7
commit c536dee56d

View File

@ -445,7 +445,8 @@ WHERE
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
--(target_sales - current_state)/current state = adjustment factor
,((SELECT pincr::numeric FROM target) - (SELECT sum(fb_val_loc * r_rate) FROM volume))/(SELECT sum(fb_val_loc * r_rate) FROM volume) factor
)
,price AS (
SELECT
@ -509,10 +510,10 @@ SELECT
,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*p.factor fb_val_loc
,b.fb_val_loc_pl*p.factor fb_val_loc_pl
,b.calc_status --0
@ -523,11 +524,10 @@ SELECT
,b.adj_orderdate
,b.adj_requestdate
,b.adj_shipdate
,b.version --calculated
,b.iter --calculated
-----------------------ui columns--------------------------------
,b.iterdet
,b.iterdef
,'replace_version' "version" --calculated
,'replace_source'||' price' iter --calculateds
,'replace_iterdet' iterdet
,$$replace_iterdef$$::jsonb iterdef
,b.order_season
,b.order_month
,b.ship_season
@ -554,15 +554,15 @@ SELECT
,b.director_descr
,b.fb_val_loc*p.factor value_loc
,b.fb_val_loc*p.factor*r_rate value_usd
,b.fb_cst_loc cost_loc
,b.fb_cst_loc*c_rate cost_usd
,b.units
,0 cost_loc
,0 cost_usd
,0 units
FROM
volume b
CROSS JOIN pscale p
)
, ins AS (
INSERT INTO rlarp.osm_fcpool SELECT * FROM price RETURNING *
INSERT INTO rlarp.osm_fcpool (SELECT * FROM price UNION ALL SELECT * FROM volume) RETURNING *
)
,insagg AS (
SELECT