MIFOSX-1481 : changed the validation to allow writeoff on last repayment date

This commit is contained in:
Pramod Nuthakki
2015-01-16 15:11:35 +05:30
parent d5f0ae53f8
commit f438bc6f17
2 changed files with 53 additions and 2 deletions
@@ -3142,8 +3142,8 @@ public class Loan extends AbstractPersistable<Long> {
LocalDateTime createdDate = DateUtils.getLocalDateTimeOfTenant();
loanTransaction = LoanTransaction.writeoff(this, getOffice(), writtenOffOnLocalDate, txnExternalId, createdDate, currentUser);
final boolean isLastTransaction = isChronologicallyLatestTransaction(loanTransaction, this.loanTransactions);
if (!isLastTransaction) {
LocalDate lastTransactionDate = getLastUserTransactionDate();
if (lastTransactionDate.isAfter(writtenOffOnLocalDate)) {
final String errorMessage = "The date of the writeoff transaction must occur on or before previous transactions.";
throw new InvalidLoanStateTransitionException("writeoff", "must.occur.on.or.after.other.transaction.dates", errorMessage,
writtenOffOnLocalDate);