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('CreateGlimAccountComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ CreateGlimAccountComponent ]
})
.compileComponents();
declarations: [CreateGlimAccountComponent]
}).compileComponents();
});
beforeEach(() => {
@@ -14,7 +14,6 @@ import { GlimTermsStepComponent } from './glim-account-stepper/glim-terms-step/g
styleUrls: ['./create-glim-account.component.scss']
})
export class CreateGlimAccountComponent {
/** Imports all the step component */
@ViewChild(GlimDetailsStepComponent, { static: true }) loansAccountDetailsStep: GlimDetailsStepComponent;
@ViewChild(GlimTermsStepComponent, { static: true }) loansAccountTermsStep: GlimTermsStepComponent;
@@ -48,24 +47,26 @@ export class CreateGlimAccountComponent {
* @param {LoansService} loansService Loans Service.
* @param {SettingsService} settingsService SettingsService
*/
constructor(private route: ActivatedRoute,
constructor(
private route: ActivatedRoute,
private router: Router,
private loansService: LoansService,
private settingsService: SettingsService,
public dialog: MatDialog,
private dateUtils: Dates) {
this.route.data.subscribe((data: {loansAccountTemplate: any, gsimData: any, groupsData: any}) => {
private dateUtils: Dates
) {
this.route.data.subscribe((data: { loansAccountTemplate: any; gsimData: any; groupsData: any }) => {
this.loansAccountTemplate = data.loansAccountTemplate;
this.activeClientMembers = data.groupsData.activeClientMembers;
this.gsimData = data.gsimData;
});
}
}
/**
* Sets loans account product template and collateral template
* @param {any} $event API response
*/
setTemplate($event: any) {
setTemplate($event: any) {
this.loansAccountProductTemplate = $event;
}
@@ -81,10 +82,7 @@ export class CreateGlimAccountComponent {
/** Checks wheter all the forms in different steps are valid or not */
get loansAccountFormValid() {
return (
this.loansAccountDetailsForm.valid &&
this.loansAccountTermsForm.valid
);
return this.loansAccountDetailsForm.valid && this.loansAccountTermsForm.valid;
}
/** Gets principal Amount */
@@ -98,7 +96,7 @@ export class CreateGlimAccountComponent {
return {
...this.loansAccountDetailsStep.loansAccountDetails,
...this.loansAccountTermsStep.loansAccountTerms,
...this.loansAccountChargesStep.loansAccountCharges,
...this.loansAccountChargesStep.loansAccountCharges
};
}
@@ -110,12 +108,12 @@ export class CreateGlimAccountComponent {
...this.loansAccount,
charges: this.loansAccount.charges.map((charge: any) => ({
chargeId: charge.id,
amount: charge.amount,
amount: charge.amount
})),
clientId: client.id,
totalLoan: this.totalLoan,
loanType: 'glim',
amortizationType: 1,
amortizationType: 1,
isParentAccount: true,
principal: client.principal,
syncDisbursementWithMeeting: false,
@@ -138,11 +136,10 @@ export class CreateGlimAccountComponent {
for (let index = 0; index < memberSelected.length; index++) {
requestData.push({
requestId: index.toString(),
method : 'POST',
method: 'POST',
relativeUrl: 'loans',
body : this.setData( memberSelected[ index ] )
}
);
body: this.setData(memberSelected[index])
});
}
return requestData;
}
@@ -165,5 +162,4 @@ export class CreateGlimAccountComponent {
this.router.navigate(['../../../'], { relativeTo: this.route });
});
}
}
@@ -8,9 +8,8 @@ describe('GlimChargesStepComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ GlimChargesStepComponent ]
})
.compileComponents();
declarations: [GlimChargesStepComponent]
}).compileComponents();
});
beforeEach(() => {
@@ -14,7 +14,6 @@ import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
styleUrls: ['./glim-charges-step.component.scss']
})
export class GlimChargesStepComponent implements OnInit, OnChanges {
/** Savings Account Product Template */
@Input() loansAccountProductTemplate: any;
/** Savings Account Template */
@@ -33,7 +32,15 @@ export class GlimChargesStepComponent implements OnInit, OnChanges {
/** For Edit Savings Account Form */
isChargesPatched = false;
/** Display columns for charges table */
displayedColumns: string[] = ['name', 'chargeCalculationType', 'amount', 'chargeTimeType', 'date', 'repaymentsEvery', 'action'];
displayedColumns: string[] = [
'name',
'chargeCalculationType',
'amount',
'chargeTimeType',
'date',
'repaymentsEvery',
'action'
];
/** Table Data Source */
dataSource: any;
/** Check for select all the Clients List */
@@ -41,23 +48,31 @@ export class GlimChargesStepComponent implements OnInit, OnChanges {
/** Loan Purpose Options */
loanPurposeOptions: string[] = [];
/** Table Displayed Columns */
displayedColumn: string[] = ['check', 'id', 'name', 'purpose', 'amount'];
displayedColumn: string[] = [
'check',
'id',
'name',
'purpose',
'amount'
];
/**
* @param {MatDialog} dialog Mat Dialog
*/
constructor(public dialog: MatDialog,
private dateUtils: Dates) {}
constructor(
public dialog: MatDialog,
private dateUtils: Dates
) {}
ngOnInit() {
ngOnInit() {
this.dataSource = new MatTableDataSource<any>(this.activeClientMembers);
}
}
ngOnChanges() {
ngOnChanges() {
if (this.loansAccountProductTemplate) {
this.chargeData = this.loansAccountProductTemplate.chargeOptions;
}
}
}
/**
* Adds the charge to charges table
@@ -81,7 +96,8 @@ export class GlimChargesStepComponent implements OnInit, OnChanges {
value: charge.amount,
type: 'number',
required: false
}),
})
];
const data = {
title: 'Edit Charge Amount',
@@ -111,7 +127,8 @@ export class GlimChargesStepComponent implements OnInit, OnChanges {
value: charge.dueDate || charge.feeOnMonthDay || '',
type: 'datetime-local',
required: false
}),
})
];
const data = {
title: 'Edit Charge Date',
@@ -127,11 +144,11 @@ export class GlimChargesStepComponent implements OnInit, OnChanges {
switch (charge.chargeTimeType.value) {
case 'Specified due date':
case 'Weekly Fee':
newCharge = { ...charge, dueDate: date };
break;
newCharge = { ...charge, dueDate: date };
break;
case 'Annual Fee':
newCharge = { ...charge, feeOnMonthDay: date };
break;
newCharge = { ...charge, feeOnMonthDay: date };
break;
}
this.chargesDataSource.splice(this.chargesDataSource.indexOf(charge), 1, newCharge);
this.chargesDataSource = this.chargesDataSource.concat([]);
@@ -152,7 +169,8 @@ export class GlimChargesStepComponent implements OnInit, OnChanges {
value: charge.feeInterval,
type: 'text',
required: false
}),
})
];
const data = {
title: 'Edit Charge Fee Interval',
@@ -188,7 +206,7 @@ export class GlimChargesStepComponent implements OnInit, OnChanges {
}
get selectedClientMembers() {
return { selectedMembers: this.activeClientMembers.filter( (item: any) => item.selected ) };
return { selectedMembers: this.activeClientMembers.filter((item: any) => item.selected) };
}
/** Toggle all checks */
@@ -201,7 +219,7 @@ export class GlimChargesStepComponent implements OnInit, OnChanges {
/** Check if all the checks are selected */
toggleSelect() {
const len = this.activeClientMembers.length;
this.selectAllItems = len === 0 ? false : this.activeClientMembers.filter( (item: any) => item.selected ).length === len;
this.selectAllItems =
len === 0 ? false : this.activeClientMembers.filter((item: any) => item.selected).length === len;
}
}
@@ -8,9 +8,8 @@ describe('GlimDetailsStepComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ GlimDetailsStepComponent ]
})
.compileComponents();
declarations: [GlimDetailsStepComponent]
}).compileComponents();
});
beforeEach(() => {
@@ -39,9 +39,11 @@ export class GlimDetailsStepComponent implements OnInit {
* @param {LoansService} loansService Loans Service.
* @param {SettingsService} settingsService SettingsService
*/
constructor(private formBuilder: UntypedFormBuilder,
constructor(
private formBuilder: UntypedFormBuilder,
private loansService: LoansService,
private settingsService: SettingsService) {
private settingsService: SettingsService
) {
this.createLoansAccountDetailsForm();
}
@@ -52,13 +54,17 @@ export class GlimDetailsStepComponent implements OnInit {
this.productData = this.loansAccountTemplate.productOptions;
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
});
}
}
@@ -67,21 +73,30 @@ export class GlimDetailsStepComponent implements OnInit {
/**
* Creates glim account details form.
*/
createLoansAccountDetailsForm() {
createLoansAccountDetailsForm() {
this.loansAccountDetailsForm = this.formBuilder.group({
'productId': ['', Validators.required],
'loanOfficerId': [''],
'fundId': [''],
'submittedOnDate': [new Date(), Validators.required],
'expectedDisbursementDate': ['', Validators.required],
'linkAccountId': [''],
productId: [
'',
Validators.required
],
loanOfficerId: [''],
fundId: [''],
submittedOnDate: [
new Date(),
Validators.required
],
expectedDisbursementDate: [
'',
Validators.required
],
linkAccountId: ['']
});
}
/**
* Fetches loans account product template on productId value changes
*/
buildDependencies() {
buildDependencies() {
const groupId = this.loansAccountTemplate.group.id;
this.loansAccountDetailsForm.get('productId').valueChanges.subscribe((productId: string) => {
this.loansService.getLoansAccountTemplateResource(groupId, true, productId).subscribe((response: any) => {
@@ -100,5 +115,4 @@ export class GlimDetailsStepComponent implements OnInit {
get loansAccountDetails() {
return this.loansAccountDetailsForm.value;
}
}
@@ -8,9 +8,8 @@ describe('GlimPreviewStepComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ GlimPreviewStepComponent ]
})
.compileComponents();
declarations: [GlimPreviewStepComponent]
}).compileComponents();
});
beforeEach(() => {
@@ -6,8 +6,6 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
styleUrls: ['./glim-preview-step.component.scss']
})
export class GlimPreviewStepComponent {
/** Loans Account Template */
@Input() loansAccountTemplate: any;
/** Loans Account Product Template */
@@ -18,10 +16,20 @@ export class GlimPreviewStepComponent {
@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'];
constructor() { }
overdueChargesDisplayedColumns: string[] = [
'name',
'type',
'amount',
'collectedon'
];
constructor() {}
}
@@ -8,9 +8,8 @@ describe('GlimTermsStepComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ GlimTermsStepComponent ]
})
.compileComponents();
declarations: [GlimTermsStepComponent]
}).compileComponents();
});
beforeEach(() => {
@@ -8,7 +8,6 @@ import { SettingsService } from 'app/settings/settings.service';
styleUrls: ['./glim-terms-step.component.scss']
})
export class GlimTermsStepComponent implements OnInit, OnChanges {
/** Loans Account Product Template */
@Input() loansAccountProductTemplate: any;
/** Loans Account Template */
@@ -42,8 +41,10 @@ export class GlimTermsStepComponent implements OnInit, OnChanges {
* @param formBuilder FormBuilder
* @param {SettingsService} settingsService SettingsService
*/
constructor(private formBuilder: UntypedFormBuilder,
private settingsService: SettingsService) {
constructor(
private formBuilder: UntypedFormBuilder,
private settingsService: SettingsService
) {
this.createloansAccountTermsForm();
}
/**
@@ -52,16 +53,16 @@ export class GlimTermsStepComponent implements OnInit, OnChanges {
ngOnChanges() {
if (this.loansAccountProductTemplate) {
this.loansAccountTermsForm.patchValue({
'principal': this.loansAccountProductTemplate.principal,
'loanTermFrequency': this.loansAccountProductTemplate.termFrequency,
'loanTermFrequencyType': this.loansAccountProductTemplate.termPeriodFrequencyType.id,
'numberOfRepayments': this.loansAccountProductTemplate.numberOfRepayments,
'repaymentEvery': this.loansAccountProductTemplate.repaymentEvery,
'repaymentFrequencyType': this.loansAccountProductTemplate.repaymentFrequencyType.id,
'interestRatePerPeriod': this.loansAccountProductTemplate.interestRatePerPeriod,
'interestType': this.loansAccountProductTemplate.interestType.id,
'interestCalculationPeriodType': this.loansAccountProductTemplate.interestCalculationPeriodType.id,
'transactionProcessingStrategyCode': this.loansAccountProductTemplate.transactionProcessingStrategyCode,
principal: this.loansAccountProductTemplate.principal,
loanTermFrequency: this.loansAccountProductTemplate.termFrequency,
loanTermFrequencyType: this.loansAccountProductTemplate.termPeriodFrequencyType.id,
numberOfRepayments: this.loansAccountProductTemplate.numberOfRepayments,
repaymentEvery: this.loansAccountProductTemplate.repaymentEvery,
repaymentFrequencyType: this.loansAccountProductTemplate.repaymentFrequencyType.id,
interestRatePerPeriod: this.loansAccountProductTemplate.interestRatePerPeriod,
interestType: this.loansAccountProductTemplate.interestType.id,
interestCalculationPeriodType: this.loansAccountProductTemplate.interestCalculationPeriodType.id,
transactionProcessingStrategyCode: this.loansAccountProductTemplate.transactionProcessingStrategyCode
});
this.setOptions();
}
@@ -72,7 +73,9 @@ export class GlimTermsStepComponent implements OnInit, OnChanges {
if (this.loansAccountTemplate) {
if (this.loansAccountTemplate.loanProductId) {
this.loansAccountTermsForm.patchValue({
'repaymentsStartingFromDate': this.loansAccountTemplate.expectedFirstRepaymentOnDate && new Date(this.loansAccountTemplate.expectedFirstRepaymentOnDate)
repaymentsStartingFromDate:
this.loansAccountTemplate.expectedFirstRepaymentOnDate &&
new Date(this.loansAccountTemplate.expectedFirstRepaymentOnDate)
});
}
}
@@ -85,39 +88,55 @@ export class GlimTermsStepComponent 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();
});
}
/** Create Loans Account Terms Form */
createloansAccountTermsForm() {
this.loansAccountTermsForm = this.formBuilder.group({
'principal': ['', Validators.required],
'loanTermFrequency': ['', Validators.required],
'loanTermFrequencyType': ['', Validators.required],
'numberOfRepayments': ['', Validators.required],
'repaymentEvery': ['', Validators.required],
'repaymentFrequencyType': ['', Validators.required],
'repaymentFrequencyNthDayType': [''],
'repaymentFrequencyDayOfWeekType': [''],
'repaymentsStartingFromDate': [''],
'interestChargedFromDate': [''],
'interestRatePerPeriod': [''],
'interestType': [''],
'interestCalculationPeriodType': [''],
'transactionProcessingStrategyCode': ['']
principal: [
'',
Validators.required
],
loanTermFrequency: [
'',
Validators.required
],
loanTermFrequencyType: [
'',
Validators.required
],
numberOfRepayments: [
'',
Validators.required
],
repaymentEvery: [
'',
Validators.required
],
repaymentFrequencyType: [
'',
Validators.required
],
repaymentFrequencyNthDayType: [''],
repaymentFrequencyDayOfWeekType: [''],
repaymentsStartingFromDate: [''],
interestChargedFromDate: [''],
interestRatePerPeriod: [''],
interestType: [''],
interestCalculationPeriodType: [''],
transactionProcessingStrategyCode: ['']
});
}
@@ -127,7 +146,8 @@ export class GlimTermsStepComponent 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;
@@ -141,5 +161,4 @@ export class GlimTermsStepComponent implements OnInit, OnChanges {
get loansAccountTerms() {
return this.loansAccountTermsForm.value;
}
}
@@ -13,11 +13,10 @@ import { LoansService } from '../loans.service';
*/
@Injectable()
export class GLIMViewResolver implements Resolve<Object> {
/**
* @param {LoansService} loansService Loans service.
*/
constructor(private loansService: LoansService) { }
constructor(private loansService: LoansService) {}
/**
* Returns the Savings Account data.
@@ -29,5 +28,4 @@ export class GLIMViewResolver implements Resolve<Object> {
const glimId = route.paramMap.get('glimId');
return this.loansService.getGLIMAccountData(glimId, groupId);
}
}
@@ -8,9 +8,8 @@ describe('GlimAccountComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ GlimAccountComponent ]
})
.compileComponents();
declarations: [GlimAccountComponent]
}).compileComponents();
});
beforeEach(() => {
@@ -13,9 +13,15 @@ import { ActivatedRoute } from '@angular/router';
styleUrls: ['./glim-account.component.scss']
})
export class GlimAccountComponent implements OnInit {
/** Columns to be displayed in GLIM overview table. */
displayedColumns: string[] = ['loanId', 'clientId', 'clientName', 'loanAccountNumber', 'clientPrincipalLoan', 'groupPrincipalLoan'];
displayedColumns: string[] = [
'loanId',
'clientId',
'clientName',
'loanAccountNumber',
'clientPrincipalLoan',
'groupPrincipalLoan'
];
/** Data source for charge overview table. */
dataSource: MatTableDataSource<any>;
/** Charge Overview data */
@@ -29,9 +35,11 @@ export class GlimAccountComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
* @param {MatDialog} dialog Dialog reference.
*/
constructor(private route: ActivatedRoute,
public dialog: MatDialog) {
this.route.data.subscribe((data: { glimData: any }) => {
constructor(
private route: ActivatedRoute,
public dialog: MatDialog
) {
this.route.data.subscribe((data: { glimData: any }) => {
this.glimOverviewData = data.glimData;
});
}
@@ -43,7 +51,7 @@ export class GlimAccountComponent implements OnInit {
/**
* Set GLIM Overview.
*/
setLoanClientChargeOverview() {
setLoanClientChargeOverview() {
this.dataSource = new MatTableDataSource(this.glimOverviewData);
}
}