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, 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 ELSE
--select customers go to select reps CASE SUBSTR(bill_class,2,3)
CASE ACCOUNT WHEN 'DIS' THEN
------Alecia Latini------------------------------- ship_rep
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 bill_rep
'PW'
--gdir, ndir go to bill-to rep
ELSE
CASE WHEN BILL_CLASS IN ('GDIR','NDIR') THEN
BILL_REP
ELSE
SHIP_REP
END END
END END
END END QUOTA_REP
) QUOTA_REP
FROM FROM
RLARP.OSMFS_DEV S RLARP.OSMFS_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 COALESCE(GLEC,'') IS NOT NULL
) CR ) CR

View File

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