From 2d9ee2eadfcfc4fd3f54b334e10c09380ad9af26 Mon Sep 17 00:00:00 2001 From: ashok-conflux Date: Tue, 29 Oct 2013 17:07:59 +0530 Subject: [PATCH] updated montly recurring charge start dateto be after savings account activagtion date --- .../savings/domain/SavingsAccountCharge.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 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 2de297d44..61d7cd9e4 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 @@ -665,6 +665,10 @@ public class SavingsAccountCharge extends AbstractPersistable { public void updateToNextDueDateFrom(final LocalDate startingDate) { if (isAnnualFee() || isMonthlyFee()) { LocalDate nextDueLocalDate = startingDate.withMonthOfYear(this.feeOnMonth); + int maxDayOfMonth = nextDueLocalDate.dayOfMonth().withMaximumValue().getDayOfMonth(); + int newDayOfMonth = (this.feeOnDay.intValue() <= maxDayOfMonth) ? this.feeOnDay.intValue() : maxDayOfMonth; + nextDueLocalDate = nextDueLocalDate.withDayOfMonth(newDayOfMonth); + while (startingDate.isAfter(nextDueLocalDate)) { if (isAnnualFee()) { nextDueLocalDate = nextDueLocalDate.plusYears(1); @@ -672,10 +676,7 @@ public class SavingsAccountCharge extends AbstractPersistable { nextDueLocalDate = nextDueLocalDate.plusMonths(this.feeInterval); } } - //set day of month - int maxDayOfMonth = nextDueLocalDate.dayOfMonth().withMaximumValue().getDayOfMonth(); - int newDayOfMonth = (this.feeOnDay.intValue() <= maxDayOfMonth) ? this.feeOnDay.intValue() : maxDayOfMonth; - nextDueLocalDate = nextDueLocalDate.withDayOfMonth(newDayOfMonth); + this.dueDate = nextDueLocalDate.toDate(); } } @@ -683,17 +684,16 @@ public class SavingsAccountCharge extends AbstractPersistable { public void updateToNextDueDate() { if(isAnnualFee() || isMonthlyFee()){ LocalDate nextDueLocalDate = new LocalDate(dueDate); + int maxDayOfMonth = nextDueLocalDate.dayOfMonth().withMaximumValue().getDayOfMonth(); + int newDayOfMonth = (this.feeOnDay.intValue() < maxDayOfMonth) ? this.feeOnDay.intValue() : maxDayOfMonth; + nextDueLocalDate = nextDueLocalDate.withDayOfMonth(newDayOfMonth); + if(isAnnualFee()){ nextDueLocalDate = nextDueLocalDate.withMonthOfYear(this.feeOnMonth).plusYears(1); }else if(isMonthlyFee()){ nextDueLocalDate = nextDueLocalDate.plusMonths(this.feeInterval); } - - //set day of month - int maxDayOfMonth = nextDueLocalDate.dayOfMonth().withMaximumValue().getDayOfMonth(); - int newDayOfMonth = (this.feeOnDay.intValue() < maxDayOfMonth) ? this.feeOnDay.intValue() : maxDayOfMonth; - nextDueLocalDate = nextDueLocalDate.withDayOfMonth(newDayOfMonth); - + this.dueDate = nextDueLocalDate.toDate(); } }