null checks for fixing failing test cases in RD
This commit is contained in:
+4
-5
@@ -181,12 +181,12 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getExpectedFirstDepositOnDate() {
|
public LocalDate getExpectedFirstDepositOnDate() {
|
||||||
LocalDate expectedFirstDepositOnLocalDate = null;
|
LocalDate expectedFirstDepositOnLocalDate = null;
|
||||||
if (this.expectedFirstDepositOnDate != null) {
|
if (this.expectedFirstDepositOnDate != null) {
|
||||||
expectedFirstDepositOnLocalDate = new LocalDate(this.expectedFirstDepositOnDate);
|
expectedFirstDepositOnLocalDate = new LocalDate(this.expectedFirstDepositOnDate);
|
||||||
}
|
}
|
||||||
return expectedFirstDepositOnLocalDate;
|
return expectedFirstDepositOnLocalDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPreClosurePenalApplicable() {
|
public boolean isPreClosurePenalApplicable() {
|
||||||
if (this.preClosureDetail != null) { return this.preClosureDetail.preClosurePenalApplicable(); }
|
if (this.preClosureDetail != null) { return this.preClosureDetail.preClosurePenalApplicable(); }
|
||||||
@@ -196,8 +196,7 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistable<Long> {
|
|||||||
public Integer getActualDepositPeriod(final LocalDate interestPostingUpToDate, final SavingsPeriodFrequencyType periodFrequencyType) {
|
public Integer getActualDepositPeriod(final LocalDate interestPostingUpToDate, final SavingsPeriodFrequencyType periodFrequencyType) {
|
||||||
LocalDate depositFromDate = getExpectedFirstDepositOnDate();
|
LocalDate depositFromDate = getExpectedFirstDepositOnDate();
|
||||||
|
|
||||||
if(depositFromDate == null)
|
if (depositFromDate == null) depositFromDate = this.account.accountSubmittedOrActivationDate();
|
||||||
depositFromDate = this.account.accountSubmittedOrActivationDate();
|
|
||||||
|
|
||||||
Integer actualDepositPeriod = this.depositPeriod;
|
Integer actualDepositPeriod = this.depositPeriod;
|
||||||
if (depositFromDate == null || getMaturityLocalDate() == null || interestPostingUpToDate.isEqual(getMaturityLocalDate())) { return actualDepositPeriod; }
|
if (depositFromDate == null || getMaturityLocalDate() == null || interestPostingUpToDate.isEqual(getMaturityLocalDate())) { return actualDepositPeriod; }
|
||||||
|
|||||||
+25
-21
@@ -100,9 +100,9 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
recurringDetail, chart, allowOverdraft, overdraftLimit);
|
recurringDetail, chart, allowOverdraft, overdraftLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RecurringDepositAccount createNewActivatedAccount(final Client client, final Group group,
|
public static RecurringDepositAccount createNewActivatedAccount(final Client client, final Group group, final SavingsProduct product,
|
||||||
final SavingsProduct product, final Staff fieldOfficer, final String accountNo, final String externalId,
|
final Staff fieldOfficer, final String accountNo, final String externalId, final AccountType accountType,
|
||||||
final AccountType accountType, final LocalDate submittedOnDate, final AppUser submittedBy, final BigDecimal interestRate,
|
final LocalDate submittedOnDate, final AppUser submittedBy, final BigDecimal interestRate,
|
||||||
final SavingsCompoundingInterestPeriodType interestCompoundingPeriodType,
|
final SavingsCompoundingInterestPeriodType interestCompoundingPeriodType,
|
||||||
final SavingsPostingInterestPeriodType interestPostingPeriodType, final SavingsInterestCalculationType interestCalculationType,
|
final SavingsPostingInterestPeriodType interestPostingPeriodType, final SavingsInterestCalculationType interestCalculationType,
|
||||||
final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final BigDecimal minRequiredOpeningBalance,
|
final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final BigDecimal minRequiredOpeningBalance,
|
||||||
@@ -272,8 +272,8 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType
|
final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType
|
||||||
.fromInt(this.interestCalculationDaysInYearType);
|
.fromInt(this.interestCalculationDaysInYearType);
|
||||||
|
|
||||||
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(
|
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(depositStartDate(),
|
||||||
depositStartDate(), maturityDate, postingPeriodType);
|
maturityDate, postingPeriodType);
|
||||||
|
|
||||||
final List<PostingPeriod> allPostingPeriods = new ArrayList<PostingPeriod>();
|
final List<PostingPeriod> allPostingPeriods = new ArrayList<PostingPeriod>();
|
||||||
|
|
||||||
@@ -380,8 +380,7 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
// TODO: Support to add deposit start date which can be a date after
|
// TODO: Support to add deposit start date which can be a date after
|
||||||
// account activation date.
|
// account activation date.
|
||||||
final LocalDate depositStartDate = accountTermAndPreClosure.getExpectedFirstDepositOnDate();
|
final LocalDate depositStartDate = accountTermAndPreClosure.getExpectedFirstDepositOnDate();
|
||||||
if(depositStartDate == null)
|
if (depositStartDate == null) return accountSubmittedOrActivationDate();
|
||||||
return accountSubmittedOrActivationDate();
|
|
||||||
return depositStartDate;
|
return depositStartDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -806,20 +805,23 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
|
|
||||||
final boolean firstDepositDateBeforeMaturityAndOnOrAfterActivationDate = firstDepositDateBeforeMaturityAndOnOrAfterActivationDate();
|
final boolean firstDepositDateBeforeMaturityAndOnOrAfterActivationDate = firstDepositDateBeforeMaturityAndOnOrAfterActivationDate();
|
||||||
|
|
||||||
if(!firstDepositDateBeforeMaturityAndOnOrAfterActivationDate) {
|
if (!firstDepositDateBeforeMaturityAndOnOrAfterActivationDate) {
|
||||||
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("expected.first.deposit.date.is.not.between.maturity.date.and.activation.or.submitted.date");
|
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
|
||||||
|
"expected.first.deposit.date.is.not.between.maturity.date.and.activation.or.submitted.date");
|
||||||
}
|
}
|
||||||
|
|
||||||
final BigDecimal recurringDepositAmount = recurringDetail.recurringDepositAmount();
|
final BigDecimal recurringDepositAmount = recurringDetail.recurringDepositAmount();
|
||||||
BigDecimal applicableInterestRate = this.chart.getApplicableInterestRate(recurringDepositAmount, depositStartDate(), calculateMaturityDate());
|
BigDecimal applicableInterestRate = this.chart.getApplicableInterestRate(recurringDepositAmount, depositStartDate(),
|
||||||
|
calculateMaturityDate());
|
||||||
|
|
||||||
if(applicableInterestRate.equals(BigDecimal.ZERO)) {
|
if (applicableInterestRate.equals(BigDecimal.ZERO)) {
|
||||||
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("no.applicable.interest.rate.is.found.based.on.amount.and.deposit.period");
|
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
|
||||||
|
"no.applicable.interest.rate.is.found.based.on.amount.and.deposit.period");
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean recurringFrequencyBeforeDepositPeriod = recurringFrequencyBeforeDepositPeriod();
|
final boolean recurringFrequencyBeforeDepositPeriod = recurringFrequencyBeforeDepositPeriod();
|
||||||
|
|
||||||
if(!recurringFrequencyBeforeDepositPeriod) {
|
if (!recurringFrequencyBeforeDepositPeriod) {
|
||||||
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("recurring.frequency.not.before.deposit.period");
|
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("recurring.frequency.not.before.deposit.period");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -859,13 +861,14 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
|
|
||||||
newAccountTermAndPreClosure.updateExpectedFirstDepositDate(now);
|
newAccountTermAndPreClosure.updateExpectedFirstDepositDate(now);
|
||||||
|
|
||||||
RecurringDepositAccount rdAccount = RecurringDepositAccount.createNewActivatedAccount(client, group, product, fieldOfficer, accountNumber, externalId,
|
RecurringDepositAccount rdAccount = RecurringDepositAccount.createNewActivatedAccount(client, group, product, fieldOfficer,
|
||||||
accountType, getClosedOnDate(), closedBy, interestRate, compoundingPeriodType, postingPeriodType, interestCalculationType,
|
accountNumber, externalId, accountType, getClosedOnDate(), closedBy, interestRate, compoundingPeriodType,
|
||||||
daysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency, lockinPeriodFrequencyType,
|
postingPeriodType, interestCalculationType, daysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency,
|
||||||
withdrawalFeeApplicableForTransfer, savingsAccountCharges, newAccountTermAndPreClosure, recurringDetail, newChart);
|
lockinPeriodFrequencyType, withdrawalFeeApplicableForTransfer, savingsAccountCharges, newAccountTermAndPreClosure,
|
||||||
|
recurringDetail, newChart);
|
||||||
|
|
||||||
rdAccount.setDatesFrom(now);
|
rdAccount.setDatesFrom(now);
|
||||||
newAccountTermAndPreClosure.updateAccountReference(rdAccount);
|
newAccountTermAndPreClosure.updateAccountReference(rdAccount);
|
||||||
recurringDetail.updateAccountReference(rdAccount);
|
recurringDetail.updateAccountReference(rdAccount);
|
||||||
|
|
||||||
return rdAccount;
|
return rdAccount;
|
||||||
@@ -876,9 +879,10 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
LocalDate expectedFirstDepositLocalDate = accountTermAndPreClosure.getExpectedFirstDepositOnDate();
|
LocalDate expectedFirstDepositLocalDate = accountTermAndPreClosure.getExpectedFirstDepositOnDate();
|
||||||
LocalDate maturityLocalDate = calculateMaturityDate();
|
LocalDate maturityLocalDate = calculateMaturityDate();
|
||||||
LocalDate activateOnSubmittedLocalDate = accountSubmittedOrActivationDate();
|
LocalDate activateOnSubmittedLocalDate = accountSubmittedOrActivationDate();
|
||||||
|
if (expectedFirstDepositLocalDate != null) { return expectedFirstDepositLocalDate.isBefore(maturityLocalDate)
|
||||||
return expectedFirstDepositLocalDate.isBefore(maturityLocalDate) &&
|
&& (activateOnSubmittedLocalDate.isEqual(expectedFirstDepositLocalDate) || activateOnSubmittedLocalDate
|
||||||
(activateOnSubmittedLocalDate.isEqual(expectedFirstDepositLocalDate) || activateOnSubmittedLocalDate.isBefore(expectedFirstDepositLocalDate));
|
.isBefore(expectedFirstDepositLocalDate)); }
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDatesFrom(final LocalDate now) {
|
public void setDatesFrom(final LocalDate now) {
|
||||||
|
|||||||
Reference in New Issue
Block a user