Skip to content

Commit af1cb0e

Browse files
author
Jose Alberto Hernandez
committed
fix: Loan create fails if Max allowed outstanding balance value is not specified for multidisbursal loan
1 parent a08af71 commit af1cb0e

File tree

2 files changed

+65
-29
lines changed

2 files changed

+65
-29
lines changed

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

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ <h4 class="mat-h4 flex-98">
4545
loansAccountTermsForm.value.loanTermFrequencyType | find: termFrequencyTypeData : 'id' : 'value'
4646
}}</span>
4747

48-
<h4 class="mat-h4 flex-98">Repayments</h4>
48+
<h4 class="mat-h4 flex-98">{{ 'labels.inputs.Repayments' | translate }}</h4>
4949

50-
<mat-form-field class="flex-48">
50+
<mat-form-field class="flex-fill flex-23">
5151
<mat-label>{{ 'labels.inputs.Number of repayments' | translate }}</mat-label>
5252
<input
5353
type="number"
@@ -61,6 +61,11 @@ <h4 class="mat-h4 flex-98">Repayments</h4>
6161
</mat-error>
6262
</mat-form-field>
6363

64+
<mat-form-field class="flex-fill flex-23" *ngIf="loansAccountTermsData?.canDefineInstallmentAmount">
65+
<mat-label>{{ 'labels.inputs.Installment Amount' | translate }}</mat-label>
66+
<input type="number" matInput formControlName="fixedEmiAmount" />
67+
</mat-form-field>
68+
6469
<mat-form-field class="flex-fill flex-23" (click)="repaymentsPicker.open()">
6570
<mat-label>{{ 'labels.inputs.First repayment on' | translate }}</mat-label>
6671
<input
@@ -220,7 +225,7 @@ <h4 class="mat-h4 flex-98">{{ 'labels.inputs.Nominal interest rate' | translate
220225
</ng-container>
221226

222227
<ng-container *ngIf="loansAccountTermsData?.isLoanProductLinkedToFloatingRate">
223-
<div class="flex-48 layout-row-wrap gap-2percent layout-xs-column">
228+
<div class="flex-48 layout-row layout-xs-column">
224229
<mat-form-field class="flex-48">
225230
<mat-label>{{ 'labels.inputs.Interest Method' | translate }}</mat-label>
226231
<mat-select formControlName="interestType">
@@ -256,12 +261,14 @@ <h4 class="mat-h4 flex-98">{{ 'labels.inputs.Nominal interest rate' | translate
256261
<h4 class="mat-h4 flex-98">{{ 'labels.inputs.Loan Schedule' | translate }}</h4>
257262

258263
<div class="flex-48" *ngIf="loanScheduleType">
259-
<span class="flex-40"
260-
><p>{{ 'labels.inputs.Loan Schedule Type' | translate }}</p></span
261-
>
262-
<span class="flex-60"
263-
><p>{{ loanScheduleType.value | translateKey: 'catalogs' }}</p></span
264-
>
264+
<div class="layout-row">
265+
<span class="flex-40"
266+
><p>{{ 'labels.inputs.Loan Schedule Type' | translate }}</p></span
267+
>
268+
<span class="flex-60"
269+
><p>{{ loanScheduleType.value | translateKey: 'catalogs' }}</p></span
270+
>
271+
</div>
265272
</div>
266273

267274
<mat-form-field class="flex-48">
@@ -284,14 +291,9 @@ <h4 class="mat-h4 flex-98">{{ 'labels.inputs.Loan Schedule' | translate }}</h4>
284291
</mat-error>
285292
</mat-form-field>
286293

287-
<mat-form-field class="flex-48" *ngIf="loansAccountTermsData?.canDefineInstallmentAmount">
288-
<mat-label>{{ 'labels.inputs.Installment Amount' | translate }}</mat-label>
289-
<input type="number" matInput formControlName="fixedEmiAmount" />
290-
</mat-form-field>
291-
292294
<h4 class="mat-h4 flex-98">{{ 'labels.heading.Interest Calculations' | translate }}</h4>
293295

294-
<mat-form-field class="flex-40">
296+
<mat-form-field class="flex-48">
295297
<mat-label>{{ 'labels.inputs.Interest calculation period' | translate }}</mat-label>
296298
<mat-select
297299
formControlName="interestCalculationPeriodType"
@@ -307,15 +309,15 @@ <h4 class="mat-h4 flex-98">{{ 'labels.heading.Interest Calculations' | translate
307309
</mat-form-field>
308310

309311
<mat-checkbox
310-
class="flex-48"
312+
class="flex-98"
311313
formControlName="allowPartialPeriodInterestCalculation"
312314
matTooltip="{{ 'tooltips.To be used with SAME AS REPAYMENT PERIOD' | translate }}"
313315
>
314316
<p>{{ 'labels.inputs.Calculate interest for exact days in partial period' | translate }}</p>
315317
</mat-checkbox>
316318

317-
<ng-container *ngIf="isProgressive">
318-
<mat-checkbox formControlName="interestRecognitionOnDisbursementDate" class="flex-48">
319+
<ng-container class="flex-98" *ngIf="isProgressive">
320+
<mat-checkbox formControlName="interestRecognitionOnDisbursementDate" class="flex-98">
319321
<p>{{ 'labels.inputs.Is interest recognition on disbursement date?' | translate }}</p>
320322
</mat-checkbox>
321323
</ng-container>
@@ -473,6 +475,13 @@ <h4 class="mat-h4 flex-98">
473475
<span class="flex-40">{{ enableIncomeCapitalization | yesNo }}</span>
474476
</div>
475477

478+
<div class="flex-100 layout-row">
479+
<span class="flex-40"
480+
><b>{{ 'labels.inputs.Enable Buy down fee' | translate }}</b></span
481+
>
482+
<span class="flex-40">{{ enableBuyDownFee | yesNo }}</span>
483+
</div>
484+
476485
<ng-container *ngIf="multiDisburseLoan">
477486
<mat-divider class="flex-98"></mat-divider>
478487
<div class="flex-100 layout-row" *ngIf="allowAddDisbursementDetails()">
@@ -481,7 +490,11 @@ <h4 class="mat-h4 flex-98">{{ 'labels.heading.Loan Tranche Details' | translate
481490
<div class="flex-100 layout-row">
482491
<mat-form-field class="flex-48">
483492
<mat-label>{{ 'labels.inputs.Maximum allowed outstanding balance' | translate }}</mat-label>
484-
<input matInput required formControlName="maxOutstandingLoanBalance" />
493+
<input matInput type="number" formControlName="maxOutstandingLoanBalance" />
494+
<mat-error *ngIf="loansAccountTermsForm.controls.maxOutstandingLoanBalance.hasError('required')">
495+
{{ 'labels.inputs.Maximum allowed outstanding balance' | translate }} {{ 'labels.commons.is' | translate }}
496+
<strong>{{ 'labels.commons.required' | translate }}</strong>
497+
</mat-error>
485498
</mat-form-field>
486499
<span class="flex-48">
487500
<button

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

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
/** Angular Imports */
22
import { Component, OnInit, Input, OnChanges } from '@angular/core';
3-
import {
4-
UntypedFormGroup,
5-
UntypedFormBuilder,
6-
Validators,
7-
FormArray,
8-
UntypedFormControl,
9-
ReactiveFormsModule
10-
} from '@angular/forms';
3+
import { UntypedFormGroup, UntypedFormBuilder, Validators, UntypedFormControl } from '@angular/forms';
114
import { MatDialog } from '@angular/material/dialog';
12-
import { ActivatedRoute, RouterLink } from '@angular/router';
5+
import { ActivatedRoute } from '@angular/router';
136
import { LoansAccountAddCollateralDialogComponent } from 'app/loans/custom-dialog/loans-account-add-collateral-dialog/loans-account-add-collateral-dialog.component';
147
import { LoanProducts } from 'app/products/loan-products/loan-products';
158
import { LoanProduct } from 'app/products/loan-products/models/loan-product.model';
@@ -25,7 +18,7 @@ import { InputAmountComponent } from '../../../shared/input-amount/input-amount.
2518
import { MatTooltip } from '@angular/material/tooltip';
2619
import { MatCheckbox } from '@angular/material/checkbox';
2720
import { MatDivider } from '@angular/material/divider';
28-
import { MatIconButton, MatButton } from '@angular/material/button';
21+
import { MatIconButton } from '@angular/material/button';
2922
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
3023
import {
3124
MatTable,
@@ -161,6 +154,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
161154

162155
productEnableDownPayment = false;
163156
enableIncomeCapitalization = false;
157+
enableBuyDownFee = false;
164158
isProgressive = false;
165159

166160
/**
@@ -190,6 +184,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
190184
}
191185
this.productEnableDownPayment = this.loansAccountTermsData.product.enableDownPayment;
192186
this.enableIncomeCapitalization = this.loansAccountTermsData.product.enableIncomeCapitalization;
187+
this.enableBuyDownFee = this.loansAccountTermsData.product.enableBuyDownFee;
193188
this.isProgressive =
194189
this.loansAccountTermsData.loanScheduleType.code == LoanProducts.LOAN_SCHEDULE_TYPE_PROGRESSIVE;
195190
if (this.loansAccountTermsData.product) {
@@ -291,6 +286,19 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
291286
this.loansAccountTermsForm.controls.graceOnArrearsAgeing.disable();
292287
}
293288
this.setOptions();
289+
290+
this.loansAccountTermsForm.removeControl('maxOutstandingLoanBalance');
291+
if (this.allowAddDisbursementDetails()) {
292+
this.loansAccountTermsForm.addControl(
293+
'maxOutstandingLoanBalance',
294+
new UntypedFormControl(this.loansAccountTermsData.maxOutstandingLoanBalance, Validators.required)
295+
);
296+
} else {
297+
this.loansAccountTermsForm.addControl(
298+
'maxOutstandingLoanBalance',
299+
new UntypedFormControl(this.loansAccountTermsData.maxOutstandingLoanBalance)
300+
);
301+
}
294302
}
295303
}
296304

@@ -344,11 +352,26 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
344352
this.setAdvancedPaymentStrategyControls();
345353
// this.setCustomValidators();
346354
this.setLoanTermListener();
355+
356+
this.loansAccountTermsForm.removeControl('maxOutstandingLoanBalance');
357+
if (this.allowAddDisbursementDetails()) {
358+
this.loansAccountTermsForm.removeControl('maxOutstandingLoanBalance');
359+
this.loansAccountTermsForm.addControl(
360+
'maxOutstandingLoanBalance',
361+
new UntypedFormControl(this.loansAccountTermsData.maxOutstandingLoanBalance, Validators.required)
362+
);
363+
} else {
364+
this.loansAccountTermsForm.addControl(
365+
'maxOutstandingLoanBalance',
366+
new UntypedFormControl(this.loansAccountTermsData.maxOutstandingLoanBalance)
367+
);
368+
}
347369
}
348370

349371
allowAddDisbursementDetails() {
350372
return this.multiDisburseLoan && !this.loansAccountTermsData.disallowExpectedDisbursements;
351373
}
374+
352375
formatDateToDDMMYYYY(date: Date): string {
353376
const day = date.getDate().toString().padStart(2, '0');
354377
const month = (date.getMonth() + 1).toString().padStart(2, '0');

0 commit comments

Comments
 (0)