FINERACT-2665: Fix NPE modifying a loan application when schedule fields are omitted#6059
Open
oluexpert99 wants to merge 1 commit into
Open
FINERACT-2665: Fix NPE modifying a loan application when schedule fields are omitted#6059oluexpert99 wants to merge 1 commit into
oluexpert99 wants to merge 1 commit into
Conversation
…lds are omitted - On modify, LoanScheduleAssembler.assembleLoanApplicationTermsFrom rebuilds the loan terms from the request JSON. A modify request may legitimately send only the fields being changed (LoanApplicationValidator .validateForModify already treats the rest as optional), but the recalculation read each schedule-driving field straight from the request: an omitted override-enabled enum hit XxxMethod.fromInt(null) and an omitted expectedDisbursementDate hit deriveFirstRepaymentDate(null), both throwing a NullPointerException (HTTP 500) once the change triggered a schedule recalculation. This completes FINERACT-2389, which applied null-override handling only to the grace/tolerance fields. - Before recalculating, backfill any omitted schedule-driving field from the loan's own values (LoanAssemblerImpl.updateFrom -> backfillOmittedScheduleTerms) so the regenerated schedule matches what the loan records rather than a product default or null: interestType, amortizationType, interestCalculationPeriodType, repaymentEvery, numberOfRepayments, repaymentFrequencyType, loanTermFrequency, loanTermFrequencyType, interestRateFrequencyType, graceOnPrincipalPayment, graceOnInterestPayment, graceOnArrearsAgeing, principal, interestRatePerPeriod, expectedDisbursementDate, submittedOnDate and interestChargedFromDate. This mirrors validateForModify, so validation and recalculation stay consistent. - Date fields are re-serialised with the request's own dateFormat/locale, exactly as loan creation requires them; if a date must be backfilled and either parameter is missing or malformed, fail with a clear validation error rather than defaulting. - Add unit tests for the backfill helper, the date-formatter required-parameter handling, and the schedule-term backfill from a loan. Signed-off-by: oluexpert99 <farooq@techservicehub.io>
4394787 to
50ab7b0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JSON. A modify request may legitimately send only the fields being changed (LoanApplicationValidator
.validateForModify already treats the rest as optional), but the recalculation read each schedule-driving
field straight from the request: an omitted override-enabled enum hit XxxMethod.fromInt(null) and an omitted
expectedDisbursementDate hit deriveFirstRepaymentDate(null), both throwing a NullPointerException (HTTP 500)
once the change triggered a schedule recalculation. This completes FINERACT-2389, which applied null-override
handling only to the grace/tolerance fields.
(LoanAssemblerImpl.updateFrom -> backfillOmittedScheduleTerms) so the regenerated schedule matches what the
loan records rather than a product default or null: interestType, amortizationType,
interestCalculationPeriodType, repaymentEvery, numberOfRepayments, repaymentFrequencyType, loanTermFrequency,
loanTermFrequencyType, interestRateFrequencyType, graceOnPrincipalPayment, graceOnInterestPayment,
graceOnArrearsAgeing, principal, interestRatePerPeriod, expectedDisbursementDate, submittedOnDate and
interestChargedFromDate. This mirrors validateForModify, so validation and recalculation stay consistent.
them; if a date must be backfilled and either parameter is missing or malformed, fail with a clear
validation error rather than defaulting.
schedule-term backfill from a loan.
Description
Describe the changes made and why they were made. (Ignore if these details are present on the associated Apache Fineract JIRA ticket.)
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Your assigned reviewer(s) will follow our guidelines for code reviews.