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:

  1. Define a new calculated attribute of the Loan object called OverdueFeeChargedOn of the Date type
  2. Add “Overdue fee” rule to the Loan object that will react to the change of the OverdueFeeChargedOn attribute:
    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 
  3. 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 
  4. Define a new scheduling rule that invokes the ProcessOverdueLoans process on a daily basis at 03:00