diff --git a/build/merge_actuals_pool.sql b/build/merge_actuals_pool.sql index fcf2be9..d57a96b 100644 --- a/build/merge_actuals_pool.sql +++ b/build/merge_actuals_pool.sql @@ -23,7 +23,8 @@ repc AS ( FROM ( VALUES - ('1CU','Retail'), + ('1SU','Sustainable'), + ('1CU','Sustainable'), ('1GR','Greenhouse'), ('1NU','Nursery'), ('1RE','Retail'), diff --git a/build/snap_itemm_pool.sql b/build/snap_itemm_pool.sql index 7ae21db..92723cb 100644 --- a/build/snap_itemm_pool.sql +++ b/build/snap_itemm_pool.sql @@ -8,7 +8,8 @@ SEG AS ( FROM ( VALUES - ('1CU','Retail'), + ('1SU','Sustainable'), + ('1CU','Sustainable'), ('1GR','Greenhouse'), ('1NU','Nursery'), ('1RE','Retail'), diff --git a/over_under_ship.sql b/over_under_ship.sql new file mode 100644 index 0000000..aec6a87 --- /dev/null +++ b/over_under_ship.sql @@ -0,0 +1,15 @@ +SELECT + calc_status, + flag, + sum(fb_val_loc * r_rate) filter (where fb_qty < 0) overship, + sum(fb_val_loc * r_rate) filter (where fb_qty > 0) undership +FROM + rlarp.osm_dev +WHERE + oseas = 2021 + AND version = 'ACTUALS' + AND calc_status = 'CLOSED' + AND flag = 'REMAINDER' +GROUP BY + calc_status, + flag; diff --git a/route_sql/new_basket.sql b/route_sql/new_basket.sql index 37f1c77..89c8553 100644 --- a/route_sql/new_basket.sql +++ b/route_sql/new_basket.sql @@ -53,7 +53,8 @@ target AS (select $$replace_request$$::json def) FROM ( VALUES - ('1CU','Retail'), + ('1SU','Sustainable'), + ('1CU','Sustainable'), ('1GR','Greenhouse'), ('1NU','Nursery'), ('1RE','Retail'), diff --git a/route_sql/swap_cust.sql b/route_sql/swap_cust.sql index 863c37e..56e2f65 100644 --- a/route_sql/swap_cust.sql +++ b/route_sql/swap_cust.sql @@ -37,7 +37,8 @@ target AS (SELECT $$swap_doc$$::jsonb swap) FROM ( VALUES - ('1CU','Retail'), + ('1SU','Sustainable'), + ('1CU','Sustainable'), ('1GR','Greenhouse'), ('1NU','Nursery'), ('1RE','Retail'), diff --git a/route_sql/swap_post.sql b/route_sql/swap_post.sql index 13bdc43..4e79d0b 100644 --- a/route_sql/swap_post.sql +++ b/route_sql/swap_post.sql @@ -2,7 +2,11 @@ WITH target AS (SELECT $$swap_doc$$::jsonb swap) ,pl AS ( SELECT - x.* + -----trim white space on CMS part numbers coming from spreadsheet master data---- + rtrim(x.original) AS original + ,sales + ,rtrim(x."replace") AS replace + ,rtrim(x.fit) fit FROM TARGET LEFT JOIN LATERAL jsonb_to_recordset(target.swap->'rows') AS x(original text, sales numeric, replace text, fit text)ON TRUE @@ -17,7 +21,8 @@ target AS (SELECT $$swap_doc$$::jsonb swap) FROM ( VALUES - ('1CU','Retail'), + ('1CU','Sustainable'), + ('1SU','Sustainable'), ('1GR','Greenhouse'), ('1NU','Nursery'), ('1RE','Retail'),