repoint snaps

This commit is contained in:
Paul Trowbridge 2023-03-01 16:07:36 -05:00
parent 7d901e7f42
commit e5db7372a1
4 changed files with 83 additions and 82 deletions

2
build/rebuild_script.sh Normal file → Executable file
View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
#$PG -f ./build_stage.sql; #$PG -f ./build_stage.sql;
$PG -f ./build_rolling.sql; #$PG -f ./build_rolling.sql;
$PG -f ./snap_itemm.sql; $PG -f ./snap_itemm.sql;
$PG -f ./snap_cost_current.sql; $PG -f ./snap_cost_current.sql;
$PG -f ./snap_customer.sql; $PG -f ./snap_customer.sql;

View File

@ -6,7 +6,7 @@ plist AS (
part part
,plnt ,plnt
FROM FROM
rlarp.osmf_dev rlarp.osmf
-----prevent a list of fake parts -----prevent a list of fake parts
INNER JOIN lgdat.stka ON INNER JOIN lgdat.stka ON
v6part = part v6part = part
@ -30,7 +30,7 @@ plist AS (
AND ir.y0plnt = p.plnt AND ir.y0plnt = p.plnt
) )
UPDATE UPDATE
rlarp.osmf_dev o rlarp.osmf o
SET SET
fb_cst_loc_cur = c.stdcost * o.fb_qty fb_cst_loc_cur = c.stdcost * o.fb_qty
FROM FROM
@ -40,4 +40,4 @@ WHERE
AND c.plnt = o.plnt; AND c.plnt = o.plnt;
--AND version = 'b21'; --AND version = 'b21';
commit; commit;

View File

@ -1,64 +1,64 @@
----------------------------SET BILL-TO REP------------------------------------ ----------------------------SET BILL-TO REP------------------------------------
UPDATE UPDATE
RLARP.OSMF_DEV S rlarp.osmf s
SET SET
BILL_REP = C.BVSALM bill_rep = c.bvsalm
,BILL_CLASS = C.BVCLAS ,bill_class = c.bvclas
,BILL_TERR = C.BVTERR ,bill_terr = c.bvterr
,BILL_CTRY = C.bvctry ,bill_ctry = c.bvctry
,bill_prov = C.bvprcd ,bill_prov = c.bvprcd
,bill_post = C.bvpost ,bill_post = c.bvpost
,remit_to = c.bvcomp ,remit_to = c.bvcomp
,ACCOUNT = CASE BVADR6 WHEN '' THEN BVNAME ELSE BVADR6 END ,account = CASE bvadr6 WHEN '' THEN bvname ELSE bvadr6 END
FROM FROM
LGDAT.CUST C lgdat.cust c
WHERE WHERE
C.BVCUST = S.BILL_CUST c.bvcust = s.bill_cust
AND ( AND (
COALESCE(S.BILL_REP,'') <> C.BVSALM COALESCE(s.bill_rep,'') <> c.bvsalm
OR COALESCE(S.BILL_CLASS,'') <> C.BVCLAS OR COALESCE(s.bill_class,'') <> c.bvclas
OR COALESCE(S.BILL_TERR,'') <> C.BVTERR OR COALESCE(s.bill_terr,'') <> c.bvterr
OR COALESCE(BILL_CTRY,'') <> C.bvctry OR COALESCE(bill_ctry,'') <> c.bvctry
OR COALESCE(bill_prov,'') <> C.bvprcd OR COALESCE(bill_prov,'') <> c.bvprcd
OR COALESCE(bill_post,'') <> C.bvpost OR COALESCE(bill_post,'') <> c.bvpost
OR COALESCE(remit_to,'') <> c.bvcomp::text OR COALESCE(remit_to,'') <> c.bvcomp::text
); );
----------------------------SET SHIP-TO REP------------------------------------ ----------------------------SET SHIP-TO REP------------------------------------
UPDATE UPDATE
RLARP.OSMF_DEV S rlarp.osmf s
SET SET
SHIP_REP = C.BVSALM ship_rep = c.bvsalm
,SHIP_CLASS = C.BVCLAS ,ship_class = c.bvclas
,SHIP_TERR = C.BVTERR ,ship_terr = c.bvterr
,dest_CTRY = C.bvctry ,dest_ctry = c.bvctry
,dest_prov = C.bvprcd ,dest_prov = c.bvprcd
,dest_post = C.bvpost ,dest_post = c.bvpost
FROM FROM
LGDAT.CUST C lgdat.cust c
WHERE WHERE
C.BVCUST = S.SHIP_CUST c.bvcust = s.ship_cust
AND ( AND (
COALESCE(S.SHIP_REP,'') <> C.BVSALM COALESCE(s.ship_rep,'') <> c.bvsalm
OR COALESCE(S.SHIP_CLASS,'') <> C.BVCLAS OR COALESCE(s.ship_class,'') <> c.bvclas
OR COALESCE(S.SHIP_TERR,'') <> C.BVTERR OR COALESCE(s.ship_terr,'') <> c.bvterr
OR COALESCE(dest_CTRY,'') <> C.bvctry OR COALESCE(dest_ctry,'') <> c.bvctry
OR COALESCE(dest_prov,'') <> C.bvprcd OR COALESCE(dest_prov,'') <> c.bvprcd
OR COALESCE(dest_post,'') <> C.bvpost OR COALESCE(dest_post,'') <> c.bvpost
); );
----------------------------SET BILLTO GROUP------------------------------------ ----------------------------SET BILLTO GROUP------------------------------------
UPDATE UPDATE
RLARP.OSMF_DEV O rlarp.osmf o
SET SET
ACCOUNT = CASE BVADR6 WHEN '' THEN BVNAME ELSE BVADR6 END ACCOUNT = CASE BVADR6 WHEN '' THEN BVNAME ELSE BVADR6 END
FROM FROM
LGDAT.CUST C lgdat.cust c
WHERE WHERE
C.BVCUST = O.BILL_CUST c.bvcust = o.bill_cust
AND coalesce(account,'') <> CASE BVADR6 WHEN '' THEN BVNAME ELSE BVADR6 END; AND coalesce(account,'') <> CASE BVADR6 WHEN '' THEN BVNAME ELSE BVADR6 END;
@ -66,13 +66,13 @@ WHERE
----------------------------SET SHIPTO GROUP------------------------------------ ----------------------------SET SHIPTO GROUP------------------------------------
UPDATE UPDATE
RLARP.OSMF_DEV O rlarp.osmf o
SET SET
SHIPGRP = CASE BVADR6 WHEN '' THEN BVNAME ELSE BVADR6 END SHIPGRP = CASE BVADR6 WHEN '' THEN BVNAME ELSE BVADR6 END
FROM FROM
LGDAT.CUST C lgdat.cust c
WHERE WHERE
C.BVCUST = O.SHIP_CUST c.bvcust = o.ship_cust
AND CASE BVADR6 WHEN '' THEN BVNAME ELSE BVADR6 END <> COALESCE(O.SHIPGRP,''); AND CASE BVADR6 WHEN '' THEN BVNAME ELSE BVADR6 END <> COALESCE(O.SHIPGRP,'');
@ -80,7 +80,7 @@ WHERE
UPDATE UPDATE
rlarp.osmF_dev rlarp.osmf
SET SET
CHAN = CASE SUBSTRING(BILL_CLASS,2,3) CHAN = CASE SUBSTRING(BILL_CLASS,2,3)
--if the bill to class is ditsributor, then it's either warehouse or drop --if the bill to class is ditsributor, then it's either warehouse or drop
@ -136,17 +136,17 @@ WHERE
UPDATE UPDATE
RLARP.OSMF_DEV S rlarp.osmf 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,
MING, ming,
BILL_CUST, bill_cust,
SHIP_CUST, ship_cust,
------------quota rep column-------------- ------------quota rep column--------------
CASE WHEN COALESCE(ming,'') = 'B52' THEN 'PW' ELSE 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 --if the gl expense code is 1RE use the retail rep assigned to the bill-to customer if available
@ -163,18 +163,18 @@ FROM
END END
END QUOTA_REP END QUOTA_REP
FROM FROM
RLARP.OSMF_DEV S rlarp.osmf 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 LEFT OUTER JOIN lgpgm.usrcust cu ON
cu.cucust = s.bill_cust cu.cucust = s.bill_cust
WHERE WHERE
version = 'ACTUALS' 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 = 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;

