FUNCTION generate_amortization_sched_fn (i_transaction_id IN XXHLS.XXHLS_LOAN_APPLICATION.TRANSACTION_ID%TYPE,
i_schedule_type IN VARCHAR2)
RETURN XXHLS_TYPES_PKG.t_ref_cursor
IS
UNDEFINED_SCHEDULE_TYPE EXCEPTION;
l_loan_amount NUMBER DEFAULT 0;
l_principal NUMBER DEFAULT 0;
l_interest_rate NUMBER DEFAULT 0;
l_glip_monthly_premium NUMBER DEFAULT 0;
l_gdip_monthly_premium NUMBER DEFAULT 0;
BEGIN
SELECT LOAN_AMOUNT, PAYMENT_AMOUNT, INTEREST_RATE
INTO l_loan_amount, l_principal, l_interest_rate
FROM XXHLS.XXHLS_LOAN_APPLICATION
WHERE TRANSACTION_ID = i_transaction_id;
SELECT PREMIUM_AMOUNT
INTO l_glip_monthly_premium
FROM XXHLS.XXHLS_INSURANCE_DETAILS
WHERE TRANSACTION_ID = i_transaction_id
AND RATE_TYPE = 'GLIP';
SELECT PREMIUM_AMOUNT
INTO l_gdip_monthly_premium
FROM XXHLS.XXHLS_INSURANCE_DETAILS
WHERE TRANSACTION_ID = i_transaction_id
AND RATE_TYPE = 'GDIP';
IF i_schedule_type = 'MO1' THEN
RETURN generate_month_amort_sched_fn (l_loan_amount,
l_principal,
l_interest_rate,
l_glip_monthly_premium,
l_gdip_monthly_premium);
ELSIF i_schedule_type = 'MO2' THEN
RETURN NULL;
ELSIF i_schedule_type = 'YRA' THEN
RETURN NULL;
ELSE
RAISE UNDEFINED_SCHEDULE_TYPE;
END IF;
RETURN NULL;
EXCEPTION
WHEN UNDEFINED_SCHEDULE_TYPE THEN
DBMS_OUTPUT.PUT_LINE('undefined amortization schedule type');
RETURN NULL;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
RETURN NULL;
END generate_amortization_sched_fn;
i_schedule_type IN VARCHAR2)
RETURN XXHLS_TYPES_PKG.t_ref_cursor
IS
UNDEFINED_SCHEDULE_TYPE EXCEPTION;
l_loan_amount NUMBER DEFAULT 0;
l_principal NUMBER DEFAULT 0;
l_interest_rate NUMBER DEFAULT 0;
l_glip_monthly_premium NUMBER DEFAULT 0;
l_gdip_monthly_premium NUMBER DEFAULT 0;
BEGIN
SELECT LOAN_AMOUNT, PAYMENT_AMOUNT, INTEREST_RATE
INTO l_loan_amount, l_principal, l_interest_rate
FROM XXHLS.XXHLS_LOAN_APPLICATION
WHERE TRANSACTION_ID = i_transaction_id;
SELECT PREMIUM_AMOUNT
INTO l_glip_monthly_premium
FROM XXHLS.XXHLS_INSURANCE_DETAILS
WHERE TRANSACTION_ID = i_transaction_id
AND RATE_TYPE = 'GLIP';
SELECT PREMIUM_AMOUNT
INTO l_gdip_monthly_premium
FROM XXHLS.XXHLS_INSURANCE_DETAILS
WHERE TRANSACTION_ID = i_transaction_id
AND RATE_TYPE = 'GDIP';
IF i_schedule_type = 'MO1' THEN
RETURN generate_month_amort_sched_fn (l_loan_amount,
l_principal,
l_interest_rate,
l_glip_monthly_premium,
l_gdip_monthly_premium);
ELSIF i_schedule_type = 'MO2' THEN
RETURN NULL;
ELSIF i_schedule_type = 'YRA' THEN
RETURN NULL;
ELSE
RAISE UNDEFINED_SCHEDULE_TYPE;
END IF;
RETURN NULL;
EXCEPTION
WHEN UNDEFINED_SCHEDULE_TYPE THEN
DBMS_OUTPUT.PUT_LINE('undefined amortization schedule type');
RETURN NULL;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
RETURN NULL;
END generate_amortization_sched_fn;
No comments:
Post a Comment