build dates

This commit is contained in:
Trowbridge 2019-03-21 12:11:20 -04:00
parent 24188768f1
commit 2fc146ae5d

View File

@ -176,18 +176,18 @@ SELECT
,0::numeric(11,0) "fgent#" ,0::numeric(11,0) "fgent#"
,0::numeric(9,0) "diinv#" ,0::numeric(9,0) "diinv#"
,0::numeric(3,0) "dilin#" ,0::numeric(3,0) "dilin#"
,null::text promo --history date mix ,null::text promo --history
,null::text return_reas ,null::text return_reas
,null::tex terms ,null::text terms
,''::text custpo ,''::text custpo
,'I' dhincr ,'I' dhincr
,null::numeric diext ,null::numeric diext
,null::numeric ditdis ,null::numeric ditdis
,null::date dcodatdate mix ,null::date dcodat
,null::date ddqdatdate mix ,null::date ddqdat
,null::date dcmdatdate mix ,null::date dcmdat
,null::date dhidatdate mix ,null::date dhidat
,null::text fsprdate mix ,null::text fspr
,remit_to ,remit_to
,bill_class ,bill_class
,bill_cust ,bill_cust
@ -237,9 +237,9 @@ SELECT
,0::numeric fb_val_loc_pl ,0::numeric fb_val_loc_pl
,calc_status ,calc_status
,flag ,flag
,null::date orderdate --history date mix ,null::date orderdate --history
,null::date requestdate --history date mix ,null::date requestdate --history
,null::date shipdate --history date mix ,null::date shipdate --history
,null::date adj_orderdate --history ,null::date adj_orderdate --history
,null::date adj_requestdate --history ,null::date adj_requestdate --history
,null::date adj_shipdate --history ,null::date adj_shipdate --history
@ -323,69 +323,6 @@ SELECT
,quota_rep_descr ,quota_rep_descr
,director_descr ,director_descr
) )
,custmix AS (
SELECT
remit_to
,bill_class
,bill_cust
,bill_rep
,bill_terr
,ship_class
,ship_cust
,ship_rep
,ship_terr
,quota_rep
,account
,shipgrp
,geo
,chan
,orig_ctry
,orig_prov
,orig_post
,dest_ctry
,dest_prov
,dest_post
,r_currency
,r_rate
--fcpool columns
,bill_cust_descr
,billto_group
,ship_cust_descr
,shipto_group
,(SELECT (regexp_match(def->>'newpart','(.*) - '::text))[1] FROM target) part_descr
,sum(coalesce(fb_val_loc * r_rate,0))/(SELECT sum(fb_val_loc * r_rate) FROM basemix) mix
FROM
basemix
GROUP BY
remit_to
,bill_class
,bill_cust
,bill_rep
,bill_terr
,ship_class
,ship_cust
,ship_rep
,ship_terr
,quota_rep
,account
,shipgrp
,geo
,chan
,orig_ctry
,orig_prov
,orig_post
,dest_ctry
,dest_prov
,dest_post
,r_currency
,r_rate
--fcpool columns
,bill_cust_descr
,billto_group
,ship_cust_descr
,shipto_group
,(SELECT (regexp_match(def->>'newpart','(.*) - '::text))[1] FROM target)
)
SELECT SELECT
b.plnt --master data b.plnt --master data
,b."ddord#" ,b."ddord#"
@ -394,18 +331,18 @@ SELECT
,b."fgent#" ,b."fgent#"
,b."diinv#" ,b."diinv#"
,b."dilin#" ,b."dilin#"
,b.promo --history date mix ,b.promo --history
,b.return_reas ,b.return_reas
,b.terms --history cust mix ,b.terms --history cust mix
,b.custpo ,b.custpo
,b.dhincr ,b.dhincr
,b.diext ,b.diext
,b.ditdis ,b.ditdis
,b.dcodatdate mix ,b.dcodat
,b.ddqdatdate mix ,b.ddqdat
,b.dcmdatdate mix ,b.dcmdat
,b.dhidatdate mix ,b.dhidat
,b.fsprdate mix ,b.fspr
,b.remit_to --master data ,b.remit_to --master data
,b.bill_class --master data ,b.bill_class --master data
,b.bill_cust --history cust mix ,b.bill_cust --history cust mix
@ -455,23 +392,23 @@ SELECT
,b.fb_val_loc_pl ,b.fb_val_loc_pl
,b.calc_status ,b.calc_status
,b.flag ,b.flag
,make_date(mseq.yr + 2020,mseq.cal,m.odom) orderdate ,make_date(mxm.yr + 2020,mxm.cal,mxm.odom) orderdate
,make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag requestdate ,make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag requestdate
,make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag shipdate ,make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag + slag shipdate
,make_date(mseq.yr + 2020,mseq.cal,m.odom) adj_orderdate ,make_date(mxm.yr + 2020,mxm.cal,mxm.odom) adj_orderdate
,make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag adj_requestdate ,make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag adj_requestdate
,make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag adj_shipdate ,make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag + slag adj_shipdate
,'replace_version' "version" ,'replace_version' "version"
,'replace_source'||' volume' iter ,'replace_source'||' volume' iter
-----------------------ui columns-------------------------------- -----------------------ui columns--------------------------------
,'replace_iterdet' iterdet ,'replace_iterdet' iterdet
,$$replace_iterdef$$::jsonb iterdef ,$${"replace_iterdef":""}$$::json iterdef
,od.ssyr order_season ,od.ssyr order_season
,to_char(make_date(mseq.yr + 2020,mseq.cal,m.odom),'Mon') order_month ,to_char(make_date(mxm.yr + 2020,mxm.cal,mxm.odom),'Mon') order_month
,sd.ssyr ship_season ,sd.ssyr ship_season
,to_char(make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag,'Mon') ship_month ,to_char(make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag + slag,'Mon') ship_month
,rd.ssyr request_season ,rd.ssyr request_season
,to_char(make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag,'Mon') request_month ,to_char(make_date(mxm.yr + 2020,mxm.cal,mxm.odom) + rlag,'Mon') request_month
,b.part_descr ,b.part_descr
,b.part_family ,b.part_family
,b.part_group ,b.part_group