View File

@ -1,28 +1,29 @@
UPDATE UPDATE
RLARP.OSMF_DEV O rlarp.osmf o
SET SET
STYC = M.STLC stlc = m.stlc
,COLC = M.COLC ,colc = m.colc
,COLGRP = M.COLGRP ,colgrp = m.colgrp
,COLTIER = M.COLTIER ,coltier = m.coltier
,COLSTAT = M.COLSTAT ,colstat = m.colstat
,SIZC = M.SIZC ,sizc = m.sizc
,PCKG = M.PACKAGE ,uomp = m.uomp
,KIT = M.KIT ,suffix = m.suffix
,BRND = M.BRANDING ,accs_ps = m.accs_ps
,MAJG = M.MAJG ,brnd = m.branding
,MING = M.MING ,majg = m.majg
,MAJS = M.MAJS ,ming = m.ming
,MINS = M.MINS ,majs = m.majs
,GLDC = M.GLCD ,mins = m.mins
,GLEC = M.GLEC ,gldc = m.glcd
,HARM = M.HARM ,glec = m.glec
,CLSS = M.CLSS ,harm = m.harm
,BRAND = M.BRAND ,clss = m.clss
,ASSC = M.ASSC ,brand = m.brand
,LBS = CASE M.NWUN WHEN 'KG' THEN 2.2046 ELSE 1 END*M.NWHT ,assc = m.assc
,UNTI = M.UNTI ,lbs = CASE m.nwun WHEN 'KG' THEN 2.2046 ELSE 1 END*m.nwht
,unti = m.unti
FROM FROM
RLARP.ITEMM M "CMS.CUSLG".itemm m
WHERE WHERE
M.ITEM = O.PART m.item = o.part