diff --git a/routes/baseline/gen_baseline.sql b/routes/baseline/gen_baseline.sql index 46d030d..9bebc34 100644 --- a/routes/baseline/gen_baseline.sql +++ b/routes/baseline/gen_baseline.sql @@ -107,7 +107,7 @@ WHERE --base period orders booked.... $$||format('%I',_order_date)||$$ BETWEEN 'app_baseline_from_date'::date AND 'app_baseline_to_date'::date --...or any open orders currently booked before cutoff.... - OR ($$||format('%I',_order_status)||$$ IN ('app_openstatus_code') and $$||format('%I',_order_date)||$$ <= 'app_openorder_cutoff'::date) + OR ($$||format('%I',_order_status)||$$ IN (app_openstatus_code) and $$||format('%I',_order_date)||$$ <= 'app_openorder_cutoff'::date) --...or anything that shipped in that period OR ($$||format('%I',_ship_date)||$$ BETWEEN 'app_baseline_from_date'::date AND 'app_baseline_to_date'::date) ) @@ -130,7 +130,7 @@ $$ FROM fc.live o$$||E'\n'||_perd_joins||$$ WHERE - $$||_order_date||$$ BETWEEN 'app_plug_fromdate'::date AND 'app_plug_todate'::date + $$||format('%I',_order_date)||$$ BETWEEN 'app_plug_fromdate'::date AND 'app_plug_todate'::date --be sure to pre-exclude unwanted items, like canceled orders, non-gross sales, and short-ships $$ INTO @@ -158,8 +158,8 @@ SELECT FROM incr i WHERE - i.$$||_order_date||$$ >= 'app_first_forecast_date'::date$$||$$ - OR i.$$||_ship_date||$$ >= 'app_first_forecast_date'::date$$||$$ + i.$$||format('%I',_order_date)||$$ >= 'app_first_forecast_date'::date$$||$$ + OR i.$$||format('%I',_ship_date)||$$ >= 'app_first_forecast_date'::date$$||$$ RETURNING * ) SELECT COUNT(*) num_rows FROM ins$$