From c4f3abd733992b1336b7d0d274bb713276738e32 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Sun, 4 Apr 2021 23:18:18 -0400 Subject: [PATCH] increment dates --- build/build_forecast.sql | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/build/build_forecast.sql b/build/build_forecast.sql index 365ec45..ded2084 100644 --- a/build/build_forecast.sql +++ b/build/build_forecast.sql @@ -145,11 +145,11 @@ gld AS ( WHERE ( --base period orders booked.... - o.odate BETWEEN '2019-06-01' AND '2020-02-29' + o.odate BETWEEN '2020-06-01' AND '2021-04-11' --...or any open orders currently booked before cutoff.... - OR (o.calc_status IN ('OPEN','BACKORDER') and o.odate < '2020-03-01') + OR (o.calc_status IN ('OPEN','BACKORDER') and o.odate < '2021-04-11') --...or anything that shipped in that period - OR o.fspr BETWEEN '2001' AND '2009' + OR o.fspr BETWEEN '2101' AND '2011' ) AND fs_line = '41010' AND calc_status <> 'CANCELED' @@ -289,11 +289,11 @@ gld AS ( LEFT OUTER JOIN gld ss ON greatest(least(o.sdate,gld.edat),gld.sdat) + interval '1 year' BETWEEN ss.sdat AND ss.edat WHERE - o.odate BETWEEN '2019-03-01' AND '2019-05-31' + o.odate BETWEEN '2020-04-12' AND '2020-05-31' AND fs_line = '41010' AND calc_status <> 'CANCELED' ------exclude actuals for now and use forecast to get the plug for the rest of the year - AND false + --AND false GROUP BY o.fspr ,plnt @@ -432,6 +432,8 @@ gld AS ( o.odate BETWEEN '2020-03-01' AND '2020-05-31' AND fs_line = '41010' AND calc_status <> 'CANCELED' + ------dont pull forecast for a baseline this time around-- + AND false GROUP BY o.fspr ,plnt @@ -555,14 +557,14 @@ SELECT ,o.rseas + 1 --incremented ,o.sdate + interval '1 year' --incremented ,o.sseas + 1 --incremented - ,'b21' "version" + ,'b22' "version" ,'copy' iter FROM baseline o LEFT OUTER JOIN gld ON o.sdate + interval '1 year' BETWEEN gld.sdat and gld.edat WHERE - o.odate + interval '1 year' >= '2020-06-01' + o.odate + interval '1 year' >= '2021-06-01' ) INSERT INTO rlarp.osmf_dev SELECT * FROM incr @@ -573,4 +575,4 @@ SELECT * FROM baseline; --UPDATE rlarp.osmfs SET iter = 'short ship' WHERE calc_status = 'CLOSED' AND flag = 'REMAINDER'; ---identify goofy ship dates: causes disconnect with sales when splicing in a forecast that has this problem------------------- ---UPDATE rlarp.osmfs SET iter = 'bad date' WHERE adj_shipdate < adj_orderdate; \ No newline at end of file +--UPDATE rlarp.osmfs SET iter = 'bad date' WHERE adj_shipdate < adj_orderdate;