From 92657e72c366ec192f025ec1f98a06e32678d71b Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Wed, 13 Mar 2019 23:25:07 -0400 Subject: [PATCH] update scale volume route to contain iteration info --- index.js | 6 +++++- route_sql/scale_vd.sql | 10 ++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 1cdd7a6..30eaf15 100644 --- a/index.js +++ b/index.js @@ -221,6 +221,10 @@ server.post('/scale_v', bodyParser.json(), function (req, res) { //console.log(args); sql = sql.replace(new RegExp("where_clause",'g'),w); sql = sql.replace(new RegExp("target_increment",'g'),req.body.amount); + sql = sql.replace(new RegExp("replace_version",'g'),req.body.scenario.version); + sql = sql.replace(new RegExp("replace_iteration",'g'),"tool volume"); + sql = sql.replace(new RegExp("replace_iterdet",'g'),"scale volume"); + sql = sql.replace(new RegExp("replace_iterdef",'g'),JSON.stringify(req.body)); //console.log(sql); Postgres.FirstRow(sql,[],res) } @@ -260,7 +264,7 @@ server.post('/scale_p', bodyParser.json(), function (req, res) { sql = sql.replace(new RegExp("target_increment",'g'),req.body.amount); sql = sql.replace(new RegExp("replace_version",'g'),req.body.scenario.version); sql = sql.replace(new RegExp("replace_iteration",'g'),"tool price"); - sql = sql.replace(new RegExp("replace_iterdet",'g'),"addmonth_vupd"); + sql = sql.replace(new RegExp("replace_iterdet",'g'),"scale price"); sql = sql.replace(new RegExp("replace_iterdef",'g'),JSON.stringify(req.body)); //console.log(sql); Postgres.FirstRow(sql,[],res) diff --git a/route_sql/scale_vd.sql b/route_sql/scale_vd.sql index 44ce6dd..e6ea932 100644 --- a/route_sql/scale_vd.sql +++ b/route_sql/scale_vd.sql @@ -114,8 +114,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 @@ -274,11 +272,11 @@ SELECT ,b.adj_orderdate ,b.adj_requestdate ,b.adj_shipdate - ,b.version --calculated - ,b.iter --calculated + ,'replace_version' "version" --calculated + ,'replace_iteration' iter --calculated -----------------------ui columns-------------------------------- - ,'scale volume' iterdet - ,null::jsonb iterdef + ,'replace_iterdet' iterdet + ,$$replace_iterdef$$::jsonb iterdef ,b.order_season ,b.order_month ,b.ship_season