diff --git a/route_sql/addmonth_vupd.sql b/route_sql/addmonth_vupd.sql index 4adc460..e4c0559 100644 --- a/route_sql/addmonth_vupd.sql +++ b/route_sql/addmonth_vupd.sql @@ -6,10 +6,10 @@ target AS (select target_volume vincr, target_price pincr) ,testv AS ( SELECT sum(units) tot - ,sum(units) FILTER (WHERE iter = 'copy') base + ,sum(units) FILTER (WHERE iter IN ('copy','plan','diff')) base ,COALESCE(sum(units) FILTER (WHERE module = 'new basket'),0) newpart ,sum(value_loc *r_rate) totsales - ,sum(value_loc *r_rate) FILTER (WHERE iter = 'copy') basesales + ,sum(value_loc *r_rate) FILTER (WHERE iter IN ('plan','diff','copy')) basesales ,COALESCE(sum(value_loc *r_rate) FILTER (WHERE module = 'new basket'),0) newpartsales FROM rlarp.osm_pool @@ -114,7 +114,7 @@ target AS (select target_volume vincr, target_price pincr) -----------------additional params------------------- AND CASE (SELECT flag FROM flagv) WHEN 'scale all' THEN true - WHEN 'scale copy' THEN iter = 'copy' + WHEN 'scale copy' THEN iter IN ('plan','diff','copy') WHEN 'scale new part' THEN module = 'new basket' END AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments @@ -236,7 +236,7 @@ SELECT -----------------additional params------------------- AND CASE (SELECT flag FROM flagv) WHEN 'scale all' THEN true - WHEN 'scale copy' THEN iter = 'copy' + WHEN 'scale copy' THEN iter IN ('plan','diff','copy') WHEN 'scale new part' THEN module = 'new basket' END AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments diff --git a/route_sql/adj_totals.sql b/route_sql/adj_totals.sql index 2cdbe2b..d855fd4 100644 --- a/route_sql/adj_totals.sql +++ b/route_sql/adj_totals.sql @@ -10,10 +10,10 @@ SELECT ,doc->>'stamp' stamp ,logid ,tag - ,sum(value_usd) FILTER (WHERE iter = 'copy') sales - ,sum(cost_usd) FILTER (WHERE iter = 'copy') scogs - ,sum(value_usd) FILTER (WHERE iter <> 'copy') sales_adj - ,sum(cost_usd) FILTER (WHERE iter <> 'copy') scogs_adj + ,sum(value_usd) FILTER (WHERE iter IN ('plan','diff','copy')) sales + ,sum(cost_usd) FILTER (WHERE iter IN ('plan','diff','copy')) scogs + ,sum(value_usd) FILTER (WHERE iter <> NOT IN ('plan','diff','copy')) sales_adj + ,sum(cost_usd) FILTER (WHERE iter <> NOT IN ('plan','diff','copy')) scogs_adj FROM rlarp.osm_pool LEFT OUTER JOIN rlarp.osm_log ON diff --git a/route_sql/scale_vd.sql b/route_sql/scale_vd.sql index 75b5a57..472b4c9 100644 --- a/route_sql/scale_vd.sql +++ b/route_sql/scale_vd.sql @@ -3,7 +3,7 @@ target AS (select incr_qty qincr) ,testv AS ( SELECT sum(units) tot - ,sum(units) FILTER (WHERE iter = 'copy') base + ,sum(units) FILTER (WHERE iter IN ('copy','plan','diff')) base ,sum(units) FILTER (WHERE module = 'new basket') newpart FROM rlarp.osm_pool p @@ -91,13 +91,13 @@ target AS (select incr_qty qincr) -----------------additional params------------------- AND CASE (SELECT flag FROM flagv) WHEN 'scale all' THEN true - WHEN 'scale copy' THEN iter = 'copy' + WHEN 'scale copy' THEN iter IN ('copy','plan','diff') WHEN 'scale new part' THEN module = 'new basket' END AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments AND order_date <= ship_date GROUP BY - fspr + fspr ,plnt ---master data ,promo --history date mix ,terms diff --git a/route_sql/scale_vupd.sql b/route_sql/scale_vupd.sql index a21f43e..add0d58 100644 --- a/route_sql/scale_vupd.sql +++ b/route_sql/scale_vupd.sql @@ -3,7 +3,7 @@ target AS (select target_vol vincr, target_prc pincr) ,testv AS ( SELECT sum(units) tot - ,sum(units) FILTER (WHERE iter = 'copy') base + ,sum(units) FILTER (WHERE iter IN ('plan','diff','copy')) base ,sum(units) FILTER (WHERE module = 'new basket') newpart FROM rlarp.osm_pool @@ -91,7 +91,7 @@ target AS (select target_vol vincr, target_prc pincr) -----------------additional params------------------- AND CASE (SELECT flag FROM flagv) WHEN 'scale all' THEN true - WHEN 'scale copy' THEN iter = 'copy' + WHEN 'scale copy' THEN iter IN ('plan','diff','copy') WHEN 'scale new part' THEN module = 'new basket' END AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments diff --git a/route_sql/scale_vupd_sales.sql b/route_sql/scale_vupd_sales.sql index aa7b1f0..cd5ea20 100644 --- a/route_sql/scale_vupd_sales.sql +++ b/route_sql/scale_vupd_sales.sql @@ -3,7 +3,7 @@ target AS (select target_vol vincr, target_prc pincr) ,testv AS ( SELECT sum(units) tot - ,sum(units) FILTER (WHERE iter = 'copy') base + ,sum(units) FILTER (WHERE iter IN ('plan','diff','copy')) base ,sum(units) FILTER (WHERE module = 'new basket') newpart FROM rlarp.osm_pool @@ -92,7 +92,7 @@ target AS (select target_vol vincr, target_prc pincr) -----------------additional params------------------- AND CASE (SELECT flag FROM flagv) WHEN 'scale all' THEN true - WHEN 'scale copy' THEN iter = 'copy' + WHEN 'scale copy' THEN iter IN ('plan','diff','copy') WHEN 'scale new part' THEN module = 'new basket' END AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments diff --git a/route_sql/scenario_package.sql b/route_sql/scenario_package.sql index c6dddde..c11a503 100644 --- a/route_sql/scenario_package.sql +++ b/route_sql/scenario_package.sql @@ -95,12 +95,12 @@ GROUP BY order_month ,seq ,SUM(units) FILTER (WHERE order_season = 2021) "2021 qty" - ,SUM(units) FILTER (WHERE order_season = 2022 AND iter IN ('copy','short ship','bad_ship')) "2022 base qty" - ,SUM(units) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship')) "2022 adj qty" + ,SUM(units) FILTER (WHERE order_season = 2022 AND iter IN ('copy','short ship','bad_ship','plan')) "2022 base qty" + ,SUM(units) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship','diff','pf')) "2022 adj qty" ,SUM(units) FILTER (WHERE order_season = 2022) "2022 tot qty" ,SUM(value_usd) FILTER (WHERE order_season = 2021) "2021 value_usd" - ,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter IN ('copy','short ship','bad_ship')) "2022 base value_usd" - ,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship')) "2022 adj value_usd" + ,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter IN ('copy','short ship','bad_ship','plan')) "2022 base value_usd" + ,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship','diff','pf')) "2022 adj value_usd" ,SUM(value_usd) FILTER (WHERE order_season = 2022) "2022 tot value_usd" FROM months