Skip to content

Commit c841f82

Browse files
committed
WEB-874 Prevent negative values in numeric fields of Group
1 parent d4fa504 commit c841f82

4 files changed

Lines changed: 73 additions & 27 deletions

File tree

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ <h4 class="mat-h4 flex-98">{{ 'labels.inputs.Repayments' | translate }}</h4>
7373
matInput
7474
formControlName="numberOfRepayments"
7575
matTooltip="{{ 'tooltips.Enter the total count of repayments' | translate }}"
76+
min="0"
7677
/>
7778
@if (loansAccountTermsForm.controls.numberOfRepayments.hasError('required')) {
7879
<mat-error>
@@ -133,6 +134,7 @@ <h4 class="mat-h4 flex-98">
133134
required
134135
formControlName="repaymentEvery"
135136
matTooltip="{{ 'tooltips.Fields are input to calculating the repayment schedule' | translate }}"
137+
min="0"
136138
/>
137139
@if (loansAccountTermsForm.controls.repaymentEvery.hasError('required')) {
138140
<mat-error>
@@ -198,7 +200,7 @@ <h4 class="mat-h4 flex-98">{{ 'labels.inputs.Nominal interest rate' | translate
198200
@if (!loansAccountTermsData?.isLoanProductLinkedToFloatingRate) {
199201
<mat-form-field class="flex-fill flex-23">
200202
<mat-label>{{ 'labels.inputs.Nominal interest rate' | translate }} %</mat-label>
201-
<input type="number" matInput formControlName="interestRatePerPeriod" />
203+
<input type="number" matInput formControlName="interestRatePerPeriod" min="0" />
202204
</mat-form-field>
203205
<mat-form-field class="flex-fill flex-23">
204206
<mat-label>{{ 'labels.inputs.Frequency' | translate }}</mat-label>
@@ -375,6 +377,7 @@ <h4 class="mat-h4 flex-98">{{ 'labels.heading.Interest Calculations' | translate
375377
type="number"
376378
formControlName="inArrearsTolerance"
377379
matTooltip="{{ 'tooltips.With Arrears tolerance' | translate }}"
380+
min="0"
378381
/>
379382
</mat-form-field>
380383

@@ -384,6 +387,7 @@ <h4 class="mat-h4 flex-98">{{ 'labels.heading.Interest Calculations' | translate
384387
matInput
385388
formControlName="graceOnInterestCharged"
386389
matTooltip="{{ 'tooltips.If the Interest Free Period' | translate }}"
390+
min="0"
387391
/>
388392
</mat-form-field>
389393

@@ -394,17 +398,17 @@ <h4 class="mat-h4 flex-98">
394398

395399
<mat-form-field class="flex-fill flex-23">
396400
<mat-label>{{ 'labels.inputs.Grace on principal payment' | translate }}</mat-label>
397-
<input type="number" matInput formControlName="graceOnPrincipalPayment" />
401+
<input type="number" matInput formControlName="graceOnPrincipalPayment" min="0" />
398402
</mat-form-field>
399403

400404
<mat-form-field class="flex-fill flex-23">
401405
<mat-label>{{ 'labels.inputs.Grace on interest payment' | translate }}</mat-label>
402-
<input type="number" matInput formControlName="graceOnInterestPayment" />
406+
<input type="number" matInput formControlName="graceOnInterestPayment" min="0" />
403407
</mat-form-field>
404408

405409
<mat-form-field class="flex-48">
406410
<mat-label>{{ 'labels.inputs.On arrears ageing' | translate }}</mat-label>
407-
<input type="number" matInput formControlName="graceOnArrearsAgeing" />
411+
<input type="number" matInput formControlName="graceOnArrearsAgeing" min="0" />
408412
</mat-form-field>
409413

410414
@if (isDelinquencyEnabled()) {

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

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,17 @@ export class LoansAccountTermsStepComponent extends LoanProductBaseComponent imp
497497
],
498498
numberOfRepayments: [
499499
'',
500-
Validators.required
500+
[
501+
Validators.required,
502+
Validators.min(0)
503+
]
501504
],
502505
repaymentEvery: [
503506
'',
504-
Validators.required
507+
[
508+
Validators.required,
509+
Validators.min(0)
510+
]
505511
],
506512
repaymentFrequencyType: [
507513
{ value: '', disabled: true },
@@ -511,7 +517,10 @@ export class LoansAccountTermsStepComponent extends LoanProductBaseComponent imp
511517
repaymentFrequencyDayOfWeekType: [''],
512518
repaymentsStartingFromDate: [''],
513519
interestChargedFromDate: [''],
514-
interestRatePerPeriod: [''],
520+
interestRatePerPeriod: [
521+
'',
522+
Validators.min(0)
523+
],
515524
interestType: [''],
516525
isFloatingInterestRate: [null],
517526
isEqualAmortization: [''],
@@ -521,11 +530,26 @@ export class LoansAccountTermsStepComponent extends LoanProductBaseComponent imp
521530
],
522531
interestCalculationPeriodType: [''],
523532
allowPartialPeriodInterestCalculation: [''],
524-
inArrearsTolerance: [''],
525-
graceOnInterestCharged: [''],
526-
graceOnPrincipalPayment: [''],
527-
graceOnInterestPayment: [''],
528-
graceOnArrearsAgeing: [''],
533+
inArrearsTolerance: [
534+
'',
535+
Validators.min(0)
536+
],
537+
graceOnInterestCharged: [
538+
'',
539+
Validators.min(0)
540+
],
541+
graceOnPrincipalPayment: [
542+
'',
543+
Validators.min(0)
544+
],
545+
graceOnInterestPayment: [
546+
'',
547+
Validators.min(0)
548+
],
549+
graceOnArrearsAgeing: [
550+
'',
551+
Validators.min(0)
552+
],
529553
loanIdToClose: [''],
530554
fixedEmiAmount: [''],
531555
isTopup: [''],

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<mat-form-field class="flex-48">
2222
<mat-label>{{ 'labels.inputs.Nominal Annual Interest' | translate }}</mat-label>
23-
<input type="number" matInput formControlName="nominalAnnualInterestRate" required />
23+
<input type="number" matInput formControlName="nominalAnnualInterestRate" required min="0" />
2424
<mat-error>
2525
{{ 'labels.inputs.Nominal Annual Interest' | translate }} {{ 'labels.commons.is' | translate }}
2626
<strong>{{ 'labels.commons.required' | translate }}</strong>
@@ -92,7 +92,7 @@
9292

9393
<mat-form-field class="flex-48">
9494
<mat-label>{{ 'labels.inputs.Minimum Opening Balance' | translate }}</mat-label>
95-
<input type="number" matInput formControlName="minRequiredOpeningBalance" />
95+
<input type="number" matInput formControlName="minRequiredOpeningBalance" min="0" />
9696
</mat-form-field>
9797

9898
<mat-checkbox labelPosition="before" formControlName="withdrawalFeeForTransfers" class="margin-v flex-48">
@@ -103,7 +103,7 @@ <h4 class="mat-h4 flex-98">{{ 'labels.inputs.Lock-in Period' | translate }}</h4>
103103

104104
<mat-form-field class="flex-48">
105105
<mat-label>{{ 'labels.inputs.Frequency' | translate }}</mat-label>
106-
<input type="number" matInput formControlName="lockinPeriodFrequency" />
106+
<input type="number" matInput formControlName="lockinPeriodFrequency" min="0" />
107107
</mat-form-field>
108108

109109
<mat-form-field class="flex-48">
@@ -129,15 +129,15 @@ <h3 class="mat-h3 flex-23">{{ 'labels.inputs.Overdraft' | translate }}</h3>
129129
<div class="flex-fill layout-row-wrap gap-2percent responsive-column">
130130
<mat-form-field class="flex-31">
131131
<mat-label>{{ 'labels.inputs.Minimum Overdraft Required for Interest Calculation' | translate }}</mat-label>
132-
<input type="number" matInput formControlName="minOverdraftForInterestCalculation" />
132+
<input type="number" matInput formControlName="minOverdraftForInterestCalculation" min="0" />
133133
</mat-form-field>
134134
<mat-form-field class="flex-31">
135135
<mat-label>{{ 'labels.inputs.Nominal Annual Interest for Overdraft' | translate }}</mat-label>
136-
<input type="number" matInput formControlName="nominalAnnualInterestRateOverdraft" />
136+
<input type="number" matInput formControlName="nominalAnnualInterestRateOverdraft" min="0" />
137137
</mat-form-field>
138138
<mat-form-field class="flex-31">
139139
<mat-label>{{ 'labels.inputs.Maximum Overdraft Amount Limit' | translate }}</mat-label>
140-
<input type="number" matInput formControlName="overdraftLimit" />
140+
<input type="number" matInput formControlName="overdraftLimit" min="0" />
141141
</mat-form-field>
142142
</div>
143143
}
@@ -150,13 +150,13 @@ <h3 class="mat-h3 flex-23">{{ 'labels.inputs.Overdraft' | translate }}</h3>
150150

151151
<mat-form-field class="flex-48">
152152
<mat-label>{{ 'labels.inputs.Minimum Balance' | translate }}</mat-label>
153-
<input type="number" matInput formControlName="minRequiredBalance" />
153+
<input type="number" matInput formControlName="minRequiredBalance" min="0" />
154154
</mat-form-field>
155155

156156
@if (savingsAccountTermsForm.controls.minBalanceForInterestCalculation.value) {
157157
<mat-form-field class="flex-48">
158158
<mat-label>{{ 'labels.inputs.Balance Required for Interest Calculation' | translate }}</mat-label>
159-
<input type="number" matInput formControlName="minBalanceForInterestCalculation" />
159+
<input type="number" matInput formControlName="minBalanceForInterestCalculation" min="0" />
160160
</mat-form-field>
161161
}
162162
</div>

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ export class SavingsAccountTermsStepComponent implements OnChanges, OnInit {
128128
decimal: [{ value: '', disabled: true }],
129129
nominalAnnualInterestRate: [
130130
'',
131-
Validators.required
131+
[
132+
Validators.required,
133+
Validators.min(0)
134+
]
132135
],
133136
interestCompoundingPeriodType: [
134137
'',
@@ -146,13 +149,22 @@ export class SavingsAccountTermsStepComponent implements OnChanges, OnInit {
146149
'',
147150
Validators.required
148151
],
149-
minRequiredOpeningBalance: [''],
152+
minRequiredOpeningBalance: [
153+
'',
154+
Validators.min(0)
155+
],
150156
withdrawalFeeForTransfers: [false],
151-
lockinPeriodFrequency: [''],
157+
lockinPeriodFrequency: [
158+
'',
159+
Validators.min(0)
160+
],
152161
lockinPeriodFrequencyType: [''],
153162
allowOverdraft: [false],
154163
enforceMinRequiredBalance: [false],
155-
minRequiredBalance: [''],
164+
minRequiredBalance: [
165+
'',
166+
Validators.min(0)
167+
],
156168
minBalanceForInterestCalculation: [{ value: '', disabled: true }]
157169
});
158170
}
@@ -175,9 +187,15 @@ export class SavingsAccountTermsStepComponent implements OnChanges, OnInit {
175187
buildDependencies() {
176188
this.savingsAccountTermsForm.get('allowOverdraft').valueChanges.subscribe((allowOverdraft: any) => {
177189
if (allowOverdraft) {
178-
this.savingsAccountTermsForm.addControl('minOverdraftForInterestCalculation', new UntypedFormControl(''));
179-
this.savingsAccountTermsForm.addControl('nominalAnnualInterestRateOverdraft', new UntypedFormControl(''));
180-
this.savingsAccountTermsForm.addControl('overdraftLimit', new UntypedFormControl(''));
190+
this.savingsAccountTermsForm.addControl(
191+
'minOverdraftForInterestCalculation',
192+
new UntypedFormControl('', Validators.min(0))
193+
);
194+
this.savingsAccountTermsForm.addControl(
195+
'nominalAnnualInterestRateOverdraft',
196+
new UntypedFormControl('', Validators.min(0))
197+
);
198+
this.savingsAccountTermsForm.addControl('overdraftLimit', new UntypedFormControl('', Validators.min(0)));
181199
} else {
182200
this.savingsAccountTermsForm.removeControl('minOverdraftForInterestCalculation');
183201
this.savingsAccountTermsForm.removeControl('nominalAnnualInterestRateOverdraft');

0 commit comments

Comments
 (0)