update quota_rep logic to mirror current sales matrix, create readme, adjust rebuild script

This commit is contained in:
Paul Trowbridge 2021-04-08 11:42:09 -04:00
parent ce91851d48
commit 037070ed1e
3 changed files with 36 additions and 50 deletions

13
build/readme.md Normal file
View File

@ -0,0 +1,13 @@
Build A New Forecast
------------------------------------------------------------------------------------------------------------------
* overwrite osmf: review dates and execute build_forecase.sql
* the product and customer attributes are wiped, they will need to be snapped (itemm must come first)
1. snap_itemm.sql
2. snap_customer.sql
3. snap_cost_current.sql
4. snap_fx.sql (if necessary)
5. offline/last_price.sql (if necessary)
* build the pool for the more limited UI data set: build_pool.sql
* copy the pool to osmfs_dev from inclusion in the osm_stack and reporting: convert_pool_all.sql
* refresh osm_stack_refresh() to integrate into reporting

View File

@ -1,6 +1,8 @@
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/build_forecast.sql psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/build_forecast.sql
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/snap_cost_current.sql
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/fx.sql
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/customer.sql
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/snap_itemm.sql psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/snap_itemm.sql
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/build_pool.sql psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/snap_cost_current.sql
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/snap_fx.sql
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/customer.sql
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/build_pool.sql
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/convert_pool_all.sql
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -c "CALL rlarp.osm_stack_refresh();"

View File

@ -144,66 +144,37 @@ FROM
SELECT DISTINCT SELECT DISTINCT
VERSION, VERSION,
COALESCE(GLEC,'') GLEC, COALESCE(GLEC,'') GLEC,
COALESCE(MING,'') MING, MING,
BILL_CUST, BILL_CUST,
SHIP_CUST, SHIP_CUST,
------------quota rep column-------------- ------------quota rep column--------------
RTRIM( CASE WHEN COALESCE(ming,'') = 'B52' THEN 'PW' ELSE
--retail items go to currep, or if null go to 90005 --if the gl expense code is 1RE use the retail rep assigned to the bill-to customer if available
CASE WHEN S.GLEC IN ('1RE','1CU') THEN CASE WHEN COALESCE(glec,'') = '1RE' AND COALESCE(cu.currep,'') <> '' THEN
CASE WHEN BVCTRY = 'CAN' THEN cu.currep
--Rachel Bowman --default logic
'50300'
ELSE
--select customers go to select reps
CASE ACCOUNT
------Alecia Latini-------------------------------
WHEN 'DO IT BEST' THEN '90006'
WHEN 'ACE HARDWARE' THEN '90006'
WHEN 'ALDI' THEN '90006'
WHEN 'AMAZON.COM' THEN '90006'
WHEN 'GARDEN RIDGE CORP' THEN '90006' --AKA "At Home"
WHEN 'TRUE VALUE' THEN '90006'
WHEN 'WAYFAIR' THEN '90006'
WHEN 'GRIFFIN' THEN '90006'
WHEN 'WAL-MART' THEN '90006'
------Tony Landino--------------------------------
WHEN 'THE HOME DEPOT' THEN '50802'
WHEN 'FRED MEYER' THEN '50802'
WHEN 'MENARDS' THEN '50802'
WHEN 'KROGER' THEN '50802'
WHEN 'OCEAN STATE JOBBERS' THEN '50802'
WHEN 'AURORA WHOLESALE' THEN '50802'
WHEN 'LEON KORRAL' THEN '50802'
--all other retail goes to Doran Marable-----------
ELSE '50200'
END
END
--minor group b52 goes to dedicated rep
ELSE ELSE
CASE WHEN MING = 'B52' THEN CASE SUBSTR(bill_class,2,3)
'PW' WHEN 'DIS' THEN
--gdir, ndir go to bill-to rep ship_rep
ELSE
CASE WHEN BILL_CLASS IN ('GDIR','NDIR') THEN
BILL_REP
ELSE ELSE
SHIP_REP bill_rep
END
END END
END END
) QUOTA_REP END QUOTA_REP
FROM FROM
RLARP.OSMF_DEV S RLARP.OSMF_DEV S
LEFT OUTER JOIN LGDAT.CUST ON LEFT OUTER JOIN LGDAT.CUST ON
BVCUST = BILL_CUST BVCUST = BILL_CUST
LEFT OUTER JOIN lgpgm.usrcust cu ON
cu.cucust = s.bill_cust
WHERE WHERE
COALESCE(GLEC,'') IS NOT NULL version = 'ACTUALS'
) CR ) CR
WHERE WHERE
CR.VERSION = S.VERSION CR.VERSION = S.VERSION
AND CR.GLEC = COALESCE(S.GLEC,'') AND CR.GLEC = COALESCE(S.GLEC,'')
AND CR.MING = COALESCE(S.MING,'') AND CR.MING = S.MING
AND CR.BILL_CUST = S.BILL_CUST AND CR.BILL_CUST = S.BILL_CUST
AND CR.SHIP_CUST = S.SHIP_CUST AND CR.SHIP_CUST = S.SHIP_CUST
AND COALESCE(S.DSM,'') <> CR.QUOTA_REP; AND COALESCE(S.DSM,'') <> CR.QUOTA_REP;