From 0ce9056d7c8a885b32b09c6b7eebaa9b3353a608 Mon Sep 17 00:00:00 2001 From: Trowbridge Date: Wed, 13 Mar 2019 13:53:19 -0400 Subject: [PATCH] fix up volume and price --- index.js | 12 ++++++++---- route_sql/addmonth_vupd.sql | 16 ++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/index.js b/index.js index f1dd4c0..af8bcaf 100644 --- a/index.js +++ b/index.js @@ -165,7 +165,7 @@ server.post('/addmonth_vp', bodyParser.json(), function (req, res) { var path = './route_sql/addmonth_vupd.sql'; var callback = function(arg){ - sql = arg + sql = arg; ({ c, w, d } = build_where(req, c, w, d, args)); @@ -180,6 +180,10 @@ server.post('/addmonth_vp', bodyParser.json(), function (req, res) { sql = sql.replace(new RegExp("target_volume",'g'),req.body.qty); sql = sql.replace(new RegExp("target_price",'g'),req.body.amount); sql = sql.replace(new RegExp("target_month",'g'),req.body.month); + sql = sql.replace(new RegExp("replace_version",'g'),req.body.scenario.version); + sql = sql.replace(new RegExp("replace_iteration",'g'),"tool volume & price"); + sql = sql.replace(new RegExp("replace_iterdet",'g'),"addmonth_vupd"); + sql = sql.replace(new RegExp("replace_iterdef",'g'),JSON.stringify(req.body)); //console.log(sql); Postgres.FirstRow(sql,[],res) } @@ -204,7 +208,7 @@ server.post('/scale_v', bodyParser.json(), function (req, res) { var path = './route_sql/scale_vd.sql'; var callback = function(arg){ - sql = arg + sql = arg; ({ c, w, d } = build_where(req, c, w, d, args)); @@ -241,7 +245,7 @@ server.post('/scale_p', bodyParser.json(), function (req, res) { var path = './route_sql/scale_pd.sql'; var callback = function(arg){ - sql = arg + sql = arg; ({ c, w, d } = build_where(req, c, w, d, args)); @@ -278,7 +282,7 @@ server.post('/scale_vp', bodyParser.json(), function (req, res) { var path = './route_sql/scale_vupd.sql'; var callback = function(arg){ - sql = arg + sql = arg; ({ c, w, d } = build_where(req, c, w, d, args)); diff --git a/route_sql/addmonth_vupd.sql b/route_sql/addmonth_vupd.sql index eb3d7c2..10739c3 100644 --- a/route_sql/addmonth_vupd.sql +++ b/route_sql/addmonth_vupd.sql @@ -61,8 +61,6 @@ target AS (select target_volume vincr, target_price pincr) -----------------scenario---------------------------- where_clause -----------------additional params------------------- - AND version = 'b20' - AND iter = 'copy' AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments AND adj_orderdate <= adj_shipdate GROUP BY @@ -247,8 +245,6 @@ SELECT -----------------scenario---------------------------- where_clause -----------------additional params------------------- - AND version = 'b20' - AND iter = 'copy' AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments AND adj_orderdate <= adj_shipdate GROUP BY @@ -395,11 +391,11 @@ SELECT ,make_date(mseq.yr + 2020,mseq.cal,m.odom) adj_orderdate ,make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag adj_requestdate ,make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag adj_shipdate - ,b.version --calculated - ,b.iter --calculated + ,'replace_version' "version" --calculated + ,'replace_iteration' iter --calculated -----------------------ui columns-------------------------------- - ,'adjust volume' iterdet - ,null::jsonb iterdef + ,'replace_iterdet' iterdet + ,$$replace_iterdef$$::jsonb iterdef ,od.ssyr order_season ,to_char(make_date(mseq.yr + 2020,mseq.cal,m.odom),'Mon') order_month ,sd.ssyr ship_season @@ -530,8 +526,8 @@ SELECT ,b.version --calculated ,b.iter --calculated -----------------------ui columns-------------------------------- - ,'adjust p & v' iterdet - ,null::jsonb iterdef + ,b.iterdet + ,b.iterdef ,b.order_season ,b.order_month ,b.ship_season