build: Use prettier for typescript

Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
Ralph Hopman
2025-01-15 11:59:30 +00:00
committed by Adam Saghy
parent 9d6cf1514a
commit cac1d11ad7
1812 changed files with 22516 additions and 16862 deletions
@@ -8,9 +8,8 @@ describe('LoansAccountChargesStepComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoansAccountChargesStepComponent ]
})
.compileComponents();
declarations: [LoansAccountChargesStepComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -25,7 +25,6 @@ import { ActivatedRoute } from '@angular/router';
styleUrls: ['./loans-account-charges-step.component.scss']
})
export class LoansAccountChargesStepComponent implements OnInit, OnChanges {
// @Input loansAccountProductTemplate: LoansAccountProductTemplate
@Input() loansAccountProductTemplate: any;
// @Imput loansAccountTemplate: LoansAccountTemplate
@@ -42,9 +41,21 @@ export class LoansAccountChargesStepComponent implements OnInit, OnChanges {
/** Collateral Data Source */
collateralDataSource: {}[] = [];
/** Charges table columns */
chargesDisplayedColumns: string[] = ['name', 'chargeCalculationType', 'amount', 'chargeTimeType', 'date', 'action'];
chargesDisplayedColumns: string[] = [
'name',
'chargeCalculationType',
'amount',
'chargeTimeType',
'date',
'action'
];
/** Columns to be displayed in overdue charges table. */
overdueChargesDisplayedColumns: string[] = ['name', 'type', 'amount', 'collectedon'];
overdueChargesDisplayedColumns: string[] = [
'name',
'type',
'amount',
'collectedon'
];
/** Component is pristine if there has been no changes by user interaction */
pristine = true;
/** Check if value of collateral added is more than principal amount */
@@ -59,16 +70,19 @@ export class LoansAccountChargesStepComponent implements OnInit, OnChanges {
* @param {Dates} dateUtils Date Utils
* @param {SettingsService} settingsService Settings Service
*/
constructor(public dialog: MatDialog,
constructor(
public dialog: MatDialog,
private dateUtils: Dates,
private route: ActivatedRoute,
private settingsService: SettingsService) {
private settingsService: SettingsService
) {
this.loanId = this.route.snapshot.params['loanId'];
}
ngOnInit() {
if (this.loansAccountTemplate && this.loansAccountTemplate.charges) {
this.chargesDataSource = this.loansAccountTemplate.charges.map((charge: any) => ({ ...charge, id: charge.chargeId })) || [];
this.chargesDataSource =
this.loansAccountTemplate.charges.map((charge: any) => ({ ...charge, id: charge.chargeId })) || [];
}
}
@@ -81,8 +95,13 @@ export class LoansAccountChargesStepComponent implements OnInit, OnChanges {
if (this.loansAccountProductTemplate.overdueCharges) {
this.overDueChargesDataSource = this.loansAccountProductTemplate.overdueCharges;
}
if (this.loansAccountProductTemplate.charges && this.loansAccountProductTemplate.charges.length > 0 && this.chargesDataSource.length === 0) {
this.chargesDataSource = this.loansAccountProductTemplate.charges.map((charge: any) => ({ ...charge, id: charge.chargeId })) || [];
if (
this.loansAccountProductTemplate.charges &&
this.loansAccountProductTemplate.charges.length > 0 &&
this.chargesDataSource.length === 0
) {
this.chargesDataSource =
this.loansAccountProductTemplate.charges.map((charge: any) => ({ ...charge, id: charge.chargeId })) || [];
}
}
}
@@ -108,7 +127,8 @@ export class LoansAccountChargesStepComponent implements OnInit, OnChanges {
value: charge.amount,
type: 'number',
required: false
}),
})
];
const data = {
title: 'Edit Charge Amount',
@@ -138,7 +158,8 @@ export class LoansAccountChargesStepComponent implements OnInit, OnChanges {
value: charge.dueDate || charge.feeOnMonthDay || '',
type: 'datetime-local',
required: false
}),
})
];
const data = {
title: 'Edit Charge Date',
@@ -179,7 +200,8 @@ export class LoansAccountChargesStepComponent implements OnInit, OnChanges {
value: charge.feeInterval,
type: 'text',
required: false
}),
})
];
const data = {
title: 'Edit Charge Fee Interval',
@@ -214,14 +236,12 @@ export class LoansAccountChargesStepComponent implements OnInit, OnChanges {
});
}
/**
* Returns Loans Account Charges and Collateral Form
*/
get loansAccountCharges() {
return {
charges: this.chargesDataSource,
charges: this.chargesDataSource
};
}
}
@@ -8,9 +8,8 @@ describe('LoansAccountDatatableStepComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LoansAccountDatatableStepComponent ]
})
.compileComponents();
declarations: [LoansAccountDatatableStepComponent]
}).compileComponents();
});
beforeEach(() => {
@@ -16,13 +16,20 @@ export class LoansAccountDatatableStepComponent implements OnInit {
datatableInputs: any = [];
constructor(private formBuilder: UntypedFormBuilder,
constructor(
private formBuilder: UntypedFormBuilder,
private settingsService: SettingsService,
private dateUtils: Dates) { }
private dateUtils: Dates
) {}
ngOnInit(): void {
this.datatableInputs = this.datatableData.columnHeaderData.filter((column: any) => {
return ((column.columnName !== 'id') && (column.columnName !== 'loan_id') && (column.columnName !== 'created_at') && (column.columnName !== 'updated_at'));
return (
column.columnName !== 'id' &&
column.columnName !== 'loan_id' &&
column.columnName !== 'created_at' &&
column.columnName !== 'updated_at'
);
});
const inputItems: any = {};
this.datatableInputs.forEach((input: any) => {
@@ -72,7 +79,7 @@ export class LoansAccountDatatableStepComponent implements OnInit {
}
isColumnType(columnType: string, expectedType: string) {
return (columnType === expectedType);
return columnType === expectedType;
}
get payload(): any {
@@ -104,5 +111,4 @@ export class LoansAccountDatatableStepComponent implements OnInit {
};
return payload;
}
}
@@ -8,9 +8,8 @@ describe('LoansAccountDetailsStepComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoansAccountDetailsStepComponent ]
})
.compileComponents();
declarations: [LoansAccountDetailsStepComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -19,7 +19,6 @@ import { ReplaySubject, Subject } from 'rxjs';
styleUrls: ['./loans-account-details-step.component.scss']
})
export class LoansAccountDetailsStepComponent implements OnInit, OnDestroy {
/** Loans Account Template */
@Input() loansAccountTemplate: any;
@@ -60,11 +59,13 @@ export class LoansAccountDetailsStepComponent implements OnInit, OnDestroy {
* @param {LoansService} loansService Loans Service.
* @param {SettingsService} settingsService SettingsService
*/
constructor(private formBuilder: UntypedFormBuilder,
constructor(
private formBuilder: UntypedFormBuilder,
private loansService: LoansService,
private route: ActivatedRoute,
private settingsService: SettingsService,
private commons: Commons) {
private commons: Commons
) {
this.loanId = this.route.snapshot.params['loanId'];
}
@@ -76,19 +77,21 @@ export class LoansAccountDetailsStepComponent implements OnInit, OnDestroy {
this.productList = this.loansAccountTemplate.productOptions.sort(this.commons.dynamicSort('name'));
if (this.loansAccountTemplate.loanProductId) {
this.loansAccountDetailsForm.patchValue({
'productId': this.loansAccountTemplate.loanProductId,
'submittedOnDate': this.loansAccountTemplate.timeline.submittedOnDate && new Date(this.loansAccountTemplate.timeline.submittedOnDate),
'loanOfficerId': this.loansAccountTemplate.loanOfficerId,
'loanPurposeId': this.loansAccountTemplate.loanPurposeId,
'fundId': this.loansAccountTemplate.fundId,
'expectedDisbursementDate': this.loansAccountTemplate.timeline.expectedDisbursementDate && new Date(this.loansAccountTemplate.timeline.expectedDisbursementDate),
'externalId': this.loansAccountTemplate.externalId
productId: this.loansAccountTemplate.loanProductId,
submittedOnDate:
this.loansAccountTemplate.timeline.submittedOnDate &&
new Date(this.loansAccountTemplate.timeline.submittedOnDate),
loanOfficerId: this.loansAccountTemplate.loanOfficerId,
loanPurposeId: this.loansAccountTemplate.loanPurposeId,
fundId: this.loansAccountTemplate.fundId,
expectedDisbursementDate:
this.loansAccountTemplate.timeline.expectedDisbursementDate &&
new Date(this.loansAccountTemplate.timeline.expectedDisbursementDate),
externalId: this.loansAccountTemplate.externalId
});
}
}
this.filterFormCtrl.valueChanges
.pipe(takeUntil(this._onDestroy))
.subscribe(() => {
this.filterFormCtrl.valueChanges.pipe(takeUntil(this._onDestroy)).subscribe(() => {
this.searchItem();
});
this.productData.next(this.productList.slice());
@@ -104,11 +107,13 @@ export class LoansAccountDetailsStepComponent implements OnInit, OnDestroy {
const search: string = this.filterFormCtrl.value.toLowerCase();
if (!search) {
this.productData.next(this.productList.slice());
this.productData.next(this.productList.slice());
} else {
this.productData.next(this.productList.filter((option: any) => {
return option['name'].toLowerCase().indexOf(search) >= 0;
}));
this.productData.next(
this.productList.filter((option: any) => {
return option['name'].toLowerCase().indexOf(search) >= 0;
})
);
}
}
}
@@ -118,15 +123,24 @@ export class LoansAccountDetailsStepComponent implements OnInit, OnDestroy {
*/
createLoansAccountDetailsForm() {
this.loansAccountDetailsForm = this.formBuilder.group({
'productId': ['', Validators.required],
'loanOfficerId': [''],
'loanPurposeId': [''],
'fundId': [''],
'submittedOnDate': [this.settingsService.businessDate, Validators.required],
'expectedDisbursementDate': ['', Validators.required],
'externalId': [''],
'linkAccountId': [''],
'createStandingInstructionAtDisbursement': ['']
productId: [
'',
Validators.required
],
loanOfficerId: [''],
loanPurposeId: [''],
fundId: [''],
submittedOnDate: [
this.settingsService.businessDate,
Validators.required
],
expectedDisbursementDate: [
'',
Validators.required
],
externalId: [''],
linkAccountId: [''],
createStandingInstructionAtDisbursement: ['']
});
}
@@ -134,8 +148,10 @@ export class LoansAccountDetailsStepComponent implements OnInit, OnDestroy {
* Fetches loans account product template on productId value changes
*/
buildDependencies() {
const entityId = (this.loansAccountTemplate.clientId) ? this.loansAccountTemplate.clientId : this.loansAccountTemplate.group.id;
const isGroup = (this.loansAccountTemplate.clientId) ? false : true;
const entityId = this.loansAccountTemplate.clientId
? this.loansAccountTemplate.clientId
: this.loansAccountTemplate.group.id;
const isGroup = this.loansAccountTemplate.clientId ? false : true;
this.loansAccountDetailsForm.get('productId').valueChanges.subscribe((productId: string) => {
this.loansService.getLoansAccountTemplateResource(entityId, isGroup, productId).subscribe((response: any) => {
this.loansAccountProductTemplate.emit(response);
@@ -145,7 +161,9 @@ export class LoansAccountDetailsStepComponent implements OnInit, OnDestroy {
this.accountLinkingOptions = response.accountLinkingOptions;
this.loanProductSelected = true;
if (response.createStandingInstructionAtDisbursement) {
this.loansAccountDetailsForm.get('createStandingInstructionAtDisbursement').patchValue(response.createStandingInstructionAtDisbursement);
this.loansAccountDetailsForm
.get('createStandingInstructionAtDisbursement')
.patchValue(response.createStandingInstructionAtDisbursement);
}
});
});
@@ -157,5 +175,4 @@ export class LoansAccountDetailsStepComponent implements OnInit, OnDestroy {
get loansAccountDetails() {
return this.loansAccountDetailsForm.getRawValue();
}
}
@@ -8,9 +8,8 @@ describe('LoansAccountPreviewStepComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoansAccountPreviewStepComponent ]
})
.compileComponents();
declarations: [LoansAccountPreviewStepComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -10,7 +10,6 @@ import { Component, Input, Output, EventEmitter, OnChanges, SimpleChanges } from
styleUrls: ['./loans-account-preview-step.component.scss']
})
export class LoansAccountPreviewStepComponent implements OnChanges {
/** Loans Account Template */
@Input() loansAccountTemplate: any = [];
/** Loans Account Product Template */
@@ -21,16 +20,26 @@ export class LoansAccountPreviewStepComponent implements OnChanges {
@Output() submitEvent = new EventEmitter();
/** Charges Displayed Columns */
chargesDisplayedColumns: string[] = ['name', 'chargeCalculationType', 'amount', 'chargeTimeType', 'date'];
chargesDisplayedColumns: string[] = [
'name',
'chargeCalculationType',
'amount',
'chargeTimeType',
'date'
];
/** Overdue Charges Displayed Columns */
overdueChargesDisplayedColumns: string[] = ['name', 'type', 'amount', 'collectedon'];
overdueChargesDisplayedColumns: string[] = [
'name',
'type',
'amount',
'collectedon'
];
productEnableDownPayment = false;
constructor() { }
constructor() {}
ngOnChanges(changes: SimpleChanges): void {
this.productEnableDownPayment = this.loansAccountProductTemplate.product.enableDownPayment;
}
}
@@ -8,9 +8,8 @@ describe('LoansAccountScheduleStepComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LoansAccountScheduleStepComponent ]
})
.compileComponents();
declarations: [LoansAccountScheduleStepComponent]
}).compileComponents();
});
beforeEach(() => {
@@ -9,7 +9,6 @@ import { SettingsService } from 'app/settings/settings.service';
styleUrls: ['./loans-account-schedule-step.component.scss']
})
export class LoansAccountScheduleStepComponent {
/** Currency Code */
@Input() currencyCode: string;
/** Loans Account Template */
@@ -19,22 +18,29 @@ export class LoansAccountScheduleStepComponent {
/** Loans Account Data */
@Input() loansAccount: any;
repaymentScheduleDetails: any = {periods: []};
repaymentScheduleDetails: any = { periods: [] };
loanId: any = null;
constructor(private loansService: LoansService,
constructor(
private loansService: LoansService,
private settingsService: SettingsService,
private route: ActivatedRoute) {
this.loanId = this.route.snapshot.params['loanId'];
private route: ActivatedRoute
) {
this.loanId = this.route.snapshot.params['loanId'];
}
showRepaymentInfo(): void {
this.repaymentScheduleDetails = {periods: []};
this.repaymentScheduleDetails = { periods: [] };
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const payload = this.loansService.buildLoanRequestPayload(this.loansAccount, this.loansAccountTemplate,
this.loansAccountProductTemplate.calendarOptions, locale, dateFormat);
const payload = this.loansService.buildLoanRequestPayload(
this.loansAccount,
this.loansAccountTemplate,
this.loansAccountProductTemplate.calendarOptions,
locale,
dateFormat
);
delete payload['enableInstallmentLevelDelinquency'];
this.loansService.calculateLoanSchedule(payload).subscribe((response: any) => {
@@ -8,9 +8,8 @@ describe('LoansAccountTermsStepComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoansAccountTermsStepComponent ]
})
.compileComponents();
declarations: [LoansAccountTermsStepComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -24,7 +24,6 @@ import { CodeName, OptionData } from 'app/shared/models/option-data.model';
styleUrls: ['./loans-account-terms-step.component.scss']
})
export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
/** Loans Product Options */
@Input() loansProductOptions: any;
/** Loans Account Product Template */
@@ -74,9 +73,19 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
/** Collateral Data Source */
collateralDataSource: {}[] = [];
/** Columns to be displayed in collateral table. */
loanCollateralDisplayedColumns: string[] = ['type', 'value', 'totalValue', 'totalCollateralValue', 'action'];
loanCollateralDisplayedColumns: string[] = [
'type',
'value',
'totalValue',
'totalCollateralValue',
'action'
];
/** Disbursement Data Displayed Columns */
disbursementDisplayedColumns: string[] = ['expectedDisbursementDate', 'principal', 'actions'];
disbursementDisplayedColumns: string[] = [
'expectedDisbursementDate',
'principal',
'actions'
];
/** Multi Disbursement Control */
totalMultiDisbursed: any = 0;
isMultiDisbursedCompleted = false;
@@ -97,12 +106,14 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
* @param formBuilder FormBuilder
* @param {SettingsService} settingsService SettingsService
*/
constructor(private formBuilder: UntypedFormBuilder,
constructor(
private formBuilder: UntypedFormBuilder,
private settingsService: SettingsService,
private route: ActivatedRoute,
public dialog: MatDialog) {
this.loanId = this.route.snapshot.params['loanId'];
this.createloansAccountTermsForm();
public dialog: MatDialog
) {
this.loanId = this.route.snapshot.params['loanId'];
this.createloansAccountTermsForm();
}
/**
* Executes on change of input values
@@ -124,30 +135,30 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
this.interestRateFrequencyTypeData = this.loansAccountTermsData.interestRateFrequencyTypeOptions;
this.loansAccountTermsForm.patchValue({
'principalAmount': this.loansAccountTermsData.principal,
'loanTermFrequency': this.loansAccountTermsData.termFrequency,
'loanTermFrequencyType': this.loansAccountTermsData.termPeriodFrequencyType.id,
'numberOfRepayments': this.loansAccountTermsData.numberOfRepayments,
'repaymentEvery': this.loansAccountTermsData.repaymentEvery,
'repaymentFrequencyType': this.loansAccountTermsData.repaymentFrequencyType.id,
'amortizationType': this.loansAccountTermsData.amortizationType.id,
'isEqualAmortization': this.loansAccountTermsData.isEqualAmortization,
'interestType': this.loansAccountTermsData.interestType.id,
'isFloatingInterestRate': this.loansAccountTermsData.isLoanProductLinkedToFloatingRate ? false : '',
'interestCalculationPeriodType': this.loansAccountTermsData.interestCalculationPeriodType.id,
'allowPartialPeriodInterestCalcualtion': this.loansAccountTermsData.allowPartialPeriodInterestCalcualtion,
'inArrearsTolerance': this.loansAccountTermsData.inArrearsTolerance,
'graceOnPrincipalPayment': this.loansAccountTermsData.graceOnPrincipalPayment,
'graceOnInterestPayment': this.loansAccountTermsData.graceOnInterestPayment,
'graceOnArrearsAgeing': this.loansAccountTermsData.graceOnArrearsAgeing,
'graceOnInterestCharged': this.loansAccountTermsData.graceOnInterestCharged,
'fixedEmiAmount': this.loansAccountTermsData.fixedEmiAmount,
'maxOutstandingLoanBalance': this.loansAccountTermsData.maxOutstandingLoanBalance,
'transactionProcessingStrategyCode': this.loansAccountTermsData.transactionProcessingStrategyCode,
'interestRateDifferential': this.loansAccountTermsData.interestRateDifferential,
'multiDisburseLoan': this.loansAccountTermsData.multiDisburseLoan,
'interestRateFrequencyType': this.loansAccountTermsData.interestRateFrequencyType.id,
'balloonRepaymentAmount': this.loansAccountTermsData.balloonRepaymentAmount,
principalAmount: this.loansAccountTermsData.principal,
loanTermFrequency: this.loansAccountTermsData.termFrequency,
loanTermFrequencyType: this.loansAccountTermsData.termPeriodFrequencyType.id,
numberOfRepayments: this.loansAccountTermsData.numberOfRepayments,
repaymentEvery: this.loansAccountTermsData.repaymentEvery,
repaymentFrequencyType: this.loansAccountTermsData.repaymentFrequencyType.id,
amortizationType: this.loansAccountTermsData.amortizationType.id,
isEqualAmortization: this.loansAccountTermsData.isEqualAmortization,
interestType: this.loansAccountTermsData.interestType.id,
isFloatingInterestRate: this.loansAccountTermsData.isLoanProductLinkedToFloatingRate ? false : '',
interestCalculationPeriodType: this.loansAccountTermsData.interestCalculationPeriodType.id,
allowPartialPeriodInterestCalcualtion: this.loansAccountTermsData.allowPartialPeriodInterestCalcualtion,
inArrearsTolerance: this.loansAccountTermsData.inArrearsTolerance,
graceOnPrincipalPayment: this.loansAccountTermsData.graceOnPrincipalPayment,
graceOnInterestPayment: this.loansAccountTermsData.graceOnInterestPayment,
graceOnArrearsAgeing: this.loansAccountTermsData.graceOnArrearsAgeing,
graceOnInterestCharged: this.loansAccountTermsData.graceOnInterestCharged,
fixedEmiAmount: this.loansAccountTermsData.fixedEmiAmount,
maxOutstandingLoanBalance: this.loansAccountTermsData.maxOutstandingLoanBalance,
transactionProcessingStrategyCode: this.loansAccountTermsData.transactionProcessingStrategyCode,
interestRateDifferential: this.loansAccountTermsData.interestRateDifferential,
multiDisburseLoan: this.loansAccountTermsData.multiDisburseLoan,
interestRateFrequencyType: this.loansAccountTermsData.interestRateFrequencyType.id,
balloonRepaymentAmount: this.loansAccountTermsData.balloonRepaymentAmount
});
this.setAdvancedPaymentStrategyControls();
@@ -165,11 +176,17 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
});
}
if (this.isDelinquencyEnabled()) {
this.loansAccountTermsForm.addControl('enableInstallmentLevelDelinquency', new UntypedFormControl(this.loansAccountTermsData.enableInstallmentLevelDelinquency || this.loanProduct.enableInstallmentLevelDelinquency));
this.loansAccountTermsForm.addControl(
'enableInstallmentLevelDelinquency',
new UntypedFormControl(
this.loansAccountTermsData.enableInstallmentLevelDelinquency ||
this.loanProduct.enableInstallmentLevelDelinquency
)
);
}
this.collateralDataSource = this.loansAccountTermsData.collateral || [];
if (this.productEnableDownPayment) {
const enableDownPayment = (this.loansAccountTermsData['enableDownPayment'] === false) ? false : true;
const enableDownPayment = this.loansAccountTermsData['enableDownPayment'] === false ? false : true;
this.loansAccountTermsForm.addControl('enableDownPayment', new UntypedFormControl(enableDownPayment));
}
@@ -217,34 +234,36 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
if (this.loansAccountTermsData) {
if (this.loansAccountTermsData.loanProductId) {
this.loansAccountTermsForm.patchValue({
'repaymentsStartingFromDate': this.loansAccountTermsData.expectedFirstRepaymentOnDate && new Date(this.loansAccountTermsData.expectedFirstRepaymentOnDate)
repaymentsStartingFromDate:
this.loansAccountTermsData.expectedFirstRepaymentOnDate &&
new Date(this.loansAccountTermsData.expectedFirstRepaymentOnDate)
});
}
this.loansAccountTermsForm.patchValue({
'principalAmount': this.loansAccountTermsData.principal,
'loanTermFrequency': this.loansAccountTermsData.termFrequency,
'loanTermFrequencyType': this.loansAccountTermsData.termPeriodFrequencyType.id,
'numberOfRepayments': this.loansAccountTermsData.numberOfRepayments,
'repaymentEvery': this.loansAccountTermsData.repaymentEvery,
'repaymentFrequencyType': this.loansAccountTermsData.repaymentFrequencyType.id,
'amortizationType': this.loansAccountTermsData.amortizationType.id,
'isEqualAmortization': this.loansAccountTermsData.isEqualAmortization,
'interestType': this.loansAccountTermsData.interestType.id,
'isFloatingInterestRate': this.loansAccountTermsData.isLoanProductLinkedToFloatingRate ? false : '',
'interestCalculationPeriodType': this.loansAccountTermsData.interestCalculationPeriodType.id,
'allowPartialPeriodInterestCalcualtion': this.loansAccountTermsData.allowPartialPeriodInterestCalcualtion,
'inArrearsTolerance': this.loansAccountTermsData.inArrearsTolerance,
'graceOnPrincipalPayment': this.loansAccountTermsData.graceOnPrincipalPayment,
'graceOnInterestPayment': this.loansAccountTermsData.graceOnInterestPayment,
'graceOnArrearsAgeing': this.loansAccountTermsData.graceOnArrearsAgeing,
'graceOnInterestCharged': this.loansAccountTermsData.graceOnInterestCharged,
'fixedEmiAmount': this.loansAccountTermsData.fixedEmiAmount,
'maxOutstandingLoanBalance': this.loansAccountTermsData.maxOutstandingLoanBalance,
'transactionProcessingStrategyCode': this.loansAccountTermsData.transactionProcessingStrategyCode,
'interestRateDifferential': this.loansAccountTermsData.interestRateDifferential,
'multiDisburseLoan': this.loansAccountTermsData.multiDisburseLoan,
'interestRateFrequencyType': this.loansAccountTermsData.interestRateFrequencyType.id,
'balloonRepaymentAmount': this.loansAccountTermsData.balloonRepaymentAmount
principalAmount: this.loansAccountTermsData.principal,
loanTermFrequency: this.loansAccountTermsData.termFrequency,
loanTermFrequencyType: this.loansAccountTermsData.termPeriodFrequencyType.id,
numberOfRepayments: this.loansAccountTermsData.numberOfRepayments,
repaymentEvery: this.loansAccountTermsData.repaymentEvery,
repaymentFrequencyType: this.loansAccountTermsData.repaymentFrequencyType.id,
amortizationType: this.loansAccountTermsData.amortizationType.id,
isEqualAmortization: this.loansAccountTermsData.isEqualAmortization,
interestType: this.loansAccountTermsData.interestType.id,
isFloatingInterestRate: this.loansAccountTermsData.isLoanProductLinkedToFloatingRate ? false : '',
interestCalculationPeriodType: this.loansAccountTermsData.interestCalculationPeriodType.id,
allowPartialPeriodInterestCalcualtion: this.loansAccountTermsData.allowPartialPeriodInterestCalcualtion,
inArrearsTolerance: this.loansAccountTermsData.inArrearsTolerance,
graceOnPrincipalPayment: this.loansAccountTermsData.graceOnPrincipalPayment,
graceOnInterestPayment: this.loansAccountTermsData.graceOnInterestPayment,
graceOnArrearsAgeing: this.loansAccountTermsData.graceOnArrearsAgeing,
graceOnInterestCharged: this.loansAccountTermsData.graceOnInterestCharged,
fixedEmiAmount: this.loansAccountTermsData.fixedEmiAmount,
maxOutstandingLoanBalance: this.loansAccountTermsData.maxOutstandingLoanBalance,
transactionProcessingStrategyCode: this.loansAccountTermsData.transactionProcessingStrategyCode,
interestRateDifferential: this.loansAccountTermsData.interestRateDifferential,
multiDisburseLoan: this.loansAccountTermsData.multiDisburseLoan,
interestRateFrequencyType: this.loansAccountTermsData.interestRateFrequencyType.id,
balloonRepaymentAmount: this.loansAccountTermsData.balloonRepaymentAmount
});
}
this.createloansAccountTermsForm();
@@ -254,7 +273,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
}
allowAddDisbursementDetails() {
return (this.multiDisburseLoan && !this.loansAccountTermsData.disallowExpectedDisbursements);
return this.multiDisburseLoan && !this.loansAccountTermsData.disallowExpectedDisbursements;
}
/** Custom Validators for the form */
@@ -262,63 +281,68 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
const repaymentFrequencyNthDayType = this.loansAccountTermsForm.get('repaymentFrequencyNthDayType');
const repaymentFrequencyDayOfWeekType = this.loansAccountTermsForm.get('repaymentFrequencyDayOfWeekType');
this.loansAccountTermsForm.get('repaymentFrequencyType').valueChanges
.subscribe(repaymentFrequencyType => {
this.loansAccountTermsForm.get('repaymentFrequencyType').valueChanges.subscribe((repaymentFrequencyType) => {
if (repaymentFrequencyType === 2) {
repaymentFrequencyNthDayType.setValidators([Validators.required]);
repaymentFrequencyDayOfWeekType.setValidators([Validators.required]);
} else {
repaymentFrequencyNthDayType.setValidators(null);
repaymentFrequencyDayOfWeekType.setValidators(null);
}
if (repaymentFrequencyType === 2) {
repaymentFrequencyNthDayType.setValidators([Validators.required]);
repaymentFrequencyDayOfWeekType.setValidators([Validators.required]);
} else {
repaymentFrequencyNthDayType.setValidators(null);
repaymentFrequencyDayOfWeekType.setValidators(null);
}
repaymentFrequencyNthDayType.updateValueAndValidity();
repaymentFrequencyDayOfWeekType.updateValueAndValidity();
});
repaymentFrequencyNthDayType.updateValueAndValidity();
repaymentFrequencyDayOfWeekType.updateValueAndValidity();
});
}
/** Custom Listeners for the form to calculate Loan Term */
setLoanTermListener() {
this.loansAccountTermsForm.get('numberOfRepayments').valueChanges
.subscribe(numberOfRepayments => {
const repaymentEvery: number = this.loansAccountTermsForm.value.repaymentEvery;
this.calculateLoanTerm(numberOfRepayments, repaymentEvery);
});
this.loansAccountTermsForm.get('numberOfRepayments').valueChanges.subscribe((numberOfRepayments) => {
const repaymentEvery: number = this.loansAccountTermsForm.value.repaymentEvery;
this.calculateLoanTerm(numberOfRepayments, repaymentEvery);
});
this.loansAccountTermsForm.get('repaymentEvery').valueChanges
.subscribe(repaymentEvery => {
const numberOfRepayments: number = this.loansAccountTermsForm.value.numberOfRepayments;
this.calculateLoanTerm(numberOfRepayments, repaymentEvery);
});
this.loansAccountTermsForm.get('repaymentEvery').valueChanges.subscribe((repaymentEvery) => {
const numberOfRepayments: number = this.loansAccountTermsForm.value.numberOfRepayments;
this.calculateLoanTerm(numberOfRepayments, repaymentEvery);
});
this.loansAccountTermsForm.get('loanTermFrequencyType').valueChanges
.subscribe(loanTermFrequencyType => {
this.loansAccountTermsForm.patchValue({'repaymentFrequencyType': loanTermFrequencyType});
});
this.loansAccountTermsForm.get('loanTermFrequencyType').valueChanges.subscribe((loanTermFrequencyType) => {
this.loansAccountTermsForm.patchValue({ repaymentFrequencyType: loanTermFrequencyType });
});
this.loansAccountTermsForm.get('amortizationType').valueChanges
.subscribe(amortizationType => {
if (amortizationType === 0) { // Equal Principal Payments
this.loansAccountTermsForm.addControl('fixedPrincipalPercentagePerInstallment', new UntypedFormControl(''));
} else { // Equal Installments
this.loansAccountTermsForm.removeControl('fixedPrincipalPercentagePerInstallment');
}
this.loansAccountTermsForm.get('amortizationType').valueChanges.subscribe((amortizationType) => {
if (amortizationType === 0) {
// Equal Principal Payments
this.loansAccountTermsForm.addControl('fixedPrincipalPercentagePerInstallment', new UntypedFormControl(''));
} else {
// Equal Installments
this.loansAccountTermsForm.removeControl('fixedPrincipalPercentagePerInstallment');
}
});
}
setAdvancedPaymentStrategyControls(): void {
// Fixed Length validation
if (this.loansAccountTermsData) {
this.loansAccountTermsForm.removeControl('interestRatePerPeriod');
this.loansAccountTermsForm.removeControl('fixedLength');
if (this.loansAccountTermsData.product.fixedLength) {
this.loansAccountTermsForm.addControl('interestRatePerPeriod', new UntypedFormControl({value: 0, disabled: true}, Validators.required));
this.loansAccountTermsForm.addControl('fixedLength', new UntypedFormControl(this.loansAccountTermsData.product.fixedLength));
} else {
this.loansAccountTermsForm.addControl('interestRatePerPeriod', new UntypedFormControl(this.loansAccountTermsData.interestRatePerPeriod, Validators.required));
}
// Fixed Length validation
if (this.loansAccountTermsData) {
this.loansAccountTermsForm.removeControl('interestRatePerPeriod');
this.loansAccountTermsForm.removeControl('fixedLength');
if (this.loansAccountTermsData.product.fixedLength) {
this.loansAccountTermsForm.addControl(
'interestRatePerPeriod',
new UntypedFormControl({ value: 0, disabled: true }, Validators.required)
);
this.loansAccountTermsForm.addControl(
'fixedLength',
new UntypedFormControl(this.loansAccountTermsData.product.fixedLength)
);
} else {
this.loansAccountTermsForm.addControl(
'interestRatePerPeriod',
new UntypedFormControl(this.loansAccountTermsData.interestRatePerPeriod, Validators.required)
);
}
}
}
hasFixedLength(): boolean {
@@ -329,49 +353,73 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
}
isEqualPrincipalPayments(): boolean {
return (this.loansAccountTermsForm.value.amortizationType === 0);
return this.loansAccountTermsForm.value.amortizationType === 0;
}
/** Create Loans Account Terms Form */
createloansAccountTermsForm() {
this.loansAccountTermsForm = this.formBuilder.group({
'principalAmount': ['', Validators.required],
'loanTermFrequency': [{ value: '', disabled: true }, Validators.required],
'loanTermFrequencyType': ['', Validators.required],
'numberOfRepayments': ['', Validators.required],
'repaymentEvery': ['', Validators.required],
'repaymentFrequencyType': [{ value: '', disabled: true }, Validators.required],
'repaymentFrequencyNthDayType': [''],
'repaymentFrequencyDayOfWeekType': [''],
'repaymentsStartingFromDate': [''],
'interestChargedFromDate': [''],
'interestRatePerPeriod': [''],
'interestType': [''],
'isFloatingInterestRate': [''],
'isEqualAmortization': [''],
'amortizationType': ['', Validators.required],
'interestCalculationPeriodType': [''],
'allowPartialPeriodInterestCalcualtion': [''],
'inArrearsTolerance': [''],
'graceOnInterestCharged': [''],
'graceOnPrincipalPayment': [''],
'graceOnInterestPayment': [''],
'graceOnArrearsAgeing': [''],
'loanIdToClose': [''],
'fixedEmiAmount': [''],
'isTopup': [''],
'maxOutstandingLoanBalance': [''],
'interestRateDifferential': [''],
'transactionProcessingStrategyCode': ['', Validators.required],
'multiDisburseLoan': [false],
'interestRateFrequencyType': [''],
'balloonRepaymentAmount': ['']
principalAmount: [
'',
Validators.required
],
loanTermFrequency: [
{ value: '', disabled: true },
Validators.required
],
loanTermFrequencyType: [
'',
Validators.required
],
numberOfRepayments: [
'',
Validators.required
],
repaymentEvery: [
'',
Validators.required
],
repaymentFrequencyType: [
{ value: '', disabled: true },
Validators.required
],
repaymentFrequencyNthDayType: [''],
repaymentFrequencyDayOfWeekType: [''],
repaymentsStartingFromDate: [''],
interestChargedFromDate: [''],
interestRatePerPeriod: [''],
interestType: [''],
isFloatingInterestRate: [''],
isEqualAmortization: [''],
amortizationType: [
'',
Validators.required
],
interestCalculationPeriodType: [''],
allowPartialPeriodInterestCalcualtion: [''],
inArrearsTolerance: [''],
graceOnInterestCharged: [''],
graceOnPrincipalPayment: [''],
graceOnInterestPayment: [''],
graceOnArrearsAgeing: [''],
loanIdToClose: [''],
fixedEmiAmount: [''],
isTopup: [''],
maxOutstandingLoanBalance: [''],
interestRateDifferential: [''],
transactionProcessingStrategyCode: [
'',
Validators.required
],
multiDisburseLoan: [false],
interestRateFrequencyType: [''],
balloonRepaymentAmount: ['']
});
}
calculateLoanTerm(numberOfRepayments: number, repaymentEvery: number): void {
const loanTerm = numberOfRepayments * repaymentEvery;
this.loansAccountTermsForm.patchValue({'loanTermFrequency': loanTerm});
this.loansAccountTermsForm.patchValue({ loanTermFrequency: loanTerm });
}
/**
@@ -408,6 +456,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
required: true,
order: 2
})
];
const data = {
title: 'Add Disbursement Details',
@@ -418,10 +467,10 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
disbursementDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) {
const principal = response.data.value.principal * 1;
if ((this.totalMultiDisbursed + principal) <= currentPrincipalAmount) {
if (this.totalMultiDisbursed + principal <= currentPrincipalAmount) {
this.disbursementDataSource = this.disbursementDataSource.concat(response.data.value);
this.totalMultiDisbursed += principal;
this.isMultiDisbursedCompleted = (this.totalMultiDisbursed === currentPrincipalAmount);
this.isMultiDisbursedCompleted = this.totalMultiDisbursed === currentPrincipalAmount;
this.pristine = false;
}
}
@@ -443,7 +492,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
this.disbursementDataSource.splice(index, 1);
this.disbursementDataSource = this.disbursementDataSource.concat([]);
this.totalMultiDisbursed -= principal;
this.isMultiDisbursedCompleted = (this.totalMultiDisbursed === currentPrincipalAmount);
this.isMultiDisbursedCompleted = this.totalMultiDisbursed === currentPrincipalAmount;
}
});
}
@@ -459,11 +508,14 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
if (response.data) {
const collateralData = {
type: response.data.value.collateral,
value: response.data.value.quantity,
value: response.data.value.quantity
};
this.totalCollateralValue += collateralData.type.pctToBase * collateralData.type.basePrice * collateralData.value / 100;
this.totalCollateralValue +=
(collateralData.type.pctToBase * collateralData.type.basePrice * collateralData.value) / 100;
this.collateralDataSource = this.collateralDataSource.concat(collateralData);
this.collateralOptions = this.collateralOptions.filter((user: any) => user.collateralId !== response.data.value.collateral.collateralId);
this.collateralOptions = this.collateralOptions.filter(
(user: any) => user.collateralId !== response.data.value.collateral.collateralId
);
if (this.loanPrincipal < this.totalCollateralValue) {
this.isCollateralSufficient = true;
} else {
@@ -484,7 +536,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
if (response.delete) {
const removed: any = this.collateralDataSource.splice(id, 1);
this.collateralOptions = this.collateralOptions.concat(removed[0].type);
this.totalCollateralValue -= removed[0].type.pctToBase * removed[0].type.basePrice * removed[0].value / 100;
this.totalCollateralValue -= (removed[0].type.pctToBase * removed[0].type.basePrice * removed[0].value) / 100;
this.collateralDataSource = this.collateralDataSource.concat([]);
this.pristine = false;
if (this.loanPrincipal < this.totalCollateralValue) {
@@ -502,7 +554,8 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
setOptions() {
this.termFrequencyTypeData = this.loansAccountProductTemplate.termFrequencyTypeOptions;
this.repaymentFrequencyNthDayTypeData = this.loansAccountProductTemplate.repaymentFrequencyNthDayTypeOptions;
this.repaymentFrequencyDaysOfWeekTypeData = this.loansAccountProductTemplate.repaymentFrequencyDaysOfWeekTypeOptions;
this.repaymentFrequencyDaysOfWeekTypeData =
this.loansAccountProductTemplate.repaymentFrequencyDaysOfWeekTypeOptions;
this.interestTypeData = this.loansAccountProductTemplate.interestTypeOptions;
this.amortizationTypeData = this.loansAccountProductTemplate.amortizationTypeOptions;
this.interestCalculationPeriodTypeData = this.loansAccountProductTemplate.interestCalculationPeriodTypeOptions;
@@ -511,14 +564,14 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
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.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) => {
this.loansAccountProductTemplate.transactionProcessingStrategyOptions.some((cn: CodeName) => {
if (LoanProducts.isAdvancedPaymentAllocationStrategy(cn.code)) {
this.transactionProcessingStrategyOptions.push(cn);
}
@@ -554,5 +607,4 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
collateral: this.collateralDataSource
};
}
}