Fix typo in error messages in Loan

This commit is contained in:
Adam Saghy
2022-07-11 17:53:54 +02:00
committed by Arnold Gálovics
parent 7ce19d703b
commit a765cb00f1
@@ -658,11 +658,11 @@ public class Loan extends AbstractPersistableCustom {
} }
/** /**
* Creates a loanTransaction for "Apply Charge Event" with transaction LocalDate set to "suppliedTransactionDate". * Creates a loanTransaction for "Apply Charge Event" with transaction date set to "suppliedTransactionDate". The
* The newly created transaction is also added to the Loan on which this method is called. * newly created transaction is also added to the Loan on which this method is called.
* *
* If "suppliedTransactionDate" is not passed Id, the transaction LocalDate is set to the loans due LocalDate if the * If "suppliedTransactionDate" is not passed Id, the transaction date is set to the loans due date if the due date
* due date is lesser than todays date. If not, the transaction LocalDate is set to todays date * is lesser than todays date. If not, the transaction date is set to todays date
* *
* @param loanCharge * @param loanCharge
* @param suppliedTransactionDate * @param suppliedTransactionDate
@@ -686,7 +686,7 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate currentDate = DateUtils.getBusinessLocalDate(); final LocalDate currentDate = DateUtils.getBusinessLocalDate();
// if loan charge is to be applied on a future date, the loan // if loan charge is to be applied on a future date, the loan
// transaction would show todays LocalDate as applied date // transaction would show todays date as applied date
if (transactionDate == null || currentDate.isBefore(transactionDate)) { if (transactionDate == null || currentDate.isBefore(transactionDate)) {
transactionDate = currentDate; transactionDate = currentDate;
} }
@@ -759,7 +759,7 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate lastRepaymentPeriodDueDate) { final LocalDate lastRepaymentPeriodDueDate) {
if (loanCharge.isSpecifiedDueDate() if (loanCharge.isSpecifiedDueDate()
&& !loanCharge.isDueForCollectionFromAndUpToAndIncluding(disbursementDate, lastRepaymentPeriodDueDate)) { && !loanCharge.isDueForCollectionFromAndUpToAndIncluding(disbursementDate, lastRepaymentPeriodDueDate)) {
final String defaultUserMessage = "This charge with specified due LocalDate cannot be added as the it is not in schedule range."; final String defaultUserMessage = "This charge with specified due date cannot be added as the it is not in schedule range.";
throw new LoanChargeCannotBeAddedException("loanCharge", "specified.due.date.outside.range", defaultUserMessage, throw new LoanChargeCannotBeAddedException("loanCharge", "specified.due.date.outside.range", defaultUserMessage,
getDisbursementDate(), lastRepaymentPeriodDueDate, loanCharge.name()); getDisbursementDate(), lastRepaymentPeriodDueDate, loanCharge.name());
} }
@@ -1049,7 +1049,7 @@ public class Loan extends AbstractPersistableCustom {
&& (loanCharge.getDueLocalDate() == null || DateUtils.getBusinessLocalDate().isAfter(loanCharge.getDueLocalDate()))) { && (loanCharge.getDueLocalDate() == null || DateUtils.getBusinessLocalDate().isAfter(loanCharge.getDueLocalDate()))) {
regenerateRepaymentScheduleWithInterestRecalculation(scheduleGeneratorDTO); regenerateRepaymentScheduleWithInterestRecalculation(scheduleGeneratorDTO);
} }
// Waive of charges whose due LocalDate falls after latest 'repayment' // Waive of charges whose due date falls after latest 'repayment'
// transaction dont require entire loan schedule to be reprocessed. // transaction dont require entire loan schedule to be reprocessed.
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory
.determineProcessor(this.transactionProcessingStrategy); .determineProcessor(this.transactionProcessingStrategy);
@@ -1528,29 +1528,29 @@ public class Loan extends AbstractPersistableCustom {
} }
// the comparison should be done with the tenant date // the comparison should be done with the tenant date
// (DateUtils.getBusinessDate()) and not the server LocalDate (new // (DateUtils.getBusinessDate()) and not the server date (new
// LocalDate()) // LocalDate())
if (getSubmittedOnDate().isAfter(DateUtils.getBusinessLocalDate())) { if (getSubmittedOnDate().isAfter(DateUtils.getBusinessLocalDate())) {
final String errorMessage = "The LocalDate on which a loan is submitted cannot be in the future."; final String errorMessage = "The date on which a loan is submitted cannot be in the future.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.a.future.date", errorMessage, getSubmittedOnDate()); throw new InvalidLoanStateTransitionException("submittal", "cannot.be.a.future.date", errorMessage, getSubmittedOnDate());
} }
if (!(this.client == null)) { if (!(this.client == null)) {
if (getSubmittedOnDate().isBefore(this.client.getActivationLocalDate())) { if (getSubmittedOnDate().isBefore(this.client.getActivationLocalDate())) {
final String errorMessage = "The LocalDate on which a loan is submitted cannot be earlier than client's activation date."; final String errorMessage = "The date on which a loan is submitted cannot be earlier than client's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.client.activation.date", errorMessage, throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.client.activation.date", errorMessage,
getSubmittedOnDate()); getSubmittedOnDate());
} }
} else if (!(this.group == null)) { } else if (!(this.group == null)) {
if (getSubmittedOnDate().isBefore(this.group.getActivationLocalDate())) { if (getSubmittedOnDate().isBefore(this.group.getActivationLocalDate())) {
final String errorMessage = "The LocalDate on which a loan is submitted cannot be earlier than groups's activation date."; final String errorMessage = "The date on which a loan is submitted cannot be earlier than groups's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.group.activation.date", errorMessage, throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.group.activation.date", errorMessage,
getSubmittedOnDate()); getSubmittedOnDate());
} }
} }
if (getSubmittedOnDate().isAfter(getExpectedDisbursedOnLocalDate())) { if (getSubmittedOnDate().isAfter(getExpectedDisbursedOnLocalDate())) {
final String errorMessage = "The LocalDate on which a loan is submitted cannot be after its expected disbursement date: " final String errorMessage = "The date on which a loan is submitted cannot be after its expected disbursement date: "
+ getExpectedDisbursedOnLocalDate().toString(); + getExpectedDisbursedOnLocalDate().toString();
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.after.expected.disbursement.date", errorMessage, throw new InvalidLoanStateTransitionException("submittal", "cannot.be.after.expected.disbursement.date", errorMessage,
getSubmittedOnDate(), getExpectedDisbursedOnLocalDate()); getSubmittedOnDate(), getExpectedDisbursedOnLocalDate());
@@ -1772,7 +1772,7 @@ public class Loan extends AbstractPersistableCustom {
return amount; return amount;
} }
// This method returns LocalDate format and locale if present in the JsonCommand // This method returns date format and locale if present in the JsonCommand
private Map<String, String> getDateFormatAndLocale(final JsonCommand jsonCommand) { private Map<String, String> getDateFormatAndLocale(final JsonCommand jsonCommand) {
Map<String, String> returnObject = new HashMap<>(); Map<String, String> returnObject = new HashMap<>();
JsonElement jsonElement = jsonCommand.parsedJson(); JsonElement jsonElement = jsonCommand.parsedJson();
@@ -1852,7 +1852,7 @@ public class Loan extends AbstractPersistableCustom {
if (disbursementDataArray != null && disbursementDataArray.size() > 0) { if (disbursementDataArray != null && disbursementDataArray.size() > 0) {
String dateFormat = null; String dateFormat = null;
Locale locale = null; Locale locale = null;
// Gets LocalDate format and locate // Gets date format and locate
Map<String, String> dateAndLocale = getDateFormatAndLocale(jsonCommand); Map<String, String> dateAndLocale = getDateFormatAndLocale(jsonCommand);
dateFormat = dateAndLocale.get(LoanApiConstants.dateFormatParameterName); dateFormat = dateAndLocale.get(LoanApiConstants.dateFormatParameterName);
if (dateAndLocale.containsKey(LoanApiConstants.localeParameterName)) { if (dateAndLocale.containsKey(LoanApiConstants.localeParameterName)) {
@@ -2056,12 +2056,12 @@ public class Loan extends AbstractPersistableCustom {
updateLoanScheduleDependentDerivedFields(); updateLoanScheduleDependentDerivedFields();
if (submittedOn.isAfter(DateUtils.getBusinessLocalDate())) { if (submittedOn.isAfter(DateUtils.getBusinessLocalDate())) {
final String errorMessage = "The LocalDate on which a loan is submitted cannot be in the future."; final String errorMessage = "The date on which a loan is submitted cannot be in the future.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.a.future.date", errorMessage, submittedOn); throw new InvalidLoanStateTransitionException("submittal", "cannot.be.a.future.date", errorMessage, submittedOn);
} }
if (this.client != null && this.client.isActivatedAfter(submittedOn)) { if (this.client != null && this.client.isActivatedAfter(submittedOn)) {
final String errorMessage = "The LocalDate on which a loan is submitted cannot be earlier than client's activation date."; final String errorMessage = "The date on which a loan is submitted cannot be earlier than client's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.client.activation.date", errorMessage, throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.client.activation.date", errorMessage,
submittedOn); submittedOn);
} }
@@ -2069,12 +2069,12 @@ public class Loan extends AbstractPersistableCustom {
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_CREATED, submittedOn); validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_CREATED, submittedOn);
if (this.group != null && this.group.isActivatedAfter(submittedOn)) { if (this.group != null && this.group.isActivatedAfter(submittedOn)) {
final String errorMessage = "The LocalDate on which a loan is submitted cannot be earlier than groups's activation date."; final String errorMessage = "The date on which a loan is submitted cannot be earlier than groups's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.group.activation.date", errorMessage, submittedOn); throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.group.activation.date", errorMessage, submittedOn);
} }
if (submittedOn.isAfter(getExpectedDisbursedOnLocalDate())) { if (submittedOn.isAfter(getExpectedDisbursedOnLocalDate())) {
final String errorMessage = "The LocalDate on which a loan is submitted cannot be after its expected disbursement date: " final String errorMessage = "The date on which a loan is submitted cannot be after its expected disbursement date: "
+ getExpectedDisbursedOnLocalDate().toString(); + getExpectedDisbursedOnLocalDate().toString();
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.after.expected.disbursement.date", errorMessage, throw new InvalidLoanStateTransitionException("submittal", "cannot.be.after.expected.disbursement.date", errorMessage,
submittedOn, getExpectedDisbursedOnLocalDate()); submittedOn, getExpectedDisbursedOnLocalDate());
@@ -2088,7 +2088,7 @@ public class Loan extends AbstractPersistableCustom {
updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement()); updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
// validate if disbursement LocalDate is a holiday or a non-working day // validate if disbursement date is a holiday or a non-working day
validateDisbursementDateIsOnNonWorkingDay(workingDays, allowTransactionsOnNonWorkingDay); validateDisbursementDateIsOnNonWorkingDay(workingDays, allowTransactionsOnNonWorkingDay);
validateDisbursementDateIsOnHoliday(allowTransactionsOnHoliday, holidays); validateDisbursementDateIsOnHoliday(allowTransactionsOnHoliday, holidays);
@@ -2147,7 +2147,7 @@ public class Loan extends AbstractPersistableCustom {
actualChanges.put("closedOnDate", rejectedOn.format(fmt)); actualChanges.put("closedOnDate", rejectedOn.format(fmt));
if (rejectedOn.isBefore(getSubmittedOnDate())) { if (rejectedOn.isBefore(getSubmittedOnDate())) {
final String errorMessage = "The LocalDate on which a loan is rejected cannot be before its submittal date: " final String errorMessage = "The date on which a loan is rejected cannot be before its submittal date: "
+ getSubmittedOnDate().toString(); + getSubmittedOnDate().toString();
throw new InvalidLoanStateTransitionException("reject", "cannot.be.before.submittal.date", errorMessage, rejectedOn, throw new InvalidLoanStateTransitionException("reject", "cannot.be.before.submittal.date", errorMessage, rejectedOn,
getSubmittedOnDate()); getSubmittedOnDate());
@@ -2156,7 +2156,7 @@ public class Loan extends AbstractPersistableCustom {
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_REJECTED, rejectedOn); validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_REJECTED, rejectedOn);
if (rejectedOn.isAfter(DateUtils.getBusinessLocalDate())) { if (rejectedOn.isAfter(DateUtils.getBusinessLocalDate())) {
final String errorMessage = "The LocalDate on which a loan is rejected cannot be in the future."; final String errorMessage = "The date on which a loan is rejected cannot be in the future.";
throw new InvalidLoanStateTransitionException("reject", "cannot.be.a.future.date", errorMessage, rejectedOn); throw new InvalidLoanStateTransitionException("reject", "cannot.be.a.future.date", errorMessage, rejectedOn);
} }
} else { } else {
@@ -2196,7 +2196,7 @@ public class Loan extends AbstractPersistableCustom {
actualChanges.put("closedOnDate", withdrawnOn.format(fmt)); actualChanges.put("closedOnDate", withdrawnOn.format(fmt));
if (withdrawnOn.isBefore(getSubmittedOnDate())) { if (withdrawnOn.isBefore(getSubmittedOnDate())) {
final String errorMessage = "The LocalDate on which a loan is withdrawn cannot be before its submittal date: " final String errorMessage = "The date on which a loan is withdrawn cannot be before its submittal date: "
+ getSubmittedOnDate().toString(); + getSubmittedOnDate().toString();
throw new InvalidLoanStateTransitionException("withdraw", "cannot.be.before.submittal.date", errorMessage, command, throw new InvalidLoanStateTransitionException("withdraw", "cannot.be.before.submittal.date", errorMessage, command,
getSubmittedOnDate()); getSubmittedOnDate());
@@ -2205,7 +2205,7 @@ public class Loan extends AbstractPersistableCustom {
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_WITHDRAWN, withdrawnOn); validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_WITHDRAWN, withdrawnOn);
if (withdrawnOn.isAfter(DateUtils.getBusinessLocalDate())) { if (withdrawnOn.isAfter(DateUtils.getBusinessLocalDate())) {
final String errorMessage = "The LocalDate on which a loan is withdrawn cannot be in the future."; final String errorMessage = "The date on which a loan is withdrawn cannot be in the future.";
throw new InvalidLoanStateTransitionException("withdraw", "cannot.be.a.future.date", errorMessage, command); throw new InvalidLoanStateTransitionException("withdraw", "cannot.be.a.future.date", errorMessage, command);
} }
} else { } else {
@@ -2300,7 +2300,7 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate submittalDate = this.submittedOnDate; final LocalDate submittalDate = this.submittedOnDate;
if (approvedOn.isBefore(submittalDate)) { if (approvedOn.isBefore(submittalDate)) {
final String errorMessage = "The LocalDate on which a loan is approved cannot be before its submittal date: " final String errorMessage = "The date on which a loan is approved cannot be before its submittal date: "
+ submittalDate.toString(); + submittalDate.toString();
throw new InvalidLoanStateTransitionException("approval", "cannot.be.before.submittal.date", errorMessage, throw new InvalidLoanStateTransitionException("approval", "cannot.be.before.submittal.date", errorMessage,
getApprovedOnDate(), submittalDate); getApprovedOnDate(), submittalDate);
@@ -2311,7 +2311,7 @@ public class Loan extends AbstractPersistableCustom {
actualChanges.put("expectedDisbursementDate", expectedDisbursementDate); actualChanges.put("expectedDisbursementDate", expectedDisbursementDate);
if (expecteddisbursementDate.isBefore(approvedOn)) { if (expecteddisbursementDate.isBefore(approvedOn)) {
final String errorMessage = "The expected disbursement LocalDate should be either on or after the approval date: " final String errorMessage = "The expected disbursement date should be either on or after the approval date: "
+ approvedOn.toString(); + approvedOn.toString();
throw new InvalidLoanStateTransitionException("expecteddisbursal", "should.be.on.or.after.approval.date", errorMessage, throw new InvalidLoanStateTransitionException("expecteddisbursal", "should.be.on.or.after.approval.date", errorMessage,
getApprovedOnDate(), expecteddisbursementDate); getApprovedOnDate(), expecteddisbursementDate);
@@ -2321,7 +2321,7 @@ public class Loan extends AbstractPersistableCustom {
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_APPROVED, approvedOn); validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_APPROVED, approvedOn);
if (approvedOn.isAfter(DateUtils.getBusinessLocalDate())) { if (approvedOn.isAfter(DateUtils.getBusinessLocalDate())) {
final String errorMessage = "The LocalDate on which a loan is approved cannot be in the future."; final String errorMessage = "The date on which a loan is approved cannot be in the future.";
throw new InvalidLoanStateTransitionException("approval", "cannot.be.a.future.date", errorMessage, getApprovedOnDate()); throw new InvalidLoanStateTransitionException("approval", "cannot.be.a.future.date", errorMessage, getApprovedOnDate());
} }
@@ -2443,7 +2443,7 @@ public class Loan extends AbstractPersistableCustom {
HolidayDetailDTO holidayDetailDTO = scheduleGeneratorDTO.getHolidayDetailDTO(); HolidayDetailDTO holidayDetailDTO = scheduleGeneratorDTO.getHolidayDetailDTO();
// validate if disbursement LocalDate is a holiday or a non-working day // validate if disbursement date is a holiday or a non-working day
validateDisbursementDateIsOnNonWorkingDay(holidayDetailDTO.getWorkingDays(), holidayDetailDTO.isAllowTransactionsOnNonWorkingDay()); validateDisbursementDateIsOnNonWorkingDay(holidayDetailDTO.getWorkingDays(), holidayDetailDTO.isAllowTransactionsOnNonWorkingDay());
validateDisbursementDateIsOnHoliday(holidayDetailDTO.isAllowTransactionsOnHoliday(), holidayDetailDTO.getHolidays()); validateDisbursementDateIsOnHoliday(holidayDetailDTO.isAllowTransactionsOnHoliday(), holidayDetailDTO.getHolidays());
@@ -2871,7 +2871,7 @@ public class Loan extends AbstractPersistableCustom {
} }
if (getApprovedOnDate() != null && disbursedOn.isBefore(getApprovedOnDate())) { if (getApprovedOnDate() != null && disbursedOn.isBefore(getApprovedOnDate())) {
final String errorMessage = "The LocalDate on which a loan is disbursed cannot be before its approval date: " final String errorMessage = "The date on which a loan is disbursed cannot be before its approval date: "
+ getApprovedOnDate().toString(); + getApprovedOnDate().toString();
throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.before.approval.date", errorMessage, disbursedOn, throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.before.approval.date", errorMessage, disbursedOn,
getApprovedOnDate()); getApprovedOnDate());
@@ -2890,7 +2890,7 @@ public class Loan extends AbstractPersistableCustom {
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_DISBURSED, disbursedOn); validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_DISBURSED, disbursedOn);
if (disbursedOn.isAfter(DateUtils.getBusinessLocalDate())) { if (disbursedOn.isAfter(DateUtils.getBusinessLocalDate())) {
final String errorMessage = "The LocalDate on which a loan with identifier : " + this.accountNumber final String errorMessage = "The date on which a loan with identifier : " + this.accountNumber
+ " is disbursed cannot be in the future."; + " is disbursed cannot be in the future.";
throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.a.future.date", errorMessage, disbursedOn); throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.a.future.date", errorMessage, disbursedOn);
} }
@@ -2957,7 +2957,7 @@ public class Loan extends AbstractPersistableCustom {
updateLoanToPreDisbursalState(); updateLoanToPreDisbursalState();
if (isScheduleRegenerateRequired || isDisbursedAmountChanged || isEmiAmountChanged if (isScheduleRegenerateRequired || isDisbursedAmountChanged || isEmiAmountChanged
|| this.repaymentScheduleDetail().isInterestRecalculationEnabled()) { || this.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
// clear off actual disbusrement LocalDate so schedule regeneration // clear off actual disbusrement date so schedule regeneration
// uses expected date. // uses expected date.
regenerateRepaymentSchedule(scheduleGeneratorDTO); regenerateRepaymentSchedule(scheduleGeneratorDTO);
@@ -3108,7 +3108,7 @@ public class Loan extends AbstractPersistableCustom {
holidayDetailDTO.isAllowTransactionsOnNonWorkingDay()); holidayDetailDTO.isAllowTransactionsOnNonWorkingDay());
if (paymentTransaction.getTransactionDate().isAfter(DateUtils.getBusinessLocalDate())) { if (paymentTransaction.getTransactionDate().isAfter(DateUtils.getBusinessLocalDate())) {
final String errorMessage = "The LocalDate on which a loan charge paid cannot be in the future."; final String errorMessage = "The date on which a loan charge paid cannot be in the future.";
throw new InvalidLoanStateTransitionException("charge.payment", "cannot.be.a.future.date", errorMessage, throw new InvalidLoanStateTransitionException("charge.payment", "cannot.be.a.future.date", errorMessage,
paymentTransaction.getTransactionDate()); paymentTransaction.getTransactionDate());
} }
@@ -3200,14 +3200,14 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate loanTransactionDate = loanTransaction.getTransactionDate(); final LocalDate loanTransactionDate = loanTransaction.getTransactionDate();
if (loanTransactionDate.isBefore(getDisbursementDate())) { if (loanTransactionDate.isBefore(getDisbursementDate())) {
final String errorMessage = "The transaction LocalDate cannot be before the loan disbursement date: " final String errorMessage = "The transaction date cannot be before the loan disbursement date: "
+ getApprovedOnDate().toString(); + getApprovedOnDate().toString();
throw new InvalidLoanStateTransitionException("transaction", "cannot.be.before.disbursement.date", errorMessage, throw new InvalidLoanStateTransitionException("transaction", "cannot.be.before.disbursement.date", errorMessage,
loanTransactionDate, getDisbursementDate()); loanTransactionDate, getDisbursementDate());
} }
if (loanTransactionDate.isAfter(DateUtils.getBusinessLocalDate())) { if (loanTransactionDate.isAfter(DateUtils.getBusinessLocalDate())) {
final String errorMessage = "The transaction LocalDate cannot be in the future."; final String errorMessage = "The transaction date cannot be in the future.";
throw new InvalidLoanStateTransitionException("transaction", "cannot.be.a.future.date", errorMessage, loanTransactionDate); throw new InvalidLoanStateTransitionException("transaction", "cannot.be.a.future.date", errorMessage, loanTransactionDate);
} }
@@ -3765,7 +3765,7 @@ public class Loan extends AbstractPersistableCustom {
changes.put("writtenOffOnDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("writtenOffOnDate", command.stringValueOfParameterNamed("transactionDate"));
if (writtenOffOnLocalDate.isBefore(getDisbursementDate())) { if (writtenOffOnLocalDate.isBefore(getDisbursementDate())) {
final String errorMessage = "The LocalDate on which a loan is written off cannot be before the loan disbursement date: " final String errorMessage = "The date on which a loan is written off cannot be before the loan disbursement date: "
+ getDisbursementDate().toString(); + getDisbursementDate().toString();
throw new InvalidLoanStateTransitionException("writeoff", "cannot.be.before.submittal.date", errorMessage, throw new InvalidLoanStateTransitionException("writeoff", "cannot.be.before.submittal.date", errorMessage,
writtenOffOnLocalDate, getDisbursementDate()); writtenOffOnLocalDate, getDisbursementDate());
@@ -3774,7 +3774,7 @@ public class Loan extends AbstractPersistableCustom {
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.WRITE_OFF_OUTSTANDING, writtenOffOnLocalDate); validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.WRITE_OFF_OUTSTANDING, writtenOffOnLocalDate);
if (writtenOffOnLocalDate.isAfter(DateUtils.getBusinessLocalDate())) { if (writtenOffOnLocalDate.isAfter(DateUtils.getBusinessLocalDate())) {
final String errorMessage = "The LocalDate on which a loan is written off cannot be in the future."; final String errorMessage = "The date on which a loan is written off cannot be in the future.";
throw new InvalidLoanStateTransitionException("writeoff", "cannot.be.a.future.date", errorMessage, writtenOffOnLocalDate); throw new InvalidLoanStateTransitionException("writeoff", "cannot.be.a.future.date", errorMessage, writtenOffOnLocalDate);
} }
@@ -3782,7 +3782,7 @@ public class Loan extends AbstractPersistableCustom {
loanTransaction = LoanTransaction.writeoff(this, getOffice(), writtenOffOnLocalDate, txnExternalId); loanTransaction = LoanTransaction.writeoff(this, getOffice(), writtenOffOnLocalDate, txnExternalId);
LocalDate lastTransactionDate = getLastUserTransactionDate(); LocalDate lastTransactionDate = getLastUserTransactionDate();
if (lastTransactionDate.isAfter(writtenOffOnLocalDate)) { if (lastTransactionDate.isAfter(writtenOffOnLocalDate)) {
final String errorMessage = "The LocalDate of the writeoff transaction must occur on or before previous transactions."; 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, throw new InvalidLoanStateTransitionException("writeoff", "must.occur.on.or.after.other.transaction.dates", errorMessage,
writtenOffOnLocalDate); writtenOffOnLocalDate);
} }
@@ -3851,14 +3851,14 @@ public class Loan extends AbstractPersistableCustom {
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.REPAID_IN_FULL, closureDate); validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.REPAID_IN_FULL, closureDate);
if (closureDate.isBefore(getDisbursementDate())) { if (closureDate.isBefore(getDisbursementDate())) {
final String errorMessage = "The LocalDate on which a loan is closed cannot be before the loan disbursement date: " final String errorMessage = "The date on which a loan is closed cannot be before the loan disbursement date: "
+ getDisbursementDate().toString(); + getDisbursementDate().toString();
throw new InvalidLoanStateTransitionException("close", "cannot.be.before.submittal.date", errorMessage, closureDate, throw new InvalidLoanStateTransitionException("close", "cannot.be.before.submittal.date", errorMessage, closureDate,
getDisbursementDate()); getDisbursementDate());
} }
if (closureDate.isAfter(DateUtils.getBusinessLocalDate())) { if (closureDate.isAfter(DateUtils.getBusinessLocalDate())) {
final String errorMessage = "The LocalDate on which a loan is closed cannot be in the future."; final String errorMessage = "The date on which a loan is closed cannot be in the future.";
throw new InvalidLoanStateTransitionException("close", "cannot.be.a.future.date", errorMessage, closureDate); throw new InvalidLoanStateTransitionException("close", "cannot.be.a.future.date", errorMessage, closureDate);
} }
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory
@@ -3881,7 +3881,7 @@ public class Loan extends AbstractPersistableCustom {
loanTransaction = LoanTransaction.writeoff(this, getOffice(), closureDate, txnExternalId); loanTransaction = LoanTransaction.writeoff(this, getOffice(), closureDate, txnExternalId);
final boolean isLastTransaction = isChronologicallyLatestTransaction(loanTransaction, getLoanTransactions()); final boolean isLastTransaction = isChronologicallyLatestTransaction(loanTransaction, getLoanTransactions());
if (!isLastTransaction) { if (!isLastTransaction) {
final String errorMessage = "The closing LocalDate of the loan must be on or after latest transaction date."; final String errorMessage = "The closing date of the loan must be on or after latest transaction date.";
throw new InvalidLoanStateTransitionException("close.loan", "must.occur.on.or.after.latest.transaction.date", throw new InvalidLoanStateTransitionException("close.loan", "must.occur.on.or.after.latest.transaction.date",
errorMessage, closureDate); errorMessage, closureDate);
} }
@@ -3945,14 +3945,14 @@ public class Loan extends AbstractPersistableCustom {
changes.put("rescheduledOnDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("rescheduledOnDate", command.stringValueOfParameterNamed("transactionDate"));
if (this.rescheduledOnDate.isBefore(getDisbursementDate())) { if (this.rescheduledOnDate.isBefore(getDisbursementDate())) {
final String errorMessage = "The LocalDate on which a loan is rescheduled cannot be before the loan disbursement date: " final String errorMessage = "The date on which a loan is rescheduled cannot be before the loan disbursement date: "
+ getDisbursementDate().toString(); + getDisbursementDate().toString();
throw new InvalidLoanStateTransitionException("close.reschedule", "cannot.be.before.submittal.date", errorMessage, throw new InvalidLoanStateTransitionException("close.reschedule", "cannot.be.before.submittal.date", errorMessage,
this.rescheduledOnDate, getDisbursementDate()); this.rescheduledOnDate, getDisbursementDate());
} }
if (this.rescheduledOnDate.isAfter(DateUtils.getBusinessLocalDate())) { if (this.rescheduledOnDate.isAfter(DateUtils.getBusinessLocalDate())) {
final String errorMessage = "The LocalDate on which a loan is rescheduled cannot be in the future."; final String errorMessage = "The date on which a loan is rescheduled cannot be in the future.";
throw new InvalidLoanStateTransitionException("close.reschedule", "cannot.be.a.future.date", errorMessage, throw new InvalidLoanStateTransitionException("close.reschedule", "cannot.be.a.future.date", errorMessage,
this.rescheduledOnDate); this.rescheduledOnDate);
} }
@@ -4218,26 +4218,26 @@ public class Loan extends AbstractPersistableCustom {
final LoanOfficerAssignmentHistory latestHistoryRecord = findLatestIncompleteHistoryRecord(); final LoanOfficerAssignmentHistory latestHistoryRecord = findLatestIncompleteHistoryRecord();
final LoanOfficerAssignmentHistory lastAssignmentRecord = findLastAssignmentHistoryRecord(newLoanOfficer); final LoanOfficerAssignmentHistory lastAssignmentRecord = findLastAssignmentHistoryRecord(newLoanOfficer);
// assignment LocalDate should not be less than loan submitted date // assignment date should not be less than loan submitted date
if (isSubmittedOnDateAfter(assignmentDate)) { if (isSubmittedOnDateAfter(assignmentDate)) {
final String errorMessage = "The Loan Officer assignment LocalDate (" + assignmentDate.toString() final String errorMessage = "The Loan Officer assignment date (" + assignmentDate.toString()
+ ") cannot be before loan submitted LocalDate (" + getSubmittedOnDate().toString() + ")."; + ") cannot be before loan submitted date (" + getSubmittedOnDate().toString() + ").";
throw new LoanOfficerAssignmentDateException("cannot.be.before.loan.submittal.date", errorMessage, assignmentDate, throw new LoanOfficerAssignmentDateException("cannot.be.before.loan.submittal.date", errorMessage, assignmentDate,
getSubmittedOnDate()); getSubmittedOnDate());
} else if (lastAssignmentRecord != null && lastAssignmentRecord.isEndDateAfter(assignmentDate)) { } else if (lastAssignmentRecord != null && lastAssignmentRecord.isEndDateAfter(assignmentDate)) {
final String errorMessage = "The Loan Officer assignment LocalDate (" + assignmentDate final String errorMessage = "The Loan Officer assignment date (" + assignmentDate
+ ") cannot be before previous Loan Officer unassigned LocalDate (" + lastAssignmentRecord.getEndDate() + ")."; + ") cannot be before previous Loan Officer unassigned date (" + lastAssignmentRecord.getEndDate() + ").";
throw new LoanOfficerAssignmentDateException("cannot.be.before.previous.unassignement.date", errorMessage, assignmentDate, throw new LoanOfficerAssignmentDateException("cannot.be.before.previous.unassignement.date", errorMessage, assignmentDate,
lastAssignmentRecord.getEndDate()); lastAssignmentRecord.getEndDate());
} else if (DateUtils.getBusinessLocalDate().isBefore(assignmentDate)) { } else if (DateUtils.getBusinessLocalDate().isBefore(assignmentDate)) {
final String errorMessage = "The Loan Officer assignment LocalDate (" + assignmentDate + ") cannot be in the future."; final String errorMessage = "The Loan Officer assignment date (" + assignmentDate + ") cannot be in the future.";
throw new LoanOfficerAssignmentDateException("cannot.be.a.future.date", errorMessage, assignmentDate); throw new LoanOfficerAssignmentDateException("cannot.be.a.future.date", errorMessage, assignmentDate);
@@ -4247,7 +4247,7 @@ public class Loan extends AbstractPersistableCustom {
latestHistoryRecord.updateLoanOfficer(newLoanOfficer); latestHistoryRecord.updateLoanOfficer(newLoanOfficer);
this.loanOfficer = newLoanOfficer; this.loanOfficer = newLoanOfficer;
} else if (latestHistoryRecord != null && latestHistoryRecord.hasStartDateBefore(assignmentDate)) { } else if (latestHistoryRecord != null && latestHistoryRecord.hasStartDateBefore(assignmentDate)) {
final String errorMessage = "Loan with identifier " + getId() + " was already assigned before LocalDate " + assignmentDate; final String errorMessage = "Loan with identifier " + getId() + " was already assigned before date " + assignmentDate;
throw new LoanOfficerAssignmentDateException("is.before.last.assignment.date", errorMessage, getId(), assignmentDate); throw new LoanOfficerAssignmentDateException("is.before.last.assignment.date", errorMessage, getId(), assignmentDate);
} else { } else {
if (latestHistoryRecord != null) { if (latestHistoryRecord != null) {
@@ -4283,7 +4283,7 @@ public class Loan extends AbstractPersistableCustom {
if (latestHistoryRecord.getStartDate().isAfter(unassignDate)) { if (latestHistoryRecord.getStartDate().isAfter(unassignDate)) {
final String errorMessage = "The Loan officer Unassign date(" + unassignDate + ") cannot be before its assignment LocalDate (" final String errorMessage = "The Loan officer Unassign date(" + unassignDate + ") cannot be before its assignment date ("
+ latestHistoryRecord.getStartDate() + ")."; + latestHistoryRecord.getStartDate() + ").";
throw new LoanOfficerUnassignmentDateException("cannot.be.before.assignment.date", errorMessage, getId(), throw new LoanOfficerUnassignmentDateException("cannot.be.before.assignment.date", errorMessage, getId(),
@@ -4291,7 +4291,7 @@ public class Loan extends AbstractPersistableCustom {
} else if (unassignDate.isAfter(today)) { } else if (unassignDate.isAfter(today)) {
final String errorMessage = "The Loan Officer Unassign LocalDate (" + unassignDate + ") cannot be in the future."; final String errorMessage = "The Loan Officer Unassign date (" + unassignDate + ") cannot be in the future.";
throw new LoanOfficerUnassignmentDateException("cannot.be.a.future.date", errorMessage, unassignDate); throw new LoanOfficerUnassignmentDateException("cannot.be.a.future.date", errorMessage, unassignDate);
} }
@@ -4458,9 +4458,9 @@ public class Loan extends AbstractPersistableCustom {
} }
/* /*
* if (transaction.getTransactionDate().isAfter(tillDate) && transaction.isAccrual()) { final String * if (transaction.getTransactionDate().isAfter(tillDate) && transaction.isAccrual()) { final String
* errorMessage = * errorMessage = "The date on which a loan is interest waived cannot be in after accrual transactions." ;
* "The LocalDate on which a loan is interest waived cannot be in after accrual transactions." ; throw new * throw new InvalidLoanStateTransitionException("waive", "cannot.be.after.accrual.date", errorMessage,
* InvalidLoanStateTransitionException("waive", "cannot.be.after.accrual.date", errorMessage, tillDate); } * tillDate); }
*/ */
} }
return receivableInterest; return receivableInterest;
@@ -4486,7 +4486,7 @@ public class Loan extends AbstractPersistableCustom {
final Boolean reschedulebasedOnMeetingDates, final LocalDate presentMeetingDate, final LocalDate newMeetingDate, final Boolean reschedulebasedOnMeetingDates, final LocalDate presentMeetingDate, final LocalDate newMeetingDate,
final boolean isSkipRepaymentonfirstdayofmonth, final Integer numberofDays) { final boolean isSkipRepaymentonfirstdayofmonth, final Integer numberofDays) {
// first repayment's from LocalDate is same as disbursement date. // first repayment's from date is same as disbursement date.
/* /*
* meetingStartDate is used as seedDate Capture the seedDate from user and use the seedDate as meetingStart date * meetingStartDate is used as seedDate Capture the seedDate from user and use the seedDate as meetingStart date
*/ */
@@ -4514,7 +4514,7 @@ public class Loan extends AbstractPersistableCustom {
} else { } else {
// tmpFromDate.plusDays(1) is done to make sure // tmpFromDate.plusDays(1) is done to make sure
// getNewRepaymentMeetingDate method returns next meeting // getNewRepaymentMeetingDate method returns next meeting
// LocalDate and not the same as tmpFromDate // date and not the same as tmpFromDate
newRepaymentDate = CalendarUtils.getNewRepaymentMeetingDate(recuringRule, tmpFromDate, tmpFromDate.plusDays(1), newRepaymentDate = CalendarUtils.getNewRepaymentMeetingDate(recuringRule, tmpFromDate, tmpFromDate.plusDays(1),
loanRepaymentInterval, frequency, workingDays, isSkipRepaymentonfirstdayofmonth, numberofDays); loanRepaymentInterval, frequency, workingDays, isSkipRepaymentonfirstdayofmonth, numberofDays);
} }
@@ -4526,7 +4526,7 @@ public class Loan extends AbstractPersistableCustom {
latestRepaymentDate = newRepaymentDate; latestRepaymentDate = newRepaymentDate;
} }
loanRepaymentScheduleInstallment.updateDueDate(newRepaymentDate); loanRepaymentScheduleInstallment.updateDueDate(newRepaymentDate);
// reset from LocalDate to get actual daysInPeriod // reset from date to get actual daysInPeriod
if (!isFirstTime) { if (!isFirstTime) {
loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate); loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate);
@@ -4547,7 +4547,7 @@ public class Loan extends AbstractPersistableCustom {
final boolean isHolidayEnabled, final List<Holiday> holidays, final WorkingDays workingDays, final boolean isHolidayEnabled, final List<Holiday> holidays, final WorkingDays workingDays,
final boolean isSkipRepaymentonfirstdayofmonth, final Integer numberofDays) { final boolean isSkipRepaymentonfirstdayofmonth, final Integer numberofDays) {
// first repayment's from LocalDate is same as disbursement date. // first repayment's from date is same as disbursement date.
LocalDate tmpFromDate = getDisbursementDate(); LocalDate tmpFromDate = getDisbursementDate();
final PeriodFrequencyType repaymentPeriodFrequencyType = this.loanRepaymentScheduleDetail.getRepaymentPeriodFrequencyType(); final PeriodFrequencyType repaymentPeriodFrequencyType = this.loanRepaymentScheduleDetail.getRepaymentPeriodFrequencyType();
final Integer loanRepaymentInterval = this.loanRepaymentScheduleDetail.getRepayEvery(); final Integer loanRepaymentInterval = this.loanRepaymentScheduleDetail.getRepayEvery();
@@ -4584,7 +4584,7 @@ public class Loan extends AbstractPersistableCustom {
} }
loanRepaymentScheduleInstallment.updateDueDate(newRepaymentDate); loanRepaymentScheduleInstallment.updateDueDate(newRepaymentDate);
// reset from LocalDate to get actual daysInPeriod // reset from date to get actual daysInPeriod
loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate); loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate);
tmpFromDate = newRepaymentDate;// update with new repayment tmpFromDate = newRepaymentDate;// update with new repayment
// date // date
@@ -4619,7 +4619,7 @@ public class Loan extends AbstractPersistableCustom {
case WHOLE_TERM: case WHOLE_TERM:
break; break;
} }
return dueRepaymentPeriodDate.minusDays(1);// get 2n-1 range LocalDate from return dueRepaymentPeriodDate.minusDays(1);// get 2n-1 range date from
// startDate // startDate
} }
@@ -4667,7 +4667,7 @@ public class Loan extends AbstractPersistableCustom {
adjustedRescheduleToDate = holiday.getRepaymentsRescheduledToLocalDate(); adjustedRescheduleToDate = holiday.getRepaymentsRescheduledToLocalDate();
} }
// first repayment's from LocalDate is same as disbursement date. // first repayment's from date is same as disbursement date.
LocalDate tmpFromDate = getDisbursementDate(); LocalDate tmpFromDate = getDisbursementDate();
// Loop through all loanRepayments // Loop through all loanRepayments
@@ -4680,7 +4680,7 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate(); final LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate();
// update from LocalDate if it's not same as previous installament's due // update from date if it's not same as previous installament's due
// date. // date.
if (!loanRepaymentScheduleInstallment.getFromDate().isEqual(tmpFromDate)) { if (!loanRepaymentScheduleInstallment.getFromDate().isEqual(tmpFromDate)) {
loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate); loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate);
@@ -4688,7 +4688,7 @@ public class Loan extends AbstractPersistableCustom {
if (oldDueDate.equals(holiday.getFromDateLocalDate()) || oldDueDate.isAfter(holiday.getFromDateLocalDate())) { if (oldDueDate.equals(holiday.getFromDateLocalDate()) || oldDueDate.isAfter(holiday.getFromDateLocalDate())) {
// FIXME: AA do we need to apply non-working days. // FIXME: AA do we need to apply non-working days.
// Assuming holiday's repayment reschedule to LocalDate cannot be // Assuming holiday's repayment reschedule to date cannot be
// created on a non-working day. // created on a non-working day.
adjustedRescheduleToDate = scheduledDateGenerator.generateNextRepaymentDate(adjustedRescheduleToDate, loanApplicationTerms, adjustedRescheduleToDate = scheduledDateGenerator.generateNextRepaymentDate(adjustedRescheduleToDate, loanApplicationTerms,
@@ -4702,7 +4702,7 @@ public class Loan extends AbstractPersistableCustom {
private void validateDisbursementDateIsOnNonWorkingDay(final WorkingDays workingDays, final boolean allowTransactionsOnNonWorkingDay) { private void validateDisbursementDateIsOnNonWorkingDay(final WorkingDays workingDays, final boolean allowTransactionsOnNonWorkingDay) {
if (!allowTransactionsOnNonWorkingDay) { if (!allowTransactionsOnNonWorkingDay) {
if (!WorkingDaysUtil.isWorkingDay(workingDays, getDisbursementDate())) { if (!WorkingDaysUtil.isWorkingDay(workingDays, getDisbursementDate())) {
final String errorMessage = "Expected disbursement LocalDate cannot be on a non working day"; final String errorMessage = "Expected disbursement date cannot be on a non working day";
throw new LoanApplicationDateException("disbursement.date.on.non.working.day", errorMessage, throw new LoanApplicationDateException("disbursement.date.on.non.working.day", errorMessage,
getExpectedDisbursedOnLocalDate()); getExpectedDisbursedOnLocalDate());
} }
@@ -4712,7 +4712,7 @@ public class Loan extends AbstractPersistableCustom {
private void validateDisbursementDateIsOnHoliday(final boolean allowTransactionsOnHoliday, final List<Holiday> holidays) { private void validateDisbursementDateIsOnHoliday(final boolean allowTransactionsOnHoliday, final List<Holiday> holidays) {
if (!allowTransactionsOnHoliday) { if (!allowTransactionsOnHoliday) {
if (HolidayUtil.isHoliday(getDisbursementDate(), holidays)) { if (HolidayUtil.isHoliday(getDisbursementDate(), holidays)) {
final String errorMessage = "Expected disbursement LocalDate cannot be on a holiday"; final String errorMessage = "Expected disbursement date cannot be on a holiday";
throw new LoanApplicationDateException("disbursement.date.on.holiday", errorMessage, getExpectedDisbursedOnLocalDate()); throw new LoanApplicationDateException("disbursement.date.on.holiday", errorMessage, getExpectedDisbursedOnLocalDate());
} }
} }
@@ -4722,7 +4722,7 @@ public class Loan extends AbstractPersistableCustom {
final boolean allowTransactionsOnNonWorkingDay) { final boolean allowTransactionsOnNonWorkingDay) {
if (!allowTransactionsOnNonWorkingDay) { if (!allowTransactionsOnNonWorkingDay) {
if (!WorkingDaysUtil.isWorkingDay(workingDays, repaymentDate)) { if (!WorkingDaysUtil.isWorkingDay(workingDays, repaymentDate)) {
final String errorMessage = "Repayment LocalDate cannot be on a non working day"; final String errorMessage = "Repayment date cannot be on a non working day";
throw new LoanApplicationDateException("repayment.date.on.non.working.day", errorMessage, repaymentDate); throw new LoanApplicationDateException("repayment.date.on.non.working.day", errorMessage, repaymentDate);
} }
} }
@@ -4732,7 +4732,7 @@ public class Loan extends AbstractPersistableCustom {
final List<Holiday> holidays) { final List<Holiday> holidays) {
if (!allowTransactionsOnHoliday) { if (!allowTransactionsOnHoliday) {
if (HolidayUtil.isHoliday(repaymentDate, holidays)) { if (HolidayUtil.isHoliday(repaymentDate, holidays)) {
final String errorMessage = "Repayment LocalDate cannot be on a holiday"; final String errorMessage = "Repayment date cannot be on a holiday";
throw new LoanApplicationDateException("repayment.date.on.holiday", errorMessage, repaymentDate); throw new LoanApplicationDateException("repayment.date.on.holiday", errorMessage, repaymentDate);
} }
} }
@@ -4804,7 +4804,7 @@ public class Loan extends AbstractPersistableCustom {
public void validateExpectedDisbursementForHolidayAndNonWorkingDay(final WorkingDays workingDays, public void validateExpectedDisbursementForHolidayAndNonWorkingDay(final WorkingDays workingDays,
final boolean allowTransactionsOnHoliday, final List<Holiday> holidays, final boolean allowTransactionsOnNonWorkingDay) { final boolean allowTransactionsOnHoliday, final List<Holiday> holidays, final boolean allowTransactionsOnNonWorkingDay) {
// validate if disbursement LocalDate is a holiday or a non-working day // validate if disbursement date is a holiday or a non-working day
validateDisbursementDateIsOnNonWorkingDay(workingDays, allowTransactionsOnNonWorkingDay); validateDisbursementDateIsOnNonWorkingDay(workingDays, allowTransactionsOnNonWorkingDay);
validateDisbursementDateIsOnHoliday(allowTransactionsOnHoliday, holidays); validateDisbursementDateIsOnHoliday(allowTransactionsOnHoliday, holidays);
@@ -4819,22 +4819,22 @@ public class Loan extends AbstractPersistableCustom {
String postfix = null; String postfix = null;
switch (event) { switch (event) {
case LOAN_CREATED: case LOAN_CREATED:
errorMessage = "The LocalDate on which a loan is submitted cannot be earlier than client's transfer LocalDate to this office"; errorMessage = "The date on which a loan is submitted cannot be earlier than client's transfer date to this office";
action = "submittal"; action = "submittal";
postfix = "cannot.be.before.client.transfer.date"; postfix = "cannot.be.before.client.transfer.date";
break; break;
case LOAN_APPROVED: case LOAN_APPROVED:
errorMessage = "The LocalDate on which a loan is approved cannot be earlier than client's transfer LocalDate to this office"; errorMessage = "The date on which a loan is approved cannot be earlier than client's transfer date to this office";
action = "approval"; action = "approval";
postfix = "cannot.be.before.client.transfer.date"; postfix = "cannot.be.before.client.transfer.date";
break; break;
case LOAN_APPROVAL_UNDO: case LOAN_APPROVAL_UNDO:
errorMessage = "The LocalDate on which a loan is approved cannot be earlier than client's transfer LocalDate to this office"; errorMessage = "The date on which a loan is approved cannot be earlier than client's transfer date to this office";
action = "approval"; action = "approval";
postfix = "cannot.be.undone.before.client.transfer.date"; postfix = "cannot.be.undone.before.client.transfer.date";
break; break;
case LOAN_DISBURSED: case LOAN_DISBURSED:
errorMessage = "The LocalDate on which a loan is disbursed cannot be earlier than client's transfer LocalDate to this office"; errorMessage = "The date on which a loan is disbursed cannot be earlier than client's transfer date to this office";
action = "disbursal"; action = "disbursal";
postfix = "cannot.be.before.client.transfer.date"; postfix = "cannot.be.before.client.transfer.date";
break; break;
@@ -4844,37 +4844,37 @@ public class Loan extends AbstractPersistableCustom {
postfix = "cannot.be.undone.before.client.transfer.date"; postfix = "cannot.be.undone.before.client.transfer.date";
break; break;
case LOAN_REPAYMENT_OR_WAIVER: case LOAN_REPAYMENT_OR_WAIVER:
errorMessage = "The LocalDate on which a repayment or waiver is made cannot be earlier than client's transfer LocalDate to this office"; errorMessage = "The date on which a repayment or waiver is made cannot be earlier than client's transfer date to this office";
action = "repayment.or.waiver"; action = "repayment.or.waiver";
postfix = "cannot.be.made.before.client.transfer.date"; postfix = "cannot.be.made.before.client.transfer.date";
break; break;
case LOAN_REJECTED: case LOAN_REJECTED:
errorMessage = "The LocalDate on which a loan is rejected cannot be earlier than client's transfer LocalDate to this office"; errorMessage = "The date on which a loan is rejected cannot be earlier than client's transfer date to this office";
action = "reject"; action = "reject";
postfix = "cannot.be.before.client.transfer.date"; postfix = "cannot.be.before.client.transfer.date";
break; break;
case LOAN_WITHDRAWN: case LOAN_WITHDRAWN:
errorMessage = "The LocalDate on which a loan is withdrawn cannot be earlier than client's transfer LocalDate to this office"; errorMessage = "The date on which a loan is withdrawn cannot be earlier than client's transfer date to this office";
action = "withdraw"; action = "withdraw";
postfix = "cannot.be.before.client.transfer.date"; postfix = "cannot.be.before.client.transfer.date";
break; break;
case WRITE_OFF_OUTSTANDING: case WRITE_OFF_OUTSTANDING:
errorMessage = "The LocalDate on which a write off is made cannot be earlier than client's transfer LocalDate to this office"; errorMessage = "The date on which a write off is made cannot be earlier than client's transfer date to this office";
action = "writeoff"; action = "writeoff";
postfix = "cannot.be.undone.before.client.transfer.date"; postfix = "cannot.be.undone.before.client.transfer.date";
break; break;
case REPAID_IN_FULL: case REPAID_IN_FULL:
errorMessage = "The LocalDate on which the loan is repaid in full cannot be earlier than client's transfer LocalDate to this office"; errorMessage = "The date on which the loan is repaid in full cannot be earlier than client's transfer date to this office";
action = "close"; action = "close";
postfix = "cannot.be.undone.before.client.transfer.date"; postfix = "cannot.be.undone.before.client.transfer.date";
break; break;
case LOAN_CHARGE_PAYMENT: case LOAN_CHARGE_PAYMENT:
errorMessage = "The LocalDate on which a charge payment is made cannot be earlier than client's transfer LocalDate to this office"; errorMessage = "The date on which a charge payment is made cannot be earlier than client's transfer date to this office";
action = "charge.payment"; action = "charge.payment";
postfix = "cannot.be.made.before.client.transfer.date"; postfix = "cannot.be.made.before.client.transfer.date";
break; break;
case LOAN_REFUND: case LOAN_REFUND:
errorMessage = "The LocalDate on which a refund is made cannot be earlier than client's transfer LocalDate to this office"; errorMessage = "The date on which a refund is made cannot be earlier than client's transfer date to this office";
action = "refund"; action = "refund";
postfix = "cannot.be.made.before.client.transfer.date"; postfix = "cannot.be.made.before.client.transfer.date";
break; break;
@@ -4902,17 +4902,17 @@ public class Loan extends AbstractPersistableCustom {
String postfix = null; String postfix = null;
switch (event) { switch (event) {
case LOAN_REPAYMENT_OR_WAIVER: case LOAN_REPAYMENT_OR_WAIVER:
errorMessage = "The LocalDate on which a repayment or waiver is made cannot be earlier than last transaction date"; errorMessage = "The date on which a repayment or waiver is made cannot be earlier than last transaction date";
action = "repayment.or.waiver"; action = "repayment.or.waiver";
postfix = "cannot.be.made.before.last.transaction.date"; postfix = "cannot.be.made.before.last.transaction.date";
break; break;
case WRITE_OFF_OUTSTANDING: case WRITE_OFF_OUTSTANDING:
errorMessage = "The LocalDate on which a write off is made cannot be earlier than last transaction date"; errorMessage = "The date on which a write off is made cannot be earlier than last transaction date";
action = "writeoff"; action = "writeoff";
postfix = "cannot.be.made.before.last.transaction.date"; postfix = "cannot.be.made.before.last.transaction.date";
break; break;
case LOAN_CHARGE_PAYMENT: case LOAN_CHARGE_PAYMENT:
errorMessage = "The LocalDate on which a charge payment is made cannot be earlier than last transaction date"; errorMessage = "The date on which a charge payment is made cannot be earlier than last transaction date";
action = "charge.payment"; action = "charge.payment";
postfix = "cannot.be.made.before.last.transaction.date"; postfix = "cannot.be.made.before.last.transaction.date";
break; break;
@@ -5792,8 +5792,8 @@ public class Loan extends AbstractPersistableCustom {
/** /**
* @param dueDate * @param dueDate
* the due LocalDate of the installment * the due date of the installment
* @return a schedule installment with similar due LocalDate to the one provided * @return a schedule installment with similar due date to the one provided
**/ **/
public LoanRepaymentScheduleInstallment getRepaymentScheduleInstallment(LocalDate dueDate) { public LoanRepaymentScheduleInstallment getRepaymentScheduleInstallment(LocalDate dueDate) {
LoanRepaymentScheduleInstallment installment = null; LoanRepaymentScheduleInstallment installment = null;
@@ -6136,14 +6136,14 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate loanTransactionDate = loanTransaction.getTransactionDate(); final LocalDate loanTransactionDate = loanTransaction.getTransactionDate();
if (loanTransactionDate.isBefore(getDisbursementDate())) { if (loanTransactionDate.isBefore(getDisbursementDate())) {
final String errorMessage = "The transaction LocalDate cannot be before the loan disbursement date: " final String errorMessage = "The transaction date cannot be before the loan disbursement date: "
+ getApprovedOnDate().toString(); + getApprovedOnDate().toString();
throw new InvalidLoanStateTransitionException("transaction", "cannot.be.before.disbursement.date", errorMessage, throw new InvalidLoanStateTransitionException("transaction", "cannot.be.before.disbursement.date", errorMessage,
loanTransactionDate, getDisbursementDate()); loanTransactionDate, getDisbursementDate());
} }
if (loanTransactionDate.isAfter(DateUtils.getBusinessLocalDate())) { if (loanTransactionDate.isAfter(DateUtils.getBusinessLocalDate())) {
final String errorMessage = "The transaction LocalDate cannot be in the future."; final String errorMessage = "The transaction date cannot be in the future.";
throw new InvalidLoanStateTransitionException("transaction", "cannot.be.a.future.date", errorMessage, loanTransactionDate); throw new InvalidLoanStateTransitionException("transaction", "cannot.be.a.future.date", errorMessage, loanTransactionDate);
} }
@@ -6378,9 +6378,9 @@ public class Loan extends AbstractPersistableCustom {
if (isMultiDisburmentLoan() && loanCharge.getCharge().getChargeTimeType().equals(ChargeTimeType.DISBURSEMENT.getValue())) { if (isMultiDisburmentLoan() && loanCharge.getCharge().getChargeTimeType().equals(ChargeTimeType.DISBURSEMENT.getValue())) {
amount = getApprovedPrincipal(); amount = getApprovedPrincipal();
} else { } else {
// If charge type is specified due LocalDate and loan is multi disburment // If charge type is specified due date and loan is multi disburment
// loan. // loan.
// Then we need to get as of this loan charge due LocalDate how much // Then we need to get as of this loan charge due date how much
// amount disbursed. // amount disbursed.
if (loanCharge.isSpecifiedDueDate() && this.isMultiDisburmentLoan()) { if (loanCharge.isSpecifiedDueDate() && this.isMultiDisburmentLoan()) {
for (final LoanDisbursementDetails loanDisbursementDetails : this.getDisbursementDetails()) { for (final LoanDisbursementDetails loanDisbursementDetails : this.getDisbursementDetails()) {