first stab at pushing pool into forecast table

This commit is contained in:
pt 2020-02-21 01:22:32 -05:00
parent 5c04f7c913
commit ab72f94775
2 changed files with 129 additions and 1 deletions

112
build/convert_pool.sql Normal file
View File

@ -0,0 +1,112 @@
DELETE FROM rlarp.osmf_dev WHERE iter IN ('adj price','adj volume');
INSERT INTO
rlarp.osmf_dev
SELECT
null::int4,
null::int4,
null::int4,
null::int4,
null::int4,
null::int4,
null::int4,
null::int4,
order_date,
request_date,
null::date,
null::date,
ship_date,
null::text,
null::text,
fspr,
null::numeric,
null::numeric,
null::numeric,
null::numeric,
null::numeric,
null::numeric,
null::jsonb,
null::text,
plnt,
promo,
null::text,
terms,
null::text,
null::text,
null::text,
rtrim(substring(bill_cust_descr,1,8)),
null::text,
null::text,
null::text,
rtrim(substring(ship_cust_descr,1,8)),
null::text,
null::text,
dsm,
billto_group,
shipto_group,
null::text,
chan,
chan,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
part,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::text,
null::numeric,
null::numeric,
null::text,
fs_line,
r_currency,
r_rate,
c_currency,
c_rate,
units,
value_loc,
null::numeric,
null::numeric,
null::numeric,
null::numeric,
cost_loc,
null::numeric,
null::numeric,
calc_status,
flag,
order_date,
order_season,
request_date,
request_season,
ship_date,
ship_season,
version,
iter
FROM
rlarp.osm_pool
WHERE
iter IN ('adj price','adj volume');

View File

@ -6,6 +6,11 @@ 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
,remit_to = c.bvcomp
,ACCOUNT = CASE BVADR6 WHEN '' THEN BVNAME ELSE BVADR6 END
FROM
LGDAT.CUST C
WHERE
@ -14,6 +19,10 @@ WHERE
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------------------------------------
@ -24,6 +33,9 @@ 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
FROM
LGDAT.CUST C
WHERE
@ -32,6 +44,9 @@ WHERE
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------------------------------------
@ -44,7 +59,8 @@ FROM
LGDAT.CUST C
WHERE
C.BVCUST = O.BILL_CUST
AND CASE BVADR6 WHEN '' THEN BVNAME ELSE BVADR6 END <> COALESCE(O.ACCOUNT,'');
AND coalesce(account,'') <> CASE BVADR6 WHEN '' THEN BVNAME ELSE BVADR6 END;
----------------------------SET SHIPTO GROUP------------------------------------