Compare commits
2 Commits
60ace348b8
...
787cc9452f
Author | SHA1 | Date | |
---|---|---|---|
|
787cc9452f | ||
|
879319b889 |
@ -51,3 +51,4 @@ Things to Demo
|
||||
* product swap out
|
||||
* pivot re-org
|
||||
* don't use filters
|
||||
* assumes all changes target USD
|
@ -17,7 +17,8 @@ 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,'00') SSPR
|
||||
,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
|
||||
FROM
|
||||
LGDAT.GLDATREF
|
||||
INNER JOIN LGDAT.GLDATE ON
|
||||
@ -235,15 +236,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_loc
|
||||
,mxm.amount*mxm.momix*jr.mix value_usd --assume that target dollars are USD
|
||||
,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) order_date
|
||||
,to_char(make_date(mxm.yr + 2021,mxm.cal,mxm.odom),'Mon') order_month
|
||||
,od.sortmo order_month
|
||||
,od.ssyr order_season
|
||||
,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag request_date
|
||||
,to_char(make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag,'Mon') request_month
|
||||
,rd.sortmo request_month
|
||||
,rd.ssyr request_season
|
||||
,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag + slag ship_date
|
||||
,to_char(make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag + slag,'Mon') ship_month
|
||||
,sd.sortmo ship_month
|
||||
,sd.ssyr ship_season
|
||||
,jr.mix
|
||||
FROM
|
||||
@ -315,10 +316,10 @@ SELECT
|
||||
,copr.curr c_currency --master data
|
||||
,cx.rate c_rate --master data
|
||||
,b.units
|
||||
,b.value_loc
|
||||
,b.value_loc * rx.rate value_usd
|
||||
,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
|
||||
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units cost_loc
|
||||
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units*cx.rate cost_loc
|
||||
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units*cx.rate cost_usd
|
||||
,'CLOSED' calc_status
|
||||
,'SHIPMENT' flag
|
||||
,b.order_date
|
||||
|
Loading…
Reference in New Issue
Block a user