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
(SELECT pincr::numeric FROM target) incr (SELECT pincr::numeric FROM target) incr
,(SELECT sum(fb_val_loc * r_rate) FROM volume) base ,(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 ( ,price AS (
SELECT SELECT
@ -509,10 +510,10 @@ SELECT
,b.ddqtsi --0 ,b.ddqtsi --0
,b.fgqshp --0 ,b.fgqshp --0
,b.diqtsh --0 ,b.diqtsh --0
,b.fb_qty ,0 fb_qty
,b.fb_cst_loc ,0 fb_cst_loc
,b.fb_cst_loc_cur ,0 fb_cst_loc_cur
,b.fb_cst_loc_fut ,0 fb_cst_loc_fut
,b.fb_val_loc*p.factor fb_val_loc ,b.fb_val_loc*p.factor fb_val_loc
,b.fb_val_loc_pl*p.factor fb_val_loc_pl ,b.fb_val_loc_pl*p.factor fb_val_loc_pl
,b.calc_status --0 ,b.calc_status --0
@ -523,11 +524,10 @@ SELECT
,b.adj_orderdate ,b.adj_orderdate
,b.adj_requestdate ,b.adj_requestdate
,b.adj_shipdate ,b.adj_shipdate
,b.version --calculated ,'replace_version' "version" --calculated
,b.iter --calculated ,'replace_source'||' price' iter --calculateds
-----------------------ui columns-------------------------------- ,'replace_iterdet' iterdet
,b.iterdet ,$$replace_iterdef$$::jsonb iterdef
,b.iterdef
,b.order_season ,b.order_season
,b.order_month ,b.order_month
,b.ship_season ,b.ship_season
@ -554,15 +554,15 @@ SELECT
,b.director_descr ,b.director_descr
,b.fb_val_loc*p.factor value_loc ,b.fb_val_loc*p.factor value_loc
,b.fb_val_loc*p.factor*r_rate value_usd ,b.fb_val_loc*p.factor*r_rate value_usd
,b.fb_cst_loc cost_loc ,0 cost_loc
,b.fb_cst_loc*c_rate cost_usd ,0 cost_usd
,b.units ,0 units
FROM FROM
volume b volume b
CROSS JOIN pscale p CROSS JOIN pscale p
) )
, ins AS ( , 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 ( ,insagg AS (
SELECT SELECT