Processing Overdue Loans
Our application should be regularly checking if a loan is overdue and if so, charge the appropriate fee and send the reminder e-mail to the member. This means that we need a scheduling process to do this. We also need to store the last time the overdue fee was charged so we can check whether we need to charge another fee. Therefore, we need to do the following:
- Define a new calculated attribute of the Loan object called
OverdueFeeChargedOnof theDatetype - Add “Overdue fee” rule to the Loan object that will react to the change of the
OverdueFeeChargedOnattribute:IF Loan.OverdueFeeChargedOn WAS CHANGED THEN CREATE Fee WITH Fee.Member=Loan.Member, Fee.Amount=1.00, Fee.Description='Loan overdue fee for '+Loan.Item.Title
- Define the process “ProcessOverdueLoans” with the following actions (note that we will cover reminder e-mails and letters later).
FIND Loan WHERE Loan.Status='Current' AND Loan.DueDate<CURRENT_DATE AND (Loan.OverdueFeeChargedOn IS UNDEFINED OR DAY_DIFFERENCE(Loan.OverdueFeeChargedOn, CURRENT_DATE) > 6) Loan.OverdueFeeChargedOn=CURRENT_DATE
- Define a new scheduling rule that invokes the
ProcessOverdueLoansprocess on a daily basis at 03:00