update conver_pool to match convert all equivalent, add fspr and quota rep

This commit is contained in:
Paul Trowbridge 2021-04-06 14:14:04 -04:00
parent 4acee798d2
commit 59c32d8619
2 changed files with 81 additions and 77 deletions

View File

@ -286,81 +286,84 @@ WHERE
---------------------------SET QUOTA REP--------------------------------------- ---------------------------SET QUOTA REP---------------------------------------
UPDATE UPDATE
RLARP.OSMFS_DEV S rlarp.osmfs_dev s
SET SET
DSM = CR.QUOTA_REP dsm = cr.quota_rep
FROM 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.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 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;
-------------------set fiscal period--------------------------------------
UPDATE
rlarp.osmfs_dev f
SET
fspr = gld.fspr
FROM
(
SELECT
N1COMP COMP
,N1CCYY FSYRq
,KPMAXP PERDS
,N1FSPP PERD
,to_char(N1FSYP,'FM0000') FSPR
,N1SD01 SDAT
,N1ED01 EDAT
,to_char(N1ED01,'yymm') CAPR
,N1ED01 - N1SD01 +1 NDAYS
,CASE WHEN EXTRACT(MONTH FROM N1ED01) >= 6 THEN EXTRACT(YEAR FROM N1ED01) + 1 ELSE EXTRACT(YEAR FROM N1ED01) END SSYR
,to_char(CASE WHEN EXTRACT(MONTH FROM N1ED01) >= 6 THEN EXTRACT(MONTH FROM N1ED01) -5 ELSE EXTRACT(MONTH FROM N1ED01) +7 END,'00') SSPR
FROM
LGDAT.GLDATREF
INNER JOIN LGDAT.GLDATE ON
KPCOMP = N1COMP AND
KPCCYY = N1CCYY
WHERE
N1COMP = 93
--AND DIGITS(N1FSYP) = '1901'
) gld
WHERE
f.sdate BETWEEN gld.sdat AND gld.edat
AND coalesce(f.fspr,'') <> gld.fspr;
UPDATE UPDATE
rlarp.osmfS_dev rlarp.osmfS_dev
SET SET

View File

@ -111,33 +111,6 @@ SELECT
FROM FROM
rlarp.osm_pool; rlarp.osm_pool;
UPDATE
RLARP.OSMFS_DEV O
SET
COLC = M.COLC
,COLGRP = M.COLGRP
,COLTIER = M.COLTIER
,COLSTAT = M.COLSTAT
,SIZC = M.SIZC
,PCKG = M.PACKAGE
,KIT = M.KIT
,BRND = M.BRANDING
,MAJG = M.MAJG
,MING = M.MING
,MAJS = M.MAJS
,MINS = M.MINS
,GLDC = M.GLCD
,GLEC = M.GLEC
,HARM = M.HARM
,CLSS = M.CLSS
,BRAND = M.BRAND
,ASSC = M.ASSC
,LBS = CASE M.NWUN WHEN 'KG' THEN 2.2046 ELSE 1 END*M.NWHT
,UNTI = M.UNTI
FROM
RLARP.ITEMM M
WHERE
M.ITEM = O.PART;
WITH WITH
plist AS ( plist AS (
@ -420,6 +393,34 @@ SET
WHERE WHERE
c_currency = 'US'; c_currency = 'US';
UPDATE
RLARP.OSMFS_DEV O
SET
COLC = M.COLC
,COLGRP = M.COLGRP
,COLTIER = M.COLTIER
,COLSTAT = M.COLSTAT
,SIZC = M.SIZC
,PCKG = M.PACKAGE
,KIT = M.KIT
,BRND = M.BRANDING
,MAJG = M.MAJG
,MING = M.MING
,MAJS = M.MAJS
,MINS = M.MINS
,GLDC = M.GLCD
,GLEC = M.GLEC
,HARM = M.HARM
,CLSS = M.CLSS
,BRAND = M.BRAND
,ASSC = M.ASSC
,LBS = CASE M.NWUN WHEN 'KG' THEN 2.2046 ELSE 1 END*M.NWHT
,UNTI = M.UNTI
FROM
RLARP.ITEMM M
WHERE
M.ITEM = O.PART;
--DELETE FROM rlarp.osmf_dev WHERE iter IN ('adj price','adj volume'); --DELETE FROM rlarp.osmf_dev WHERE iter IN ('adj price','adj volume');
--INSERT INTO rlarp.osmf_dev SELECT * FROM rlarp.osmfs_dev; --INSERT INTO rlarp.osmf_dev SELECT * FROM rlarp.osmfs_dev;