Compare commits

..

No commits in common. "787cc9452ff7a92f20da583b4b12aaa9c302c000" and "60ace348b867a76aa38a169fe96c79491164c8a5" have entirely different histories.

2 changed files with 9 additions and 11 deletions

View File

@ -51,4 +51,3 @@ Things to Demo
* product swap out
* pivot re-org
* don't use filters
* assumes all changes target USD

View File

@ -17,8 +17,7 @@ target AS (select $$replace_request$$::json def)
,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,'FM00') SSPR
,to_char(CASE WHEN EXTRACT(MONTH FROM N1ED01) >= 6 THEN EXTRACT(MONTH FROM N1ED01) -5 ELSE EXTRACT(MONTH FROM N1ED01) +7 END,'FM00') || ' - '|| TO_CHAR(n1ed01,'FMMon') SORTMO
,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
@ -236,15 +235,15 @@ SELECT
,jr.part_descr
,substring(jr.part_descr,1,8) part_group
,mxm.qty*mxm.momix*jr.mix units
,mxm.amount*mxm.momix*jr.mix value_usd --assume that target dollars are USD
,mxm.amount*mxm.momix*jr.mix value_loc
,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) order_date
,od.sortmo order_month
,to_char(make_date(mxm.yr + 2021,mxm.cal,mxm.odom),'Mon') order_month
,od.ssyr order_season
,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag request_date
,rd.sortmo request_month
,to_char(make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag,'Mon') request_month
,rd.ssyr request_season
,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag + slag ship_date
,sd.sortmo ship_month
,to_char(make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag + slag,'Mon') ship_month
,sd.ssyr ship_season
,jr.mix
FROM
@ -316,10 +315,10 @@ SELECT
,copr.curr c_currency --master data
,cx.rate c_rate --master data
,b.units
,b.value_usd / rx.rate --b.value is denominated in USD, need to apply currency to get to local
,b.value_usd value_usd --b.value is already denominated in usd
,b.value_loc
,b.value_loc * rx.rate value_usd
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units cost_loc
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units*cx.rate cost_usd
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units*cx.rate cost_loc
,'CLOSED' calc_status
,'SHIPMENT' flag
,b.order_date