/*Description: Loan Repayment formula for UAE legislation*/ /*XXETS_SALARY_ADVANCE*/ Inputs are Loan_Type (text) ,SALARY_ADVANCE_AMOUNT ,Monthly_Repayment ,Number_of_Installments ,Approved_On (Date) ,Repayment_Start_Date (Date) ,Hold_Amortization (text) DEFAULT FOR Hold_Amortization IS 'N' DEFAULT FOR Monthly_Repayment IS 0 DEFAULT FOR Number_of_Installments IS 0 Default for PAY_PROC_PERIOD_END_DATE_DP is '4712/12/31 00:00:00' (DATE) Default for AE_PERSON_START_DATE is '0001/01/01 00:00:00' (DATE) Default for Approved_On is '0001/01/01 00:00:00' (DATE) Loan_Amount =SALARY_ADVANCE_AMOUNT l_outstanding_loan = Loan_Amount- SALARY_ADVANCE_REPAID_ASG_ITD l_outstanding_installments=Number_of_Installments- SALARY_ADVANCE_INSTALLMENTS_PAID_ASG_ITD If PAY_PROC_PERIOD_END_DATE_DP >= Repayment_Start_Date THEN ( IF l_outstanding_loan=0 THEN ( message1 = AE_GET_MESSAGE('PER','HR_377419_AE_LOAN_CLOSED') return Message1 ) ELSE ( IF Hold_Amortization ='N' THEN ( IF Monthly_Repayment=0 THEN ( IF Number_of_Installments=0 THEN ( message2=AE_GET_MESSAGE('PER', 'HR_377420_AE_LOAN_DET_NOT_SET') return Message2 ) ELSE ( If l_outstanding_installments <= 0 THEN (message2 = AE_GET_MESSAGE('PER','HR_377421_AE_LOAN_INCORRECT') RETURN message2) Monthly_Repayment=l_outstanding_loan/ABS(NUMBER_OF_INSTALLMENTS- SALARY_ADVANCE_INSTALLMENTS_PAID_ASG_ITD)) ) ELSE (NUMBER_OF_INSTALLMENTS = ROUND_UP(l_outstanding_loan/ Monthly_Repayment) + SALARY_ADVANCE_INSTALLMENTS_PAID_ASG_ITD) IF Monthly_Repayment > (l_outstanding_loan) THEN l_payment = l_outstanding_loan ELSE l_payment = Monthly_Repayment IF NET_ASG_RUN < l_payment THEN l_payment = NET_ASG_RUN IF NET_ASG_RUN >= l_payment THEN ( l_outstanding_loan = l_outstanding_loan - l_payment l_processed_flag = 1 l_loan_type = Loan_Type IF l_outstanding_loan > 0 THEN (return l_loan_type, l_payment, Monthly_Repayment, Number_of_Installments, l_processed_flag, l_outstanding_loan) ELSE (message1 = AE_GET_MESSAGE('PER','HR_377419_AE_LOAN_CLOSED') STOP_FLAG='Y' return message1, l_loan_type, l_payment, Monthly_Repayment, Number_of_Installments, l_processed_flag, l_outstanding_loan, STOP_FLAG) ) ELSE (l_loan_type = Loan_Type message1 = AE_GET_MESSAGE('PER','HR_377422_AE_LOAN_INSUFFICIENT') return message1, l_loan_type, l_outstanding_loan ) ) ELSE (l_loan_type = Loan_Type message1 = AE_GET_MESSAGE('PER','HR_377423_AE_LOAN_HOLD') return message1, l_loan_type, l_outstanding_loan) ) ) /*======================== End Program =======================*/