MIFOSX-1235,MIFOSX-1365,MIFSOX-1204

This commit is contained in:
Madhukar
2014-06-24 23:42:09 +05:30
parent 5ae0e0f62c
commit 2d7b1d9cf4
8 changed files with 157 additions and 14 deletions
@@ -10,7 +10,7 @@ import java.util.Map;
public enum GLAccountType {
ASSET(1, "accountType.asset"), LIABILITY(2, "accountType.liability"), EQUITY(3, "accountType.equity"), INCOME(4, "accountType.income"), EXPENSE(
5, "accountType.expense"), ;
5, "accountType.expense");
private final Integer value;
private final String code;
@@ -1662,7 +1662,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
// Update client loan counter if loan product includeInBorrowerCycle
// is true
if (loanToUpdate.loanProduct().isIncludeInBorrowerCycle()) {
Integer currentLoanCounter = loanToUpdate.getCurrentLoanCounter();
Integer currentLoanCounter = loanToUpdate.getCurrentLoanCounter() == null ? 1 : loanToUpdate.getCurrentLoanCounter();
if (newLoanCounter > currentLoanCounter) {
newLoanCounter = currentLoanCounter;
}
@@ -1872,7 +1872,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
}
if (savingsAccountCharge.isAnnualFee() || savingsAccountCharge.isMonthlyFee()) {
if (savingsAccountCharge.isAnnualFee() || savingsAccountCharge.isMonthlyFee() || savingsAccountCharge.isWeeklyFee()) {
// update due date
if (isActive()) {
savingsAccountCharge.updateToNextDueDateFrom(getActivationLocalDate());
@@ -155,14 +155,6 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
}
if (isWeeklyFee()) {
if (dueDate == null) {
final String defaultUserMessage = "Savings Account charge is missing due date.";
throw new SavingsAccountChargeWithoutMandatoryFieldException("savingsaccount.charge", dueAsOfDateParamName,
defaultUserMessage, chargeDefinition.getId(), chargeDefinition.getName());
}
}
if (isAnnualFee() || isMonthlyFee()) {
feeOnMonthDay = (feeOnMonthDay == null) ? chargeDefinition.getFeeOnMonthDay() : feeOnMonthDay;
if (feeOnMonthDay == null) {
@@ -174,6 +166,17 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
this.feeOnMonth = feeOnMonthDay.getMonthOfYear();
this.feeOnDay = feeOnMonthDay.getDayOfMonth();
} else if (isWeeklyFee()) {
if (dueDate == null) {
final String defaultUserMessage = "Savings Account charge is missing due date.";
throw new SavingsAccountChargeWithoutMandatoryFieldException("savingsaccount.charge", dueAsOfDateParamName,
defaultUserMessage, chargeDefinition.getId(), chargeDefinition.getName());
}
/**
* For Weekly fee feeOnDay is ISO standard day of the week.
* Monday=1, Tuesday=2
*/
this.feeOnDay = dueDate.getDayOfWeek();
} else {
this.feeOnDay = null;
this.feeOnMonth = null;
@@ -355,6 +358,9 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
final BigDecimal transactionAmount = BigDecimal.ZERO;
if (dueDate != null) {
this.dueDate = dueDate.toDate();
if (isWeeklyFee()) {
this.feeOnDay = dueDate.getDayOfWeek();
}
}
if (feeOnMonthDay != null) {
@@ -410,6 +416,9 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
final LocalDate newValue = command.localDateValueOfParameterNamed(dueAsOfDateParamName);
this.dueDate = newValue.toDate();
if (this.isWeeklyFee()) {
this.feeOnDay = newValue.getDayOfWeek();
}
}
if (command.hasParameter(feeOnMonthDayParamName)) {
@@ -696,6 +705,11 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
while (startingDate.isAfter(nextDueLocalDate)) {
nextDueLocalDate = calculateNextDueDate(nextDueLocalDate);
}
} else if (isWeeklyFee()) {
nextDueLocalDate = getDueLocalDate();
while (startingDate.isAfter(nextDueLocalDate)) {
nextDueLocalDate = calculateNextDueDate(nextDueLocalDate);
}
} else {
nextDueLocalDate = calculateNextDueDate(startingDate);
}
@@ -714,7 +728,8 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
nextDueLocalDate = date.plusMonths(this.feeInterval);
nextDueLocalDate = setDayOfMonth(nextDueLocalDate);
} else if (isWeeklyFee()) {
nextDueLocalDate = date.plusDays(7 * this.feeInterval);
nextDueLocalDate = date.plusWeeks(this.feeInterval);
nextDueLocalDate = setDayOfWeek(nextDueLocalDate);
}
return nextDueLocalDate;
}
@@ -726,6 +741,13 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
return nextDueLocalDate;
}
private LocalDate setDayOfWeek(LocalDate nextDueLocalDate) {
if (this.feeOnDay != nextDueLocalDate.getDayOfWeek()) {
nextDueLocalDate = nextDueLocalDate.withDayOfWeek(this.feeOnDay);
}
return nextDueLocalDate;
}
public void updateNextDueDateForRecurringFees() {
if (isAnnualFee() || isMonthlyFee() || isWeeklyFee()) {
LocalDate nextDueLocalDate = new LocalDate(dueDate);