From 20f292d329612bf0884417349ced25ffb8147a99 Mon Sep 17 00:00:00 2001 From: Vishwas Babu A J Date: Wed, 14 Jan 2015 09:29:42 -0800 Subject: [PATCH] MIFOSX-1841 --- .../savings/domain/SavingsAccountCharge.java | 40 +++++++++---------- ...WritePlatformServiceJpaRepositoryImpl.java | 2 +- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountCharge.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountCharge.java index 746373155..fb3da312d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountCharge.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountCharge.java @@ -708,25 +708,27 @@ public class SavingsAccountCharge extends AbstractPersistable { 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 { 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; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java index 80b2101ef..04e2a5721 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java @@ -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");