Source:
private static void testEditPrincipalPaymentAmountForActiveRevolvingCreditLoans() throws MambuApiException { methodName = new Object() {}.getClass().getEnclosingMethod().getName(); System.out.println("\nIn " + methodName); LoanProductType loanProductType = demoProduct.getLoanProductType(); LoansService loanService = MambuAPIFactory.getLoanService(); AccountState accountState = loanService.getLoanAccount(NEW_LOAN_ACCOUNT_ID).getAccountState(); if (loanProductType.equals(LoanProductType.REVOLVING_CREDIT) && (accountState.equals(AccountState.ACTIVE) || (accountState.equals(AccountState.ACTIVE_IN_ARREARS)))) { LoanAccount newLoanAccount = new LoanAccount(); newLoanAccount.setId(NEW_LOAN_ACCOUNT_ID); PrincipalPaymentAccountSettings paymentSettings = newAccount.getPrincipalPaymentSettings(); paymentSettings.setAmount(paymentSettings.getAmount().add(new BigDecimal(extraAmount))); newLoanAccount.setPrincipalPaymentSettings(paymentSettings); newLoanAccount.setLoanAmount(newAccount.getLoanAmount().add(new BigDecimal(extraAmount))); newLoanAccount.setPeriodicPayment((BigDecimal) null); newLoanAccount.setRepaymentInstallments(null); newLoanAccount.setGracePeriod(null); newLoanAccount.setPrincipalRepaymentInterval(null); newLoanAccount.setArrearsTolerancePeriod(null); boolean patchResult = loanService.patchLoanAccount(newLoanAccount); System.out.println("The loan's principal payment amount was edited for the loan account " + NEW_LOAN_ACCOUNT_ID + ". Status: " + patchResult); } else { System.out.println( "The loan account does not meet the prerequisites, therefore its principal payment amount will not be updated."); } }

Target:
private static void testEditPrincipalPaymentAmountForActiveRevolvingCreditLoans() throws MambuApiException { methodName = new Object() {}.getClass().getEnclosingMethod().getName(); System.out.println("\nIn " + methodName); LoanProductType loanProductType = demoProduct.getLoanProductType(); LoansService loanService = MambuAPIFactory.getLoanService(); AccountState accountState = loanService.getLoanAccount(NEW_LOAN_ACCOUNT_ID).getAccountState(); PrincipalPaymentAccountSettings paymentSettings = newAccount.getPrincipalPaymentSettings(); if (loanProductType.equals(LoanProductType.REVOLVING_CREDIT) && PrincipalPaymentMethod.FLAT.equals(paymentSettings.getPrincipalPaymentMethod()) && (accountState.equals(AccountState.ACTIVE) || accountState.equals(AccountState.ACTIVE_IN_ARREARS))) { LoanAccount newLoanAccount = new LoanAccount(); newLoanAccount.setId(NEW_LOAN_ACCOUNT_ID); paymentSettings.setAmount(paymentSettings.getAmount().add(new BigDecimal(extraAmount))); newLoanAccount.setPrincipalPaymentSettings(paymentSettings); newLoanAccount.setLoanAmount(newAccount.getLoanAmount().add(new BigDecimal(extraAmount))); newLoanAccount.setPeriodicPayment((BigDecimal) null); newLoanAccount.setRepaymentInstallments(null); newLoanAccount.setGracePeriod(null); newLoanAccount.setPrincipalRepaymentInterval(null); newLoanAccount.setArrearsTolerancePeriod(null); boolean patchResult = loanService.patchLoanAccount(newLoanAccount); System.out.println("The loan's principal payment amount was edited for the loan account " + NEW_LOAN_ACCOUNT_ID + ". Status: " + patchResult); } else { System.out.println( "The loan account does not meet the prerequisites, therefore its principal payment amount will not be updated."); } }