SELECT CH.VENDOR_SETID , CH.VENDOR_ID , R.TO_CUR , ' ' , ' ' , CH.CURRENCY_CD , SUM(%Coalesce(CL.AMT_LINE_RELEASED , 0)) , SUM(%Round(%DecMult(%DecDiv((%COALESCE(CL.AMT_LINE_RELEASED , 0)), R.RATE_DIV), R.RATE_MULT), C.DECIMAL_POSITIONS)) FROM PS_CNTRCT_HDR CH LEFT OUTER JOIN PS_CS_CNT_SUMLN_VW CL ON CL.SETID = CH.SETID AND CL.CNTRCT_ID = CH.CNTRCT_ID , PS_RT_RATE_TBL R , PS_CURRENCY_CD_TBL C WHERE CH.VERSION_STATUS = 'C' AND CH.CNTRCT_PROC_OPT IN ('AP', 'RPOV') AND R.RT_RATE_INDEX = ( SELECT RT_RATE_INDEX FROM PS_RT_INDEX_TBL WHERE DEFAULT_INDEX = 'Y') AND R.TERM = 0 AND R.FROM_CUR = CH.CURRENCY_CD AND R.RT_TYPE = CH.RT_TYPE AND R.EFFDT = ( SELECT MAX(R_ED.EFFDT) FROM PS_RT_RATE_TBL R_ED WHERE R.RT_RATE_INDEX = R_ED.RT_RATE_INDEX AND R.TERM = R_ED.TERM AND R.FROM_CUR = R_ED.FROM_CUR AND R.TO_CUR = R_ED.TO_CUR AND R.RT_TYPE = R_ED.RT_TYPE AND R_ED.EFFDT <= %CurrentDateIn) AND C.CURRENCY_CD = R.TO_CUR AND C.EFFDT = ( SELECT MAX(C2.EFFDT) FROM PS_CURRENCY_CD_TBL C2 WHERE C2.CURRENCY_CD = C.CURRENCY_CD AND C2.EFFDT <= %CurrentDateIn) GROUP BY CH.VENDOR_SETID, CH.VENDOR_ID, R.TO_CUR, CH.CURRENCY_CD
|