update quota rep logic

This commit is contained in:
Paul Trowbridge 2020-06-16 15:53:02 -04:00
parent 98eff757c0
commit cf82925eca
2 changed files with 30 additions and 86 deletions

View File

@ -326,55 +326,27 @@ FROM
BILL_CUST,
SHIP_CUST,
------------quota rep column--------------
RTRIM(
--retail items go to currep, or if null go to 90005
CASE WHEN S.GLEC IN ('1RE','1CU') THEN
CASE WHEN BVCTRY = 'CAN' THEN
--Rachel Bowman
'50300'
CASE WHEN COALESCE(ming,'') = 'B52' THEN 'PW' ELSE
--if the gl expense code is 1RE use the retail rep assigned to the bill-to customer if available
CASE WHEN COALESCE(glec,'') = '1RE' AND COALESCE(cu.currep,'') <> '' THEN
cu.currep
--default logic
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
CASE SUBSTR(bill_class,2,3)
WHEN 'DIS' THEN
ship_rep
ELSE
CASE WHEN MING = 'B52' THEN
'PW'
--gdir, ndir go to bill-to rep
ELSE
CASE WHEN BILL_CLASS IN ('GDIR','NDIR') THEN
BILL_REP
ELSE
SHIP_REP
bill_rep
END
END
END
) QUOTA_REP
END QUOTA_REP
FROM
RLARP.OSMFS_DEV S
LEFT OUTER JOIN LGDAT.CUST ON
BVCUST = BILL_CUST
LEFT OUTER JOIN lgpgm.usrcust cu ON
cu.cucust = s.bill_cust
WHERE
COALESCE(GLEC,'') IS NOT NULL
) CR

View File

@ -28,60 +28,32 @@ SET
WHEN 'NAT' THEN 'RMN'
ELSE CASE SUBSTRING(s.bvclas,1,1) WHEN 'R' THEN 'RDI' ELSE 'DIR' END
END,
dsm = RTRIM(
--retail items go to currep, or if null go to 90005
CASE WHEN o.segm IN ('Retail') THEN
CASE WHEN b.bvctry = 'CAN' THEN
--Rachel Bowman
'50300'
ELSE
--select customers go to select reps
CASE CASE b.bvadr6 WHEN '' THEN b.bvname ELSE b.bvadr6 END
------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
CASE WHEN SUBSTRING(o.ming_descr,1,3) = 'B52' THEN
'PW'
--gdir, ndir go to bill-to rep
ELSE
CASE WHEN b.bvclas IN ('GDIR','NDIR') THEN
b.bvsalm
dsm =
------------quota rep column--------------
CASE WHEN COALESCE(substring(ming_descr,1,3),'') = 'B52' THEN 'PW' ELSE
--if the gl expense code is 1RE use the retail rep assigned to the bill-to customer if available
CASE WHEN COALESCE(o.segm,'') = 'Retail' AND COALESCE(cu.currep,'') <> '' THEN
cu.currep
--default logic
ELSE
CASE SUBSTR(b.bvclas,2,3)
WHEN 'DIS' THEN
s.bvsalm
ELSE
b.bvsalm
END
END
END
),
END,
billto_group = CASE b.bvadr6 WHEN '' THEN b.bvname ELSE b.bvadr6 END,
shipto_group = CASE s.bvadr6 WHEN '' THEN s.bvname ELSE s.bvadr6 END
FROM
lgdat.cust b,
lgdat.cust s
lgdat.cust s,
lgpgm.usrcust cu
WHERE
b.bvcust = rtrim(substring(o.bill_cust_descr,1,8))
AND s.bvcust = rtrim(substring(o.ship_cust_descr,1,8));
AND s.bvcust = rtrim(substring(o.ship_cust_descr,1,8))
AND cu.cucust = b.bvcust;
--BEGIN;
UPDATE