From e3f03f1de3de5a5b0152ec12103d8ce618f96fd0 Mon Sep 17 00:00:00 2001 From: ashok-conflux Date: Fri, 8 Mar 2013 18:46:36 +0530 Subject: [PATCH] updated loan officer unassign date validation error message --- .../portfolio/loanaccount/domain/Loan.java | 16 +++++++++++++--- .../LoanOfficerUnassignmentDateException.java | 14 +++----------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java index 85c1fbacb..36d4502d0 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java @@ -2029,9 +2029,19 @@ public class Loan extends AbstractPersistable { final LocalDate today = DateUtils.getLocalDateOfTenant(); if (latestHistoryRecord.getStartDate().isAfter(unassignDate)) { - throw new LoanOfficerUnassignmentDateException(this.getId(), this.getLoanOfficer().getId(), latestHistoryRecord.getStartDate(), - unassignDate); - } else if (unassignDate.isAfter(today)) { throw new LoanOfficerUnassignmentDateException(this.getId()); } + + final String errorMessage = "The Loan officer Unassign date(" + unassignDate + ") cannot be before its assignment date (" + + latestHistoryRecord.getStartDate() + ")."; + + throw new LoanOfficerUnassignmentDateException("cannot.be.before.assignment.date", errorMessage, this.getId(), this + .getLoanOfficer().getId(), latestHistoryRecord.getStartDate(), unassignDate); + + } else if (unassignDate.isAfter(today)) { + + final String errorMessage = "The Loan Officer Unassign date (" + unassignDate + ") cannot be in the future."; + + throw new LoanOfficerUnassignmentDateException("cannot.be.a.future.date", errorMessage, unassignDate); + } } private LoanOfficerAssignmentHistory findLatestIncompleteHistoryRecord() { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/exception/LoanOfficerUnassignmentDateException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/exception/LoanOfficerUnassignmentDateException.java index 759859168..fe7bc1cc2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/exception/LoanOfficerUnassignmentDateException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/exception/LoanOfficerUnassignmentDateException.java @@ -5,20 +5,12 @@ */ package org.mifosplatform.portfolio.loanaccount.exception; -import org.joda.time.LocalDate; import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; public class LoanOfficerUnassignmentDateException extends AbstractPlatformDomainRuleException { - public LoanOfficerUnassignmentDateException(final Long loanId, final Long loanofficerId, final LocalDate assignedDate, - final LocalDate unassignDate) { - super("error.msg.loan.unassign.loanofficer.invalid.pastedate", "Loan officer Unassign date(" + unassignDate - + ") can not be less than assign date(" + assignedDate + ") for loan(" + loanId + ") with Loan Officer " + loanofficerId - + ").", loanId); + public LoanOfficerUnassignmentDateException(String postFix, String defaultUserMessage, + Object... defaultUserMessageArgs) { + super("error.msg.loan.loanofficer.unassign.date." + postFix, defaultUserMessage, defaultUserMessageArgs); } - - public LoanOfficerUnassignmentDateException(final Long loanId) { - super("error.msg.loan.unassign.loanofficer.invalid.futuredate", "Unassign loan officer in future date is not supported.", loanId); - } - }