Sei sulla pagina 1di 2

CAST(

CASE
WHEN "Core"."Dim - Payment Due Date"."Period Number" < 13

THEN FILTER(IFNULL("Core"."Fact - Fins - AR Transaction"
."AR Outstanding Amount",0) USING ( "Core"."Dim - AR Document Details"."AR
Type Desc" <> 'Letter Of Credit' AND "Core"."Dim - Payment Due Date"."Period Nu
mber" = "Core"."Fact - Fins - AR Transaction"."Period Number +
3" AND "Core"."Dim - Payment Due Date"."Year" = CAST(CAST(VALUEOF(CURRENT_FISCA
L_YEAR) AS INT) AS VARCHAR(10))))
WHEN "Core"."Dim - Payment Due Date"."Period Number" = 11
THEN FILTER(IFNULL("Core"."Fact - Fins - AR Transaction"
."AR Outstanding Amount",0) USING ( "Core"."Dim - AR Document Details"."AR
Type Desc" <> 'Letter Of Credit' AND "Core"."Dim - Payment Due Date"."Period Nu
mber" = 1 AND "Core"."Dim - Payment Due Date"."Year"
= "Core"."Fact - Fins - AR Transaction"."Year + 1"))
WHEN "Core"."Dim - Payment Due Date"."Period Number" = 12
THEN FILTER(IFNULL("Core"."Fact - Fins - AR Transaction"
."AR Outstanding Amount",0) USING ( "Core"."Dim - AR Document Details"."AR
Type Desc" <> 'Letter Of Credit' AND "Core"."Dim - Payment Due Date"."Period Nu
mber" = 2 AND "Core"."Dim - Payment Due Date"."Year"
= "Core"."Fact - Fins - AR Transaction"."Year + 1"))
WHEN "Core"."Dim - Payment Due Date"."Period Number" = 13
THEN FILTER(IFNULL("Core"."Fact - Fins - AR Transaction"
."AR Outstanding Amount",0) USING ( "Core"."Dim - AR Document Details"."AR
Type Desc" <> 'Letter Of Credit' AND "Core"."Dim - Payment Due Date"."Period Nu
mber" = 3 AND "Core"."Dim - Payment Due Date"."Year"
= "Core"."Fact - Fins - AR Transaction"."Year + 1"))
ELSE 0
END
AS DOUBLE)
--------------------------------------------------------------------------------
------------------------------------------------------------------------
SELECT W_MCAL_PERIOD_D.MCAL_PERIOD, W_MCAL_PERIOD_D.MCAL_PERIOD_START_DT, W_MCAL
_PERIOD_D.MCAL_PERIOD_END_DT
FROM W_DAY_D, W_MCAL_PERIOD_D, W_AR_XACT_F
WHERE W_DAY_D.ROW_WID = W_AR_XACT_F.PAYMENT_DUE_DT_WID
AND W_DAY_D.ROW_WID = W_MCAL_PERIOD_D.MCAL_PERIOD_START_DT_WID
AND MCAL_PERIOD > 0
SELECT W_MCAL_PERIOD_D.MCAL_PERIOD,
CASE WHEN "W_STATUS_D"."STATUS_CODE" ='OPEN' AND
( "W_XACT_TYPE_D"."W_XACT_TYPE_CODE"= 'ORIGINAL' AND "W_XACT_TYPE_D"."W_X
ACT_SUBTYPE_CODE" IN ('INVOICE','CR MEMO','DR MEMO'))
THEN "W_AR_XACT_F"."AR_REMAINING_DOC_AMT" * "W_AR_XACT_F"."GLOBAL1_EXCHAN
GE_RATE" END AS AR_OUTSTAN_AMOUNT,
CAST(CASE WHEN MCAL.MCAL_PERIOD < 13
THEN FILTER(IFNULL(CASE WHEN "W_STATUS_D"."STATUS_CODE" ='OPEN' AND
( "W_XACT_TYPE_D"."W_XACT_TYPE_CODE"= 'ORIGINAL' AND "W_XACT_TYPE_D"."W_X
ACT_SUBTYPE_CODE" IN ('INVOICE','CR MEMO','DR MEMO'))
THEN "W_AR_XACT_F"."AR_REMAINING_DOC_AMT" * "W_AR_XACT_F"."GLOBAL1_EXCHAN
GE_RATE" END,0) USING ("W_XACT_TYPE_D".XACT_TYPE_DESC
<> 'Letter Of Credit')) ELSE 0 END AS DOUBLE)
FROM W_STATUS_D, W_XACT_TYPE_D, W_DAY_D, W_MCAL_PERIOD_D, W_AR_XACT_F
WHERE W_STATUS_D.ROW_WID = W_AR_XACT_F.DOC_STATUS_WID
AND W_XACT_TYPE_D.ROW_WID = W_AR_XACT_F.DOC_TYPE_WID
AND W_DAY_D.ROW_WID = W_AR_XACT_F.PAYMENT_DUE_DT_WID
AND W_DAY_D.ROW_WID = W_MCAL_PERIOD_D.MCAL_PERIOD_START_DT_WID
--------------------------------------------------------------------------------
-----------------------------------------------------------------------
CASE WHEN "W_STATUS_D"."STATUS_CODE" ='OPEN' AND
( "W_XACT_TYPE_D"."W_XACT_TYPE_CODE"= 'ORIGINAL' AND "W_XACT_TYPE_D"."W_X
ACT_SUBTYPE_CODE" IN ('INVOICE','CR MEMO','DR MEMO'))
THEN "W_AR_XACT_F"."AR_REMAINING_DOC_AMT" * "W_AR_XACT_F"."GLOBAL1_EXCHAN
GE_RATE" END AS AR_OUTSTAN_AMOUNT
CAST(CASE WHEN MCAL.MCAL_PERIOD < 13
THEN FILTER(IF IS NULL(CASE WHEN "W_STATUS_D"."STATUS_CODE" ='OPEN' AND
( "W_XACT_TYPE_D"."W_XACT_TYPE_CODE"= 'ORIGINAL' AND "W_XACT_TYPE_D"."W_X
ACT_SUBTYPE_CODE" IN ('INVOICE','CR MEMO','DR MEMO'))
THEN "W_AR_XACT_F"."AR_REMAINING_DOC_AMT" * "W_AR_XACT_F"."GLOBAL1_EXCHAN
GE_RATE" END,0) USING ("W_XACT_TYPE_D".XACT_TYPE_DESC
<> 'Letter Of Credit')) ELSE 0 END AS DOUBLE)
CASE WHEN W_MCAL_PERIOD_D.MCAL_PERIOD < 13
THEN (CASE WHEN "W_STATUS_D"."STATUS_CODE" ='OPEN' AND
( "W_XACT_TYPE_D"."W_XACT_TYPE_CODE"= 'ORIGINAL' AND "W_XACT_TYPE_D"."W_X
ACT_SUBTYPE_CODE" IN ('INVOICE','CR MEMO','DR MEMO'))
THEN "W_AR_XACT_F"."AR_REMAINING_DOC_AMT" * "W_AR_XACT_F"."GLOBAL1_EXCHAN
GE_RATE" ELSE 0 END) ELSE 0 END AS LOC_CM