Source:
public static void testUpdateLoanRepaymentsSchedule() throws MambuApiException { String methodName = new Object() {}.getClass().getEnclosingMethod().getName(); System.out.println("\nIn " + methodName); if (repayments == null) { System.out.println("No repayments to update"); return; } System.out.println("Account " + LOAN_ACCOUNT_ID + " has " + repayments.size() + " repayments"); List<Repayment> modifiedRepayments = new ArrayList<Repayment>(); final long fiveDays = 5 * 24 * 60 * 60 * 1000L; int minusOrPlusOne = -1; final int maxRepaymentsToUpdate = 4; int i = 0; Date now = new Date(); for (Repayment repayment : repayments) { if (repayment.wasFullyPaid()) { continue; } Date dueDate = repayment.getDueDate(); if (dueDate.before(now)) { continue; } repayment.setDueDate(new Date(dueDate.getTime() + fiveDays)); Money changeAmount = new Money(5.00); Money newAmount = (minusOrPlusOne == -1) ? repayment.getPrincipalDue().subtract(changeAmount) : repayment.getPrincipalDue().add(changeAmount); repayment.setPrincipalDue(newAmount); modifiedRepayments.add(repayment); minusOrPlusOne = -minusOrPlusOne; i++; if (i >= maxRepaymentsToUpdate) { break; } } LoansService loansService = MambuAPIFactory.getLoanService(); String productTypeKey = demoLoanAccount.getProductTypeKey(); LoanProductType loanProductType = loansService.getLoanProduct(productTypeKey).getLoanProductType(); if (loanProductType.equals(LoanProductType.REVOLVING_CREDIT)) { Repayment repayment = new Repayment(); repayment.setDueDate(new Date(now.getTime() + fiveDays)); modifiedRepayments.add(repayment); } submitEditedRepaymentsToMambu(modifiedRepayments); }

Target:
public static void testUpdateLoanRepaymentsSchedule() throws MambuApiException { String methodName = new Object() {}.getClass().getEnclosingMethod().getName(); System.out.println("\nIn " + methodName); if (repayments == null) { System.out.println("No repayments to update"); return; } System.out.println("Account " + LOAN_ACCOUNT_ID + " has " + repayments.size() + " repayments"); List<Repayment> modifiedRepayments = new ArrayList<Repayment>(); final long fiveDays = 5 * 24 * 60 * 60 * 1000L; int minusOrPlusOne = -1; final int maxRepaymentsToUpdate = 4; int i = 0; Date now = new Date(); for (Repayment repayment : repayments) { if (repayment.wasFullyPaid()) { continue; } Date dueDate = repayment.getDueDate(); if (dueDate.before(now)) { continue; } repayment.setDueDate(new Date(dueDate.getTime() + fiveDays)); Money changeAmount = new Money(5.00); Money newAmount = (minusOrPlusOne == -1) ? repayment.getPrincipalDue().subtract(changeAmount) : repayment.getPrincipalDue().add(changeAmount); repayment.setPrincipalDue(newAmount); modifiedRepayments.add(repayment); minusOrPlusOne = -minusOrPlusOne; i++; if (i >= maxRepaymentsToUpdate) { break; } } LoansService loansService = MambuAPIFactory.getLoanService(); String productTypeKey = demoLoanAccount.getProductTypeKey(); LoanProductType loanProductType = loansService.getLoanProduct(productTypeKey).getLoanProductType(); if (loanProductType.equals(LoanProductType.REVOLVING_CREDIT) || loanProductType.equals(LoanProductType.DYNAMIC_TERM_LOAN)) { Repayment repayment = new Repayment(); repayment.setDueDate(new Date(now.getTime() + fiveDays)); modifiedRepayments.add(repayment); } submitEditedRepaymentsToMambu(modifiedRepayments); }