From 94ae5e192c449e238dfa31f47a5efa4301830f4c Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 13 Apr 2021 16:01:00 -0400 Subject: [PATCH 1/3] isolate short an over shipments --- over_under_ship.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 over_under_ship.sql 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; From ab7af8d2ed75a7dd9e159185cfc45e373e63da72 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 13 Apr 2021 16:10:04 -0400 Subject: [PATCH 2/3] redefine segment --- build/merge_actuals_pool.sql | 3 ++- build/snap_itemm_pool.sql | 3 ++- route_sql/new_basket.sql | 3 ++- route_sql/swap_cust.sql | 3 ++- route_sql/swap_post.sql | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) 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/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..3f66b70 100644 --- a/route_sql/swap_post.sql +++ b/route_sql/swap_post.sql @@ -17,7 +17,8 @@ target AS (SELECT $$swap_doc$$::jsonb swap) FROM ( VALUES - ('1CU','Retail'), + ('1CU','Sustainable'), + ('1SU','Sustainable'), ('1GR','Greenhouse'), ('1NU','Nursery'), ('1RE','Retail'), From fee1b9202f533f37b78c68709781f4e9a7abf7db Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 13 Apr 2021 16:15:11 -0400 Subject: [PATCH 3/3] trim white space off part numbers --- route_sql/swap_post.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/route_sql/swap_post.sql b/route_sql/swap_post.sql index 3f66b70..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