From 551a4867d634b53767aeac67e3fbd49927b6054c Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Mon, 5 Apr 2021 19:22:20 +0000 Subject: [PATCH] increment route fiscal years --- route_sql/addmonth_vupd.sql | 20 ++++++++++---------- route_sql/adj_totals.sql | 4 ++-- route_sql/new_basket.sql | 14 +++++++------- route_sql/scale_vupd_sales.sql | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/route_sql/addmonth_vupd.sql b/route_sql/addmonth_vupd.sql index 565b1a2..a57c206 100644 --- a/route_sql/addmonth_vupd.sql +++ b/route_sql/addmonth_vupd.sql @@ -323,14 +323,14 @@ SELECT ,b.cost_usd*s.factor*m.momix cost_usd ,b.calc_status ,b.flag - ,make_date(mseq.yr + 2021,mseq.cal,m.odom) order_date - ,od.sspr || ' - ' || to_char(make_date(mseq.yr + 2021,mseq.cal,m.odom),'Mon') order_month + ,make_date(mseq.yr + 2022,mseq.cal,m.odom) order_date + ,od.sspr || ' - ' || to_char(make_date(mseq.yr + 2022,mseq.cal,m.odom),'Mon') order_month ,od.ssyr order_season - ,make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag request_date - ,rd.sspr || ' - ' ||to_char(make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag,'Mon') request_month + ,make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag request_date + ,rd.sspr || ' - ' ||to_char(make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag,'Mon') request_month ,rd.ssyr request_season - ,make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag + slag ship_date - ,sd.sspr || ' - ' || to_char(make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag + slag,'Mon') ship_month + ,make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag + slag ship_date + ,sd.sspr || ' - ' || to_char(make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag + slag,'Mon') ship_month ,sd.ssyr ship_season ,'replace_version' "version" ,'replace_source'||' volume' iter @@ -347,11 +347,11 @@ FROM LEFT OUTER JOIN mseq ON mseq.m = closest.m LEFT OUTER JOIN gld od ON - make_date(mseq.yr + 2021,mseq.cal,m.odom) BETWEEN od.sdat AND od.edat + make_date(mseq.yr + 2022,mseq.cal,m.odom) BETWEEN od.sdat AND od.edat LEFT OUTER JOIN gld rd ON - make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag BETWEEN rd.sdat AND rd.edat + make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag BETWEEN rd.sdat AND rd.edat LEFT OUTER JOIN gld sd ON - make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat + make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat WHERE m._month = (SELECT _month FROM closest) ) @@ -520,4 +520,4 @@ FROM ,tag ,comment ) -SELECT json_agg(row_to_json(insagg)) x from insagg \ No newline at end of file +SELECT json_agg(row_to_json(insagg)) x from insagg diff --git a/route_sql/adj_totals.sql b/route_sql/adj_totals.sql index c822ed6..2cdbe2b 100644 --- a/route_sql/adj_totals.sql +++ b/route_sql/adj_totals.sql @@ -19,7 +19,7 @@ FROM LEFT OUTER JOIN rlarp.osm_log ON id = logid WHERE - order_season = 2021 + order_season = 2022 GROUP BY director ,quota_rep_descr @@ -51,4 +51,4 @@ GROUP BY ) ORDER BY director - ,quota_rep_descr \ No newline at end of file + ,quota_rep_descr diff --git a/route_sql/new_basket.sql b/route_sql/new_basket.sql index 29671b0..37f1c77 100644 --- a/route_sql/new_basket.sql +++ b/route_sql/new_basket.sql @@ -250,13 +250,13 @@ SELECT ,substring(jr.part_descr,1,8) part_group ,mxm.qty*mxm.momix*jr.mix units ,mxm.amount*mxm.momix*jr.mix value_usd --assume that target dollars are USD - ,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) order_date + ,make_date(mxm.yr + 2022,mxm.cal,mxm.odom) order_date ,od.sortmo order_month ,od.ssyr order_season - ,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag request_date + ,make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag request_date ,rd.sortmo request_month ,rd.ssyr request_season - ,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag + slag ship_date + ,make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag + slag ship_date ,sd.sortmo ship_month ,sd.ssyr ship_season ,jr.mix @@ -266,11 +266,11 @@ SELECT JOIN LATERAL json_to_record(ae.e) as jr(part_descr text, bill_cust_descr text, ship_cust_descr text, mix numeric) ON true CROSS JOIN mxm LEFT OUTER JOIN gld od ON - od.drange @> make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + od.drange @> make_date(mxm.yr + 2022,mxm.cal,mxm.odom) LEFT OUTER JOIN gld rd ON - rd.drange @> (make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag) + rd.drange @> (make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag) LEFT OUTER JOIN gld sd ON - sd.drange @> (make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag + slag) + sd.drange @> (make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag + slag) ) --SELECT * FROM basemix ,log AS ( @@ -517,4 +517,4 @@ FROM ,tag ,comment ) -SELECT json_agg(row_to_json(insagg)) x from insagg \ No newline at end of file +SELECT json_agg(row_to_json(insagg)) x from insagg diff --git a/route_sql/scale_vupd_sales.sql b/route_sql/scale_vupd_sales.sql index baf5655..1ad0b7d 100644 --- a/route_sql/scale_vupd_sales.sql +++ b/route_sql/scale_vupd_sales.sql @@ -88,7 +88,7 @@ target AS (select target_vol vincr, target_prc pincr) WHERE -----------------scenario---------------------------- where_clause - AND ship_season = 2021 + AND ship_season = 2022 -----------------additional params------------------- AND CASE (SELECT flag FROM flagv) WHEN 'scale all' THEN true