WEB-568 Negative values allowed for arrears ageing overdue days for npa and principal threshold fields in loan product settings#2983
Conversation
…NPA, and Principal Threshold Fields in Loan Product Settings
|
Note
|
| Cohort / File(s) | Summary |
|---|---|
Loan Product Settings Form Validation src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.html |
Added min="0" constraint to three numeric input fields: graceOnArrearsAgeing, overdueDaysForNPA, and principalThresholdForLastInstallment at the template level. |
Loan Product Settings Form Controls src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts |
Added Validators.min(0) validator to the same three form controls in createLoanProductSettingsForm method, replacing bare string initializers with validator arrays. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
- WEB-567 Negative Values Allowed in Loan Product Setting Fields #2982: Modifies the same LoanProductSettingsStepComponent with similar
Validators.min(0)andmin="0"constraints added to different numeric loan-setting fields.
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 accurately describes the main change: adding validation to prevent negative values for three specific numeric fields in the loan product settings form. |
| 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
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.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.html (3)
385-385: Consider adding validation error messages for better UX.The
min="0"attribute provides client-side validation, but users won't see feedback when they enter invalid values. Consider adding error display logic similar to other fields in this template (e.g., lines 209-221 fordisbursedAmountPercentageForDownPayment).💡 Example error message implementation
<mat-form-field class="flex-48"> <mat-label>{{ 'labels.inputs.On arrears ageing' | translate }}</mat-label> <input type="number" min="0" matInput formControlName="graceOnArrearsAgeing" /> + @if (loanProductSettingsForm.controls.graceOnArrearsAgeing.hasError('min')) { + <mat-error> + {{ 'labels.inputs.On arrears ageing' | translate }} {{ 'labels.commons.must be' | translate }} + <strong>{{ 'labels.commons.non-negative' | translate }}</strong> + </mat-error> + } </mat-form-field>Note: Ensure the translation keys exist in your translation files.
401-401: Consider adding validation error messages for better UX.Similar to line 385, this field lacks user feedback for validation failures. Adding an error message would improve the user experience.
💡 Example error message implementation
<mat-form-field class="flex-48"> <mat-label>{{ 'labels.inputs.Overdue days for NPA' | translate }}</mat-label> <input type="number" min="0" matInput formControlName="overdueDaysForNPA" /> + @if (loanProductSettingsForm.controls.overdueDaysForNPA.hasError('min')) { + <mat-error> + {{ 'labels.inputs.Overdue days for NPA' | translate }} {{ 'labels.commons.must be' | translate }} + <strong>{{ 'labels.commons.non-negative' | translate }}</strong> + </mat-error> + } </mat-form-field>
414-414: Consider adding validation error messages for better UX.This field also lacks user feedback for validation failures. Adding an error message would complete the validation implementation.
💡 Example error message implementation
<mat-form-field class="flex-48"> <mat-label>{{ 'labels.inputs.Principal Threshold (%) for Last Instalment' | translate }}</mat-label> <input type="number" min="0" matInput formControlName="principalThresholdForLastInstallment" /> + @if (loanProductSettingsForm.controls.principalThresholdForLastInstallment.hasError('min')) { + <mat-error> + {{ 'labels.inputs.Principal Threshold (%) for Last Instalment' | translate }} {{ 'labels.commons.must be' | translate }} + <strong>{{ 'labels.commons.non-negative' | translate }}</strong> + </mat-error> + } </mat-form-field>
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.htmlsrc/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts
🧰 Additional context used
📓 Path-based instructions (1)
src/app/**
⚙️ CodeRabbit configuration file
src/app/**: For Angular code: verify component separation, trackBy on *ngFor,
strict type safety, and clean observable patterns.
Files:
src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.htmlsrc/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: alberto-art3ch
Repo: openMF/web-app PR: 2876
File: src/app/loans/loans-view/loan-account-actions/loan-reaging/loan-reaging.component.ts:91-94
Timestamp: 2025-12-09T14:24:31.429Z
Learning: In the LoanReagingComponent (src/app/loans/loans-view/loan-account-actions/loan-reaging/loan-reaging.component.ts), the transactionAmount field uses both Validators.min and Validators.max set to the same value (loanTransactionData.amount). This is intentional - it requires users to enter the exact amount as a confirmation/validation step before submitting the re-age operation.
📚 Learning: 2025-12-09T14:24:31.429Z
Learnt from: alberto-art3ch
Repo: openMF/web-app PR: 2876
File: src/app/loans/loans-view/loan-account-actions/loan-reaging/loan-reaging.component.ts:91-94
Timestamp: 2025-12-09T14:24:31.429Z
Learning: In the LoanReagingComponent (src/app/loans/loans-view/loan-account-actions/loan-reaging/loan-reaging.component.ts), the transactionAmount field uses both Validators.min and Validators.max set to the same value (loanTransactionData.amount). This is intentional - it requires users to enter the exact amount as a confirmation/validation step before submitting the re-age operation.
Applied to files:
src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.htmlsrc/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts
🔇 Additional comments (1)
src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts (1)
316-328: LGTM! Form validators correctly implemented.The addition of
Validators.min(0)to these three form controls is correctly implemented and aligns with the corresponding HTMLmin="0"attributes. This provides both client-side and application-level validation to prevent negative values.The validator syntax follows Angular best practices, and the empty string initial value allows these fields to remain optional while still enforcing non-negative values when populated.
|
@IOhacker Thank You for the review |
Changes Made :-
-Added min="0" attribute to the input fields for "On arrears ageing", "Overdue days for NPA", and "Principal Threshold (%) for Last Installment" to prevent users from entering negative values.
-Added Angular form validation (Validators.min(0)) for the above fields to ensure negative values are not accepted at the form level.
WEB-568
Before :-

After :-

Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.