Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public List<LocalDateInterval> determineInterestPostingPeriods(final LocalDate s
final Integer financialYearBeginningMonth, List<LocalDate> postInterestAsOn) {

final List<LocalDateInterval> postingPeriods = new ArrayList<>();

if (startInterestCalculationLocalDate == null || interestPostingUpToDate == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain this new condition and why it is the correct behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The null check prevents a NullPointerException that occurs when either startInterestCalculationLocalDate or interestPostingUpToDate is null.

DateUtils.isAfter() at line 64 throws NPE when comparing null dates, This happens when closing a Fixed Deposit account where depositPeriodFrequencyType is INVALID, causing the maturity date (and subsequently interestPostingUpToDate) to be null

If either date is null, there are no valid interest posting periods to determine

  • An empty list semantically means "no posting periods" - which is accurate when dates are undefined
  • This allows the calling code (e.g., account closure) to continue gracefully

I've also rebased the PR with the latest develop branch as requested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what situations can these values be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interestPostingUpToDate can be null when:
depositPeriodFrequencyType is INVALID: In FixedDepositAccount.calculateMaturityDate(), the switch statement handles DAYS, WEEKS, MONTHS, and YEARS, but when depositPeriodFrequencyType is INVALID, it falls through with an empty break, leaving maturityDate as null:

Database has null/invalid deposit_period_frequency_enum: SavingsPeriodFrequencyType.fromInt() returns INVALID when the input is null or an unrecognized value. The column deposit_period_frequency_enum is marked as nullable = true in DepositAccountTermAndPreClosure

Account reinvestment: DepositAccountTermAndPreClosure.copy() explicitly sets maturityDate = null when creating a copy for reinvestment.

startInterestCalculationLocalDate can be null when:
Account in early submission state: accountSubmittedOrActivationDate() could return null if both activationDate and submittedOnDate are null.

return postingPeriods;
}

LocalDate periodStartDate = startInterestCalculationLocalDate;
LocalDate periodEndDate = periodStartDate;
LocalDate actualPeriodStartDate = periodStartDate;
Expand Down
Loading