Skip to content

Commit 23e4f43

Browse files
committed
WEB-707 Allowing Negative Values in Loan Product Numeric Fields
1 parent 767c928 commit 23e4f43

4 files changed

Lines changed: 55 additions & 17 deletions

File tree

src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ <h4 class="mat-h4 flex-98">{{ 'labels.heading.Loan Tranche Details' | translate
561561
<div class="flex-100 layout-row">
562562
<mat-form-field class="flex-48">
563563
<mat-label>{{ 'labels.inputs.Maximum allowed outstanding balance' | translate }}</mat-label>
564-
<input matInput type="number" formControlName="maxOutstandingLoanBalance" />
564+
<input matInput type="number" formControlName="maxOutstandingLoanBalance" min="0" />
565565
@if (loansAccountTermsForm.controls.maxOutstandingLoanBalance.hasError('required')) {
566566
<mat-error>
567567
{{ 'labels.inputs.Maximum allowed outstanding balance' | translate }}

src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,15 @@ export class LoansAccountTermsStepComponent extends LoanProductBaseComponent imp
308308
if (this.allowAddDisbursementDetails()) {
309309
this.loansAccountTermsForm.addControl(
310310
'maxOutstandingLoanBalance',
311-
new UntypedFormControl(this.loansAccountTermsData?.maxOutstandingLoanBalance ?? null, Validators.required)
311+
new UntypedFormControl(this.loansAccountTermsData?.maxOutstandingLoanBalance ?? null, [
312+
Validators.required,
313+
Validators.min(0)
314+
])
312315
);
313316
} else {
314317
this.loansAccountTermsForm.addControl(
315318
'maxOutstandingLoanBalance',
316-
new UntypedFormControl(this.loansAccountTermsData?.maxOutstandingLoanBalance ?? null)
319+
new UntypedFormControl(this.loansAccountTermsData?.maxOutstandingLoanBalance ?? null, [Validators.min(0)])
317320
);
318321
}
319322
}
@@ -378,12 +381,15 @@ export class LoansAccountTermsStepComponent extends LoanProductBaseComponent imp
378381
this.loansAccountTermsForm.removeControl('maxOutstandingLoanBalance');
379382
this.loansAccountTermsForm.addControl(
380383
'maxOutstandingLoanBalance',
381-
new UntypedFormControl(this.loansAccountTermsData?.maxOutstandingLoanBalance ?? null, Validators.required)
384+
new UntypedFormControl(this.loansAccountTermsData?.maxOutstandingLoanBalance ?? null, [
385+
Validators.required,
386+
Validators.min(0)
387+
])
382388
);
383389
} else {
384390
this.loansAccountTermsForm.addControl(
385391
'maxOutstandingLoanBalance',
386-
new UntypedFormControl(this.loansAccountTermsData?.maxOutstandingLoanBalance ?? null)
392+
new UntypedFormControl(this.loansAccountTermsData?.maxOutstandingLoanBalance ?? null, [Validators.min(0)])
387393
);
388394
}
389395
}

src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ <h3 class="mat-h3 flex-96">{{ 'labels.inputs.Loan Tranche Details' | translate }
187187
matTooltip="{{ 'tooltips.Maximum number of disbursements' | translate }}"
188188
formControlName="maxTrancheCount"
189189
required
190+
min="0"
190191
/>
191192
@if (loanProductSettingsForm.controls.maxTrancheCount.hasError('required')) {
192193
<mat-error>
@@ -202,6 +203,7 @@ <h3 class="mat-h3 flex-96">{{ 'labels.inputs.Loan Tranche Details' | translate }
202203
matInput
203204
matTooltip="{{ 'tooltips.Maximum outstanding loan account balance' | translate }}"
204205
formControlName="outstandingLoanBalance"
206+
min="0"
205207
/>
206208
</mat-form-field>
207209
<mat-checkbox class="flex-48 margin-v" labelPosition="before" formControlName="disallowExpectedDisbursements">
@@ -470,15 +472,15 @@ <h4 class="flex-48">
470472
<h4 class="mat-h4 flex-98">{{ 'labels.inputs.Variable Installments' | translate }}</h4>
471473
<mat-form-field class="flex-48">
472474
<mat-label>{{ 'labels.inputs.Minimum gap between Installments' | translate }}</mat-label>
473-
<input type="number" matInput formControlName="minimumGap" required />
475+
<input type="number" matInput formControlName="minimumGap" required min="0" />
474476
<mat-error>
475477
{{ 'labels.inputs.Minimum gap between Installments' | translate }} {{ 'labels.commons.is' | translate }}
476478
<strong>{{ 'labels.commons.required' | translate }}</strong>
477479
</mat-error>
478480
</mat-form-field>
479481
<mat-form-field class="flex-48">
480482
<mat-label>{{ 'labels.inputs.Maximum gap between Installments' | translate }}</mat-label>
481-
<input type="number" matInput formControlName="maximumGap" required />
483+
<input type="number" matInput formControlName="maximumGap" required min="0" />
482484
<mat-error>
483485
{{ 'labels.inputs.Maximum gap between Installments' | translate }} {{ 'labels.commons.is' | translate }}
484486
<strong>{{ 'labels.commons.required' | translate }}</strong>
@@ -758,19 +760,19 @@ <h3 class="mat-h3 flex-23">{{ 'labels.heading.Guarantee Requirements' | translat
758760
<div class="flex-fill layout-row-wrap gap-2percent responsive-column">
759761
<mat-form-field class="flex-31">
760762
<mat-label>{{ 'labels.inputs.Mandatory Guarantee(%)' | translate }}</mat-label>
761-
<input type="number" matInput formControlName="mandatoryGuarantee" required />
763+
<input type="number" matInput formControlName="mandatoryGuarantee" required min="0" />
762764
<mat-error>
763765
{{ 'labels.inputs.Mandatory Guarantee' | translate }} {{ 'labels.commons.is' | translate }}
764766
<strong>{{ 'labels.commons.required' | translate }}</strong>
765767
</mat-error>
766768
</mat-form-field>
767769
<mat-form-field class="flex-31">
768770
<mat-label>{{ 'labels.inputs.Minimum Guarantee from Own Funds(%)' | translate }}</mat-label>
769-
<input type="number" matInput formControlName="minimumGuaranteeFromOwnFunds" />
771+
<input type="number" matInput formControlName="minimumGuaranteeFromOwnFunds" min="0" />
770772
</mat-form-field>
771773
<mat-form-field class="flex-31">
772774
<mat-label>{{ 'labels.inputs.Minimum Guarantee from Guarantor Funds(%)' | translate }}</mat-label>
773-
<input type="number" matInput formControlName="minimumGuaranteeFromGuarantor" />
775+
<input type="number" matInput formControlName="minimumGuaranteeFromGuarantor" min="0" />
774776
</mat-form-field>
775777
</div>
776778
}

src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,20 @@ export class LoanProductSettingsStepComponent extends LoanProductBaseComponent i
499499
.get('allowVariableInstallments')
500500
.valueChanges.subscribe((allowVariableInstallments: any) => {
501501
if (allowVariableInstallments) {
502-
this.loanProductSettingsForm.addControl('minimumGap', new UntypedFormControl('', Validators.required));
503-
this.loanProductSettingsForm.addControl('maximumGap', new UntypedFormControl('', Validators.required));
502+
this.loanProductSettingsForm.addControl(
503+
'minimumGap',
504+
new UntypedFormControl('', [
505+
Validators.required,
506+
Validators.min(0)
507+
])
508+
);
509+
this.loanProductSettingsForm.addControl(
510+
'maximumGap',
511+
new UntypedFormControl('', [
512+
Validators.required,
513+
Validators.min(0)
514+
])
515+
);
504516
} else {
505517
this.loanProductSettingsForm.removeControl('minimumGap');
506518
this.loanProductSettingsForm.removeControl('maximumGap');
@@ -664,10 +676,19 @@ export class LoanProductSettingsStepComponent extends LoanProductBaseComponent i
664676
if (holdGuaranteeFunds) {
665677
this.loanProductSettingsForm.addControl(
666678
'mandatoryGuarantee',
667-
new UntypedFormControl('', Validators.required)
679+
new UntypedFormControl('', [
680+
Validators.required,
681+
Validators.min(0)
682+
])
683+
);
684+
this.loanProductSettingsForm.addControl(
685+
'minimumGuaranteeFromOwnFunds',
686+
new UntypedFormControl('', [Validators.min(0)])
687+
);
688+
this.loanProductSettingsForm.addControl(
689+
'minimumGuaranteeFromGuarantor',
690+
new UntypedFormControl('', [Validators.min(0)])
668691
);
669-
this.loanProductSettingsForm.addControl('minimumGuaranteeFromOwnFunds', new UntypedFormControl(''));
670-
this.loanProductSettingsForm.addControl('minimumGuaranteeFromGuarantor', new UntypedFormControl(''));
671692
} else {
672693
this.loanProductSettingsForm.removeControl('mandatoryGuarantee');
673694
this.loanProductSettingsForm.removeControl('minimumGuaranteeFromOwnFunds');
@@ -677,8 +698,17 @@ export class LoanProductSettingsStepComponent extends LoanProductBaseComponent i
677698

678699
this.loanProductSettingsForm.get('multiDisburseLoan').valueChanges.subscribe((multiDisburseLoan) => {
679700
if (multiDisburseLoan) {
680-
this.loanProductSettingsForm.addControl('maxTrancheCount', new UntypedFormControl('', Validators.required));
681-
this.loanProductSettingsForm.addControl('outstandingLoanBalance', new UntypedFormControl(''));
701+
this.loanProductSettingsForm.addControl(
702+
'maxTrancheCount',
703+
new UntypedFormControl('', [
704+
Validators.required,
705+
Validators.min(0)
706+
])
707+
);
708+
this.loanProductSettingsForm.addControl(
709+
'outstandingLoanBalance',
710+
new UntypedFormControl('', [Validators.min(0)])
711+
);
682712
} else {
683713
this.loanProductSettingsForm.removeControl('maxTrancheCount');
684714
this.loanProductSettingsForm.removeControl('outstandingLoanBalance');

0 commit comments

Comments
 (0)