MIFOSX-1841

This commit is contained in:
Vishwas Babu A J
2015-01-14 09:29:42 -08:00
parent bd689bc008
commit 20f292d329
2 changed files with 20 additions and 22 deletions
@@ -708,25 +708,27 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
public void updateToNextDueDateFrom(final LocalDate startingDate) {
if (isAnnualFee() || isMonthlyFee() || isWeeklyFee()) {
LocalDate nextDueLocalDate = null;
if (isAnnualFee() || isMonthlyFee()) {
nextDueLocalDate = startingDate.withMonthOfYear(this.feeOnMonth);
nextDueLocalDate = setDayOfMonth(nextDueLocalDate);
while (startingDate.isAfter(nextDueLocalDate)) {
nextDueLocalDate = calculateNextDueDate(nextDueLocalDate);
}
} else if (isWeeklyFee()) {
nextDueLocalDate = getDueLocalDate();
while (startingDate.isAfter(nextDueLocalDate)) {
nextDueLocalDate = calculateNextDueDate(nextDueLocalDate);
}
} else {
nextDueLocalDate = calculateNextDueDate(startingDate);
}
this.dueDate = nextDueLocalDate.toDate();
this.dueDate = getNextDueDateFrom(startingDate).toDate();
}
}
public LocalDate getNextDueDateFrom(final LocalDate startingDate) {
LocalDate nextDueLocalDate = null;
if (isAnnualFee() || isMonthlyFee()) {
nextDueLocalDate = startingDate.withMonthOfYear(this.feeOnMonth);
nextDueLocalDate = setDayOfMonth(nextDueLocalDate);
while (startingDate.isAfter(nextDueLocalDate)) {
nextDueLocalDate = calculateNextDueDate(nextDueLocalDate);
}
} else if (isWeeklyFee()) {
nextDueLocalDate = getDueLocalDate();
while (startingDate.isAfter(nextDueLocalDate)) {
nextDueLocalDate = calculateNextDueDate(nextDueLocalDate);
}
} else {
nextDueLocalDate = calculateNextDueDate(startingDate);
}
return nextDueLocalDate;
}
private LocalDate calculateNextDueDate(final LocalDate date) {
@@ -809,10 +811,6 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
return this.amountPaid;
}
public LocalDate nextDuDate(final LocalDate date) {
return calculateNextDueDate(date);
}
public void inactiavateCharge(final LocalDate inactivationOnDate) {
this.inactivationDate = inactivationOnDate.toDate();
this.status = false;
@@ -1052,7 +1052,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
} else {
final LocalDate nextDueDate = savingsAccountCharge.nextDuDate(inactivationOnDate);
final LocalDate nextDueDate = savingsAccountCharge.getNextDueDateFrom(inactivationOnDate);
if (savingsAccountCharge.isChargeIsDue(nextDueDate)) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("inactivation.of.charge.not.allowed.when.charge.is.due");