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;
+2
View File
@@ -1479,6 +1479,8 @@
"Loan Product": "Úvěrový produkt",
"Loan Purpose": "Účel půjčky",
"Loan Reschedules": "Termíny půjček",
"Loan Schedule Processing Type": "Typ zpracování plánu úvěru",
"Loan Schedule Type": "Typ harmonogramu půjčky",
"Loan Screen Reports": "Zprávy obrazovky půjčky",
"Loan Status": "Stav půjčky",
"Loan Term": "Doba půjčky",
+2
View File
@@ -1479,6 +1479,8 @@
"Loan Product": "Darlehensprodukt",
"Loan Purpose": "Darlehen Zweck",
"Loan Reschedules": "Kreditumschuldungen",
"Loan Schedule Processing Type": "Kredite Scheduleverarbeitungstyp",
"Loan Schedule Type": "Darlehensplan Typ",
"Loan Screen Reports": "Kreditbildschirmberichte",
"Loan Status": "Kreditstatus",
"Loan Term": "Kreditlaufzeit",
+2
View File
@@ -1478,6 +1478,8 @@
"Loan Product": "Loan Product",
"Loan Purpose": "Loan Purpose",
"Loan Reschedules": "Loan Reschedules",
"Loan Schedule Processing Type": "Loan Schedule Processing Type",
"Loan Schedule Type": "Loan Schedule Type",
"Loan Screen Reports": "Loan Screen Reports",
"Loan Status": "Loan Status",
"Loan Term": "Loan Term",
+4 -2
View File
@@ -847,7 +847,7 @@
"Total Withdrawals": "Retiros totales",
"Transaction Details": "Detalles de la transacción",
"Transaction Reverted": "Transacción revertida",
"Transactions": "Actas",
"Transactions": "Transacciones",
"Transferred From": "Transferido desde",
"Transferred To": "Transferido a",
"Transferring From Details": "Transferir desde detalles",
@@ -1478,7 +1478,9 @@
"Loan Parameters": "Parámetros del Crédito",
"Loan Product": "Producto de Crédito",
"Loan Purpose": "Propósito del Crédito",
"Loan Schedule Processing Type": "Tipo de procesamiento del calendario de pagos",
"Loan Reschedules": "Reprogramaciones de Créditos",
"Loan Schedule Type": "Tipo de calendario de pagos",
"Loan Screen Reports": "Informes de pantalla de Créditos",
"Loan Status": "Estado del Crédito",
"Loan Term": "Plazo del Crédito",
@@ -1949,7 +1951,7 @@
"Transaction Reference": "Referencia de transacción",
"Transaction Type": "tipo de transacción",
"Transaction date": "Fecha de Transacción",
"Transactions": "Actas",
"Transactions": "Transacciones",
"Transfer Date": "Fecha de transferencia",
"Transfer Date From": "Fecha de transferencia desde",
"Transfer Date To": "Fecha de transferencia a",
+2
View File
@@ -1479,6 +1479,8 @@
"Loan Product": "Produit de prêt",
"Loan Purpose": "Objectif du prêt",
"Loan Reschedules": "Rééchelonnements de prêt",
"Loan Schedule Processing Type": "Type de traitement des horaires de prêt",
"Loan Schedule Type": "Type de calendrier de prêt",
"Loan Screen Reports": "Rapports d'écran de prêt",
"Loan Status": "Statut du prêt",
"Loan Term": "Durée du prêt",
+2
View File
@@ -1479,6 +1479,8 @@
"Loan Product": "Prodotto di prestito",
"Loan Purpose": "Scopo del prestito",
"Loan Reschedules": "Riprogrammazione del prestito",
"Loan Schedule Processing Type": "Tipo di elaborazione del programma di prestito",
"Loan Schedule Type": "Tipo di programma di prestito",
"Loan Screen Reports": "Rapporti sullo schermo del prestito",
"Loan Status": "Stato del prestito",
"Loan Term": "Durata del prestito",
+2
View File
@@ -1479,6 +1479,8 @@
"Loan Product": "대출상품",
"Loan Purpose": "대출목적",
"Loan Reschedules": "대출 일정 조정",
"Loan Schedule Processing Type": "대출 일정 처리 유형",
"Loan Schedule Type": "대출 일정 유형",
"Loan Screen Reports": "대출 화면 보고서",
"Loan Status": "대출현황",
"Loan Term": "대출기간",
+2
View File
@@ -1479,6 +1479,8 @@
"Loan Product": "Paskolos produktas",
"Loan Purpose": "Paskolos tikslas",
"Loan Reschedules": "Paskolų atidėjimas",
"Loan Schedule Processing Type": "Paskolų grafiko apdorojimo tipas",
"Loan Schedule Type": "Paskolos grafiko tipas",
"Loan Screen Reports": "Paskolos ekrano ataskaitos",
"Loan Status": "Paskolos būsena",
"Loan Term": "Paskolos terminas",
+2
View File
@@ -1479,6 +1479,8 @@
"Loan Product": "Aizdevuma produkts",
"Loan Purpose": "Aizdevuma mērķis",
"Loan Reschedules": "Aizdevuma grafiki",
"Loan Schedule Processing Type": "Aizdevumu grafika apstrādes veids",
"Loan Schedule Type": "Aizdevuma grafika tips",
"Loan Screen Reports": "Aizdevuma ekrāna pārskati",
"Loan Status": "Aizdevuma statuss",
"Loan Term": "Aizdevuma termiņš",
+2
View File
@@ -1479,6 +1479,8 @@
"Loan Product": "ऋण उत्पादन",
"Loan Purpose": "ऋण उद्देश्य",
"Loan Reschedules": "ऋण पुन: तालिका",
"Loan Schedule Processing Type": "ऋण ण अनुसूची प्रशोधन गर्ने प्रकार",
"Loan Schedule Type": "ऋण ण तालिका प्रकार",
"Loan Screen Reports": "ऋण स्क्रिन रिपोर्टहरू",
"Loan Status": "ऋण स्थिति",
"Loan Term": "ऋण अवधि",
+2
View File
@@ -1479,6 +1479,8 @@
"Loan Product": "Produto de empréstimo",
"Loan Purpose": "Finalidade do empréstimo",
"Loan Reschedules": "Reprogramações de empréstimos",
"Loan Schedule Processing Type": "Tipo de processamento de cronograma de empréstimo",
"Loan Schedule Type": "Tipo de cronograma de empréstimo",
"Loan Screen Reports": "Relatórios de tela de empréstimo",
"Loan Status": "Situação do empréstimo",
"Loan Term": "Prazo do empréstimo",
+2
View File
@@ -1479,6 +1479,8 @@
"Loan Product": "Bidhaa ya Mkopo",
"Loan Purpose": "Madhumuni ya Mkopo",
"Loan Reschedules": "Ratiba za Mikopo",
"Loan Schedule Processing Type": "Aina ya usindikaji wa ratiba ya mkopo",
"Loan Schedule Type": "Aina ya ratiba ya mkopo",
"Loan Screen Reports": "Ripoti za skrini ya mkopo",
"Loan Status": "Hali ya Mkopo",
"Loan Term": "Muda wa Mkopo",