Loan account creation and modification with Loan schedule type validation

This commit is contained in:
Jose Alberto Hernandez
2024-01-04 14:18:50 +01:00
committed by Adam Saghy
parent f6261be8d5
commit 80b821838c
21 changed files with 103 additions and 34 deletions
+21
View File
@@ -0,0 +1,21 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class Commons {
constructor() {}
public dynamicSort(property: string) {
let sortOrder = 1;
if (property[0] === '-') {
sortOrder = -1;
property = property.substr(1);
}
return (a: any, b: any) => {
const result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;
return result * sortOrder;
};
}
}
@@ -123,7 +123,6 @@ export class FixedDepositAccountSettingsStepComponent implements OnInit, OnChang
}
});
this.fixedDepositAccountSettingsForm.get('maturityInstructionId').valueChanges.subscribe((value: number) => {
console.log(value);
if (value > 100) {
this.fixedDepositAccountSettingsForm.addControl('transferToSavingsId', new UntypedFormControl('', Validators.required));
this.fixedDepositAccountSettingsForm.get('transferToSavingsId').patchValue(this.fixedDepositsAccountTemplate.transferToSavingsId && this.fixedDepositsAccountTemplate.transferToSavingsId.id);
@@ -2,7 +2,7 @@
<div fxLayout="row wrap" fxLayoutGap="2%" fxLayout.lt-md="column">
<mat-form-field fxFlex="48%">
<mat-form-field fxFlex="72%">
<mat-label>{{"labels.inputs.Product Name" | translate}}</mat-label>
<mat-select formControlName="productId" matTooltip="{{ 'tooltips.Name of the loan product' | translate}}" required>
<mat-option *ngFor="let product of productData" [value]="product.id">
@@ -13,6 +13,14 @@
{{"labels.inputs.Product Name" | translate}} {{"labels.commons.is" | translate}} <strong>{{"labels.commons.required" | translate}}</strong>
</mat-error>
</mat-form-field>
</div>
<div fxLayout="row wrap" fxLayoutGap="2%" fxLayout.lt-md="column" *ngIf="loanProductSelected">
<mat-form-field fxFlex="48%">
<mat-label>{{"labels.inputs.External id" | translate}}</mat-label>
<input matInput formControlName="externalId" matTooltip="{{ 'tooltips.Provides an external id' | translate}}">
</mat-form-field>
<mat-form-field fxFlex="48%" *ngIf="loanProductSelected">
<mat-label>{{"labels.inputs.Loan officer" | translate}}</mat-label>
@@ -22,9 +30,6 @@
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div fxLayout="row wrap" fxLayoutGap="2%" fxLayout.lt-md="column" *ngIf="loanProductSelected">
<mat-form-field fxFlex="48%">
<mat-label>{{"labels.inputs.Loan Purpose" | translate}}</mat-label>
@@ -66,11 +71,6 @@
</mat-error>
</mat-form-field>
<mat-form-field fxFlex="48%">
<mat-label>{{"labels.inputs.External id" | translate}}</mat-label>
<input matInput formControlName="externalId" matTooltip="{{ 'tooltips.Provides an external id' | translate}}">
</mat-form-field>
<mat-divider fxFlex="98%"></mat-divider>
<h3 class="mat-h3" fxFlexFill>{{"labels.heading.Savings Linkage" | translate}}</h3>
@@ -7,6 +7,7 @@ import { TooltipPosition } from '@angular/material/tooltip';
/** Custom Services */
import { LoansService } from '../../loans.service';
import { Commons } from 'app/core/utils/commons';
/**
* Loans Account Details Step
@@ -55,7 +56,8 @@ export class LoansAccountDetailsStepComponent implements OnInit {
constructor(private formBuilder: UntypedFormBuilder,
private loansService: LoansService,
private route: ActivatedRoute,
private settingsService: SettingsService) {
private settingsService: SettingsService,
private commons: Commons) {
this.loanId = this.route.snapshot.params['loanId'];
}
@@ -64,7 +66,7 @@ export class LoansAccountDetailsStepComponent implements OnInit {
this.maxDate = this.settingsService.maxFutureDate;
this.buildDependencies();
if (this.loansAccountTemplate) {
this.productData = this.loansAccountTemplate.productOptions;
this.productData = this.loansAccountTemplate.productOptions.sort(this.commons.dynamicSort('name'));
if (this.loansAccountTemplate.loanProductId) {
this.loansAccountDetailsForm.patchValue({
'productId': this.loansAccountTemplate.loanProductId,
@@ -129,7 +129,7 @@
<div fxFlexFill>
<span fxFlex="40%">{{"labels.inputs.Repayment strategy" | translate}}: </span>
<span
fxFlex="60%">{{ loansAccount.transactionProcessingStrategyCode | find:loansAccountTemplate.transactionProcessingStrategyOptions:'code':'name' }}</span>
fxFlex="60%">{{ loansAccount.transactionProcessingStrategyCode | find:loansAccountProductTemplate.transactionProcessingStrategyOptions:'code':'name' }}</span>
</div>
<h3 class="mat-h3" fxFlexFill>{{"labels.heading.Moratorium" | translate}}</h3>
@@ -9,7 +9,7 @@ import { Component, OnInit, Input, Output, EventEmitter, OnDestroy } from '@angu
templateUrl: './loans-account-preview-step.component.html',
styleUrls: ['./loans-account-preview-step.component.scss']
})
export class LoansAccountPreviewStepComponent implements OnInit, OnDestroy {
export class LoansAccountPreviewStepComponent implements OnInit {
/** Loans Account Template */
@Input() loansAccountTemplate: any = [];
@@ -29,6 +29,4 @@ export class LoansAccountPreviewStepComponent implements OnInit, OnDestroy {
ngOnInit() { }
ngOnDestroy(): void { }
}
@@ -121,6 +121,23 @@
<p>{{"labels.inputs.Is Equal Amortization" | translate}}</p>
</mat-checkbox>
<div fxFlex="48%" *ngIf="loanScheduleType">
<span fxFlex="40%"><p>{{"labels.inputs.Loan Schedule Type" | translate}}</p></span>
<span fxFlex="60%"><p>{{ loanScheduleType.value }}</p></span>
</div>
<mat-form-field fxFlex="48%">
<mat-label>{{"labels.inputs.Repayment Strategy" | translate}}</mat-label>
<mat-select formControlName="transactionProcessingStrategyCode" matTooltip="{{ 'tooltips.The repayment strategy' | translate}}" [disabled]="repaymentStrategyDisabled">
<mat-option *ngFor="let transactionProcessingStrategy of transactionProcessingStrategyOptions" [value]="transactionProcessingStrategy.code">
{{ transactionProcessingStrategy.name }}
</mat-option>
</mat-select>
<mat-error *ngIf="loansAccountTermsForm.controls.transactionProcessingStrategyCode.hasError('required')">
{{"labels.inputs.Repayment Strategy" | translate}} {{"labels.commons.is" | translate}} <strong>{{"labels.commons.required" | translate}}</strong>
</mat-error>
</mat-form-field>
</ng-container>
<ng-container *ngIf="loansAccountTermsData?.isLoanProductLinkedToFloatingRate">
@@ -182,18 +199,6 @@
<input matInput formControlName="graceOnInterestCharged" matTooltip="{{ 'tooltips.If the Interest Free Period' | translate}}">
</mat-form-field>
<mat-form-field fxFlex="48%">
<mat-label>{{"labels.inputs.Repayment strategy" | translate}}</mat-label>
<mat-select formControlName="transactionProcessingStrategyCode" matTooltip="{{ 'tooltips.The repayment strategy' | translate}}">
<mat-option *ngFor="let transactionProcessingStrategy of transactionProcessingStrategyOptions" [value]="transactionProcessingStrategy.code">
{{ transactionProcessingStrategy.name }}
</mat-option>
</mat-select>
<mat-error *ngIf="loansAccountTermsForm.controls.transactionProcessingStrategyCode.hasError('required')">
{{"labels.inputs.Repayment Strategy" | translate}} {{"labels.commons.is" | translate}} <strong>{{"labels.commons.required" | translate}}</strong>
</mat-error>
</mat-form-field>
<h4 fxFlex="98%" class="mat-h4">{{"labels.heading.Moratorium" | translate}} <i class="fas fa-question" matTooltip="{{ 'tooltips.The moratorium information' | translate}}"></i></h4>
<mat-form-field fxFlex="23%">
@@ -4,12 +4,14 @@ import { UntypedFormGroup, UntypedFormBuilder, Validators, FormArray } from '@an
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute } from '@angular/router';
import { LoansAccountAddCollateralDialogComponent } from 'app/loans/custom-dialog/loans-account-add-collateral-dialog/loans-account-add-collateral-dialog.component';
import { LoanProducts } from 'app/products/loan-products/loan-products';
import { SettingsService } from 'app/settings/settings.service';
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base';
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
import { CodeName, OptionData } from 'app/shared/models/option-data.model';
/**
* Create Loans Account Terms Step
@@ -61,9 +63,9 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
/** Multi Disbursement Data */
disbursementDataSource: {}[] = [];
currencyDisplaySymbol = '$';
/** Loan Transaction strategies */
/** Loan repayment strategies */
transactionProcessingStrategyOptions: any = [];
repaymentStrategyDisabled = false;
/** Check if value of collateral added is more than principal amount */
isCollateralSufficient = false;
/** Total value of all collateral added to a loan */
@@ -83,6 +85,8 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
loanId: any = null;
loanScheduleType: OptionData | null = null;
/**
* Create Loans Account Terms Form
* @param formBuilder FormBuilder
@@ -440,7 +444,24 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
this.amortizationTypeData = this.loansAccountProductTemplate.amortizationTypeOptions;
this.interestCalculationPeriodTypeData = this.loansAccountProductTemplate.interestCalculationPeriodTypeOptions;
this.clientActiveLoanData = this.loansAccountProductTemplate.clientActiveLoanOptions;
this.transactionProcessingStrategyOptions = this.loansAccountProductTemplate.transactionProcessingStrategyOptions;
this.loanScheduleType = this.loansAccountProductTemplate.loanScheduleType;
this.transactionProcessingStrategyOptions = [];
if (this.loanScheduleType.code === LoanProducts.LOAN_SCHEDULE_TYPE_CUMULATIVE) {
// Filter Advanced Payment Allocation Strategy
this.transactionProcessingStrategyOptions = this.loansAccountProductTemplate.transactionProcessingStrategyOptions.filter(
(cn: CodeName) => !LoanProducts.isAdvancedPaymentAllocationStrategy(cn.code)
);
this.repaymentStrategyDisabled = false;
} else {
// Only Advanced Payment Allocation Strategy
this.loansAccountProductTemplate.transactionProcessingStrategyOptions.some(
(cn: CodeName) => {
if (LoanProducts.isAdvancedPaymentAllocationStrategy(cn.code)) {
this.transactionProcessingStrategyOptions.push(cn);
}
});
this.repaymentStrategyDisabled = true;
}
}
/**
@@ -36,7 +36,6 @@ export class ViewChargeComponent implements OnInit {
private router: Router,
private dialog: MatDialog) {
this.route.data.subscribe((data: { charge: any }) => {
console.log(data.charge);
this.chargeData = data.charge;
if (this.chargeData.minCap) {
this.minCap = true;