diff --git a/generate_sql/gen_baseline.sql b/generate_sql/gen_baseline.sql index c116d65..5e4c162 100644 --- a/generate_sql/gen_baseline.sql +++ b/generate_sql/gen_baseline.sql @@ -14,6 +14,16 @@ DECLARE _perd_joins text; _interval interval; +/*----------------parameters listing-------------- +app_baseline_from_date +app_baseline_to_date +app_first_forecast_date +app_openorder_cutoff +app_openstatus_code +app_plug_fromdate +app_plug_todate +------------------------------------------------*/ + BEGIN -----------------populate application variables-------------------------------------------- diff --git a/index.js b/index.js index 4efacbf..1d3a578 100644 --- a/index.js +++ b/index.js @@ -61,6 +61,15 @@ server.get('/baseline', bodyParser.json(), function(req, res) { } }); + //list of parameters that will need to be supplied from the app + //app_baseline_from_date + //app_baseline_to_date + //app_first_forecast_date + //app_openorder_cutoff + //app_openstatus_code + //app_plug_fromdate + //app_plug_todate + var callback = function(arg) { sql = arg; @@ -68,6 +77,8 @@ server.get('/baseline', bodyParser.json(), function(req, res) { console.log(req.body); //parse the where clause into the main sql statement //sql = sql.replace(new RegExp("where_clause", 'g'), w) + sql = sql.replace(new RegExp("[app_baseline_from_date]",'g'), "$1"); + args.push(req.body.app_baseline_from_date); //execute the sql and send the result console.log(sql); //Postgres.FirstRow(sql, [], res) diff --git a/sample_request.json b/sample_request.json index 61ee6ed..3460185 100644 --- a/sample_request.json +++ b/sample_request.json @@ -1,28 +1,9 @@ { - "scenario": { - "quota_rep_descr": "TINA PETTIGREW", - "substance": "Plastic", - "chan": "DIR", - "billto_group": "H&A MASTRONARDI", - "shipto_group": "H&A MASTRONARDI", - "majg_descr": "110 - INJECTION", - "part_descr": "HWA13000E21B025LZBLD - 13.00 WRAPT HP CHOCOLATE", - "version": "b21", - "iter": [ - "copy", - "adj volume", - "adj price", - "upload volume", - "upload price" - ] - }, - "stamp": "2020-02-19 17:03:38", - "user": "Trowbridge, Paul", - "source": "adj", - "message": "2% on volume and price", - "tag": "standard price", - "version": "b21", - "type": "scale_vp", - "qty": 453.60, - "amount": 728.43624 -} \ No newline at end of file + "app_baseline_from_date":"2020-06-01", + "app_baseline_to_date":"2020-10-31", + "app_first_forecast_date":"2021-06-01", + "app_openorder_cutoff":"2020-10-31", + "app_openstatus_code":["OPEN","BACKORDERD"], + "app_plug_fromdate":"2020-11-01", + "app_plug_todate":"2020-05-31" +}