FUNCTION PA_GET_PMT_AMT(RATE IN NUMBER,
AMT IN NUMBER,
PAYMENTS IN NUMBER) RETURN NUMBER IS
V_RATE NUMBER := RATE;
V_AMT NUMBER := AMT;
V_NOM NUMBER := PAYMENTS;
P_RATE_PM NUMBER := 0;
P_NRATE NUMBER := 0;
P_VALR NUMBER := 0;
P_NVALR NUMBER := 0;
P_NVAL NUMBER := 0;
P_RETAMT NUMBER := 0;
BEGIN
-- SELECT DECODE(V_RATE,0,1,V_RATE)INTO V_RATE FROM DUAL;
IF V_RATE > 0 THEN
--Applied Ason 27-sep-2016
P_RATE_PM := (+V_RATE / 12) / 100; --+1;
P_NRATE := (+P_RATE_PM) + 1;
P_VALR := ROUND(POWER(+P_NRATE, (V_NOM * -1)), 6);
P_NVALR := 1 - P_VALR;
P_NVAL := P_NVALR / P_RATE_PM;
P_RETAMT := ROUND(V_AMT / P_NVAL, 0);
ELSE
P_RETAMT := ROUND(V_AMT / V_NOM, 0);
END IF;
RETURN(P_RETAMT);
END PA_GET_PMT_AMT;
SELECT PA_GET_PMT_AMT(12.5,50000,36) FROM DUAL;
AMT IN NUMBER,
PAYMENTS IN NUMBER) RETURN NUMBER IS
V_RATE NUMBER := RATE;
V_AMT NUMBER := AMT;
V_NOM NUMBER := PAYMENTS;
P_RATE_PM NUMBER := 0;
P_NRATE NUMBER := 0;
P_VALR NUMBER := 0;
P_NVALR NUMBER := 0;
P_NVAL NUMBER := 0;
P_RETAMT NUMBER := 0;
BEGIN
-- SELECT DECODE(V_RATE,0,1,V_RATE)INTO V_RATE FROM DUAL;
IF V_RATE > 0 THEN
--Applied Ason 27-sep-2016
P_RATE_PM := (+V_RATE / 12) / 100; --+1;
P_NRATE := (+P_RATE_PM) + 1;
P_VALR := ROUND(POWER(+P_NRATE, (V_NOM * -1)), 6);
P_NVALR := 1 - P_VALR;
P_NVAL := P_NVALR / P_RATE_PM;
P_RETAMT := ROUND(V_AMT / P_NVAL, 0);
ELSE
P_RETAMT := ROUND(V_AMT / V_NOM, 0);
END IF;
RETURN(P_RETAMT);
END PA_GET_PMT_AMT;
SELECT PA_GET_PMT_AMT(12.5,50000,36) FROM DUAL;
No comments:
Post a Comment