From c536dee56db977562c2f2833e149f7cd51c113e8 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 14 Mar 2019 11:59:35 -0400 Subject: [PATCH] break out add-month volume and price impact --- route_sql/addmonth_vupd.sql | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/route_sql/addmonth_vupd.sql b/route_sql/addmonth_vupd.sql index ee56eab..75918c2 100644 --- a/route_sql/addmonth_vupd.sql +++ b/route_sql/addmonth_vupd.sql @@ -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