-
Notifications
You must be signed in to change notification settings - Fork 849
WEB-685 Fix default values for due overdue days repayment event fields in loan product creation #3116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
…s in loan product creation
|
Note
|
| Cohort / File(s) | Summary |
|---|---|
Repayment Event Configuration Logic src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts |
Modified conditional patching of repayment event day fields during edit mode to only update when both dueDaysForRepaymentEvent and overDueDaysForRepaymentEvent exist; non-edit mode now explicitly sets useDueForRepaymentsConfigurations to false and clears fields to empty strings instead of null values. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
- WEB-569 Negative values allowed for repayment event days in loan product creation form #2984: Modifies the same repayment event day fields by adding min(0) validation and input constraints, complementing the patching logic changes in this PR.
Suggested reviewers
- IOhacker
- alberto-art3ch
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly and specifically describes the main change: fixing default values for due/overdue days repayment event fields in loan product creation, which aligns with the code changes. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
- 📝 Generate docstrings
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
No actionable comments were generated in the recent review. 🎉
🧹 Recent nitpick comments
src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts (1)
172-195: Fragile interaction:patchValuetriggersvalueChangesmid-patch, relying on object key order.Setting
useDueForRepaymentsConfigurationsinside the samepatchValuecall that also setsdueDaysForRepaymentEvent/overDueDaysForRepaymentEventcauses thevalueChangessubscription (line 662) to fire synchronously mid-patch. That subscription patches the same two fields to eithernull(whentrue) or global-config values (whenfalse). The final field values are only correct because JavaScript iterates object keys in insertion order, so the explicit''values win.This is subtle and easy to break in a future refactor. A safer approach is to separate the two patches so the subscription completes first:
Suggested refactor
if (this.toEdit) { if ( this.loanProductsTemplate.dueDaysForRepaymentEvent != null && this.loanProductsTemplate.overDueDaysForRepaymentEvent != null ) { - this.loanProductSettingsForm.patchValue({ - useDueForRepaymentsConfigurations: false, - dueDaysForRepaymentEvent: this.loanProductsTemplate.dueDaysForRepaymentEvent, - overDueDaysForRepaymentEvent: this.loanProductsTemplate.overDueDaysForRepaymentEvent - }); + this.loanProductSettingsForm.patchValue({ useDueForRepaymentsConfigurations: false }); + this.loanProductSettingsForm.patchValue({ + dueDaysForRepaymentEvent: this.loanProductsTemplate.dueDaysForRepaymentEvent, + overDueDaysForRepaymentEvent: this.loanProductsTemplate.overDueDaysForRepaymentEvent + }); } else { - this.loanProductSettingsForm.patchValue({ - useDueForRepaymentsConfigurations: true, - dueDaysForRepaymentEvent: '', - overDueDaysForRepaymentEvent: '' - }); + this.loanProductSettingsForm.patchValue({ useDueForRepaymentsConfigurations: true }); + this.loanProductSettingsForm.patchValue({ + dueDaysForRepaymentEvent: '', + overDueDaysForRepaymentEvent: '' + }); } } else { - this.loanProductSettingsForm.patchValue({ - useDueForRepaymentsConfigurations: false, - dueDaysForRepaymentEvent: '', - overDueDaysForRepaymentEvent: '' - }); + this.loanProductSettingsForm.patchValue({ useDueForRepaymentsConfigurations: false }); + this.loanProductSettingsForm.patchValue({ + dueDaysForRepaymentEvent: '', + overDueDaysForRepaymentEvent: '' + }); }
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
alberto-art3ch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we review this requiremente? Because those two product parameters by default will came from Global Configuration variables (useDueForRepaymentsConfigurations = true)
The users (If they want) can to override them, but by default the initial values must be from the configurations
Changes Made :-
-Changed default values for [dueDaysForRepaymentEvent and [overDueDaysForRepaymentEvent] fields from inheriting global configuration value to empty string, allowing users to enter their own values when creating new loan products while preserving existing values when editing.
WEB-685
Before :-
After :-
Summary by CodeRabbit