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
#$PG -f ./build_stage.sql;
$PG -f ./build_rolling.sql;
#$PG -f ./build_rolling.sql;
$PG -f ./snap_itemm.sql;
$PG -f ./snap_cost_current.sql;
$PG -f ./snap_customer.sql;

View File

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

View File

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

View File

@ -1,28 +1,29 @@
UPDATE
RLARP.OSMF_DEV O
rlarp.osmf o
SET
STYC = M.STLC
,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
stlc = m.stlc
,colc = m.colc
,colgrp = m.colgrp
,coltier = m.coltier
,colstat = m.colstat
,sizc = m.sizc
,uomp = m.uomp
,suffix = m.suffix
,accs_ps = m.accs_ps
,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
"CMS.CUSLG".itemm m
WHERE
M.ITEM = O.PART
m.item = o.part