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('ChartOfAccountsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ChartOfAccountsComponent ]
})
.compileComponents();
declarations: [ChartOfAccountsComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -29,13 +29,19 @@ import { TreeControlService } from 'app/shared/common-logic/tree-control.service
styleUrls: ['./chart-of-accounts.component.scss']
})
export class ChartOfAccountsComponent implements AfterViewInit, OnInit {
/** Button toggle group form control for type of view. (list/tree) */
viewGroup = new UntypedFormControl('listView');
/** GL Account data. */
glAccountData: any;
/** Columns to be displayed in chart of accounts table. */
displayedColumns: string[] = ['name', 'glCode', 'glAccountType', 'disabled', 'manualEntriesAllowed', 'usedAs'];
displayedColumns: string[] = [
'name',
'glCode',
'glAccountType',
'disabled',
'manualEntriesAllowed',
'usedAs'
];
/** Data source for chart of accounts table. */
tableDataSource: MatTableDataSource<any>;
/** Nested tree control for chart of accounts tree. */
@@ -69,12 +75,14 @@ export class ChartOfAccountsComponent implements AfterViewInit, OnInit {
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService.
*/
constructor(private glAccountTreeService: GlAccountTreeService,
private route: ActivatedRoute,
private router: Router,
private treeControlService: TreeControlService,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) {
constructor(
private glAccountTreeService: GlAccountTreeService,
private route: ActivatedRoute,
private router: Router,
private treeControlService: TreeControlService,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService
) {
this.route.data.subscribe((data: { chartOfAccounts: any }) => {
this.glAccountData = data.chartOfAccounts;
glAccountTreeService.initialize(this.glAccountData);
@@ -102,9 +110,12 @@ export class ChartOfAccountsComponent implements AfterViewInit, OnInit {
this.tableDataSource.paginator = this.paginator;
this.tableDataSource.sortingDataAccessor = (glAccount: any, property: any) => {
switch (property) {
case 'glAccountType': return glAccount.type.value;
case 'usedAs': return glAccount.usage.value;
default: return glAccount[property];
case 'glAccountType':
return glAccount.type.value;
case 'usedAs':
return glAccount.usage.value;
default:
return glAccount[property];
}
};
this.tableDataSource.sort = this.sort;
@@ -158,7 +169,12 @@ export class ChartOfAccountsComponent implements AfterViewInit, OnInit {
* @param position String.
* @param backdrop Boolean.
*/
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void {
showPopover(
template: TemplateRef<any>,
target: HTMLElement | ElementRef<any>,
position: string,
backdrop: boolean
): void {
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
}
@@ -188,5 +204,4 @@ export class ChartOfAccountsComponent implements AfterViewInit, OnInit {
toggleExpandCollapse() {
this.isTreeExpanded = this.treeControlService.toggleExpandCollapse(this.nestedTreeControl, this.isTreeExpanded);
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class ChartOfAccountsResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class ChartOfAccountsResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.accountingService.getChartOfAccounts();
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../../accounting.service';
*/
@Injectable()
export class ChartOfAccountsTemplateResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class ChartOfAccountsTemplateResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.accountingService.getChartOfAccountsTemplate();
}
}
@@ -8,9 +8,8 @@ describe('CreateGlAccountComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CreateGlAccountComponent ]
})
.compileComponents();
declarations: [CreateGlAccountComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -22,7 +22,6 @@ import { GLAccount } from 'app/shared/models/general.model';
styleUrls: ['./create-gl-account.component.scss']
})
export class CreateGlAccountComponent implements OnInit, AfterViewInit {
/** GL account form. */
glAccountForm: UntypedFormGroup;
/** Chart of accounts data. */
@@ -57,14 +56,16 @@ export class CreateGlAccountComponent implements OnInit, AfterViewInit {
* @param {PopoverService} popoverService PopoverService.
* @param {Matdialog} dialog Matdialog.
*/
constructor(private formBuilder: UntypedFormBuilder,
constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService,
public dialog: MatDialog) {
this.route.queryParamMap.subscribe(params => {
public dialog: MatDialog
) {
this.route.queryParamMap.subscribe((params) => {
this.accountTypeId = Number(params.get('accountType'));
this.parentId = Number(params.get('parent'));
if (this.parentId) {
@@ -92,14 +93,26 @@ export class CreateGlAccountComponent implements OnInit, AfterViewInit {
*/
createGlAccountForm() {
this.glAccountForm = this.formBuilder.group({
'type': ['', Validators.required],
'name': ['', Validators.required],
'usage': ['', Validators.required],
'glCode': ['', Validators.required],
'parentId': [this.parentId || undefined],
'tagId': [''],
'manualEntriesAllowed': [true],
'description': ['']
type: [
'',
Validators.required
],
name: [
'',
Validators.required
],
usage: [
'',
Validators.required
],
glCode: [
'',
Validators.required
],
parentId: [this.parentId || undefined],
tagId: [''],
manualEntriesAllowed: [true],
description: ['']
});
}
@@ -107,21 +120,26 @@ export class CreateGlAccountComponent implements OnInit, AfterViewInit {
* Sets gl account form for selected account type.
*/
setGLAccountForm() {
this.glAccountForm.get('type').valueChanges.subscribe(accountTypeId => {
this.glAccountForm.get('type').valueChanges.subscribe((accountTypeId) => {
switch (accountTypeId) {
case 1: this.parentData = this.chartOfAccountsData.assetHeaderAccountOptions;
case 1:
this.parentData = this.chartOfAccountsData.assetHeaderAccountOptions;
this.tagData = this.chartOfAccountsData.allowedAssetsTagOptions;
break;
case 2: this.parentData = this.chartOfAccountsData.liabilityHeaderAccountOptions;
case 2:
this.parentData = this.chartOfAccountsData.liabilityHeaderAccountOptions;
this.tagData = this.chartOfAccountsData.allowedLiabilitiesTagOptions;
break;
case 3: this.parentData = this.chartOfAccountsData.equityHeaderAccountOptions;
case 3:
this.parentData = this.chartOfAccountsData.equityHeaderAccountOptions;
this.tagData = this.chartOfAccountsData.allowedEquityTagOptions;
break;
case 4: this.parentData = this.chartOfAccountsData.incomeHeaderAccountOptions;
case 4:
this.parentData = this.chartOfAccountsData.incomeHeaderAccountOptions;
this.tagData = this.chartOfAccountsData.allowedIncomeTagOptions;
break;
case 5: this.parentData = this.chartOfAccountsData.expenseHeaderAccountOptions;
case 5:
this.parentData = this.chartOfAccountsData.expenseHeaderAccountOptions;
this.tagData = this.chartOfAccountsData.allowedExpensesTagOptions;
break;
}
@@ -140,7 +158,13 @@ export class CreateGlAccountComponent implements OnInit, AfterViewInit {
this.configurationWizardService.showChartofAccounts = false;
this.openDialog();
} else {
this.router.navigate(['../view', response.resourceId], { relativeTo: this.route });
this.router.navigate(
[
'../view',
response.resourceId
],
{ relativeTo: this.route }
);
}
});
}
@@ -152,7 +176,12 @@ export class CreateGlAccountComponent implements OnInit, AfterViewInit {
* @param position String.
* @param backdrop Boolean.
*/
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void {
showPopover(
template: TemplateRef<any>,
target: HTMLElement | ElementRef<any>,
position: string,
backdrop: boolean
): void {
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
}
@@ -192,7 +221,7 @@ export class CreateGlAccountComponent implements OnInit, AfterViewInit {
const continueSetupDialogRef = this.dialog.open(ContinueSetupDialogComponent, {
data: {
stepName: 'GL account'
},
}
});
continueSetupDialogRef.afterClosed().subscribe((response: { step: number }) => {
if (response.step === 1) {
@@ -8,9 +8,8 @@ describe('EditGlAccountComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditGlAccountComponent ]
})
.compileComponents();
declarations: [EditGlAccountComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -15,7 +15,6 @@ import { AccountingService } from '../../accounting.service';
styleUrls: ['./edit-gl-account.component.scss']
})
export class EditGlAccountComponent implements OnInit {
/** GL account form. */
glAccountForm: UntypedFormGroup;
/** GL account and chart of accounts data. */
@@ -36,10 +35,12 @@ export class EditGlAccountComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
*/
constructor(private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router) {
constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router
) {
this.route.data.subscribe((data: { glAccountAndChartOfAccountsTemplate: any }) => {
this.glAccount = data.glAccountAndChartOfAccountsTemplate;
});
@@ -58,14 +59,29 @@ export class EditGlAccountComponent implements OnInit {
*/
createGlAccountForm() {
this.glAccountForm = this.formBuilder.group({
'type': ['', Validators.required],
'name': [this.glAccount.name, Validators.required],
'usage': [this.glAccount.usage.id, Validators.required],
'glCode': [this.glAccount.glCode, Validators.required],
'parentId': [this.glAccount.parentId],
'tagId': [this.glAccount.tagId.id],
'manualEntriesAllowed': [this.glAccount.manualEntriesAllowed, Validators.required],
'description': [this.glAccount.description]
type: [
'',
Validators.required
],
name: [
this.glAccount.name,
Validators.required
],
usage: [
this.glAccount.usage.id,
Validators.required
],
glCode: [
this.glAccount.glCode,
Validators.required
],
parentId: [this.glAccount.parentId],
tagId: [this.glAccount.tagId.id],
manualEntriesAllowed: [
this.glAccount.manualEntriesAllowed,
Validators.required
],
description: [this.glAccount.description]
});
}
@@ -75,23 +91,28 @@ export class EditGlAccountComponent implements OnInit {
setGLAccountForm() {
this.accountTypeData = this.glAccount.accountTypeOptions;
this.accountUsageData = this.glAccount.usageOptions;
this.glAccountForm.get('type').valueChanges.subscribe(accountTypeId => {
this.glAccountForm.get('type').valueChanges.subscribe((accountTypeId) => {
switch (accountTypeId) {
case 1: this.parentData = this.glAccount.assetHeaderAccountOptions;
this.tagData = this.glAccount.allowedAssetsTagOptions;
break;
case 2: this.parentData = this.glAccount.liabilityHeaderAccountOptions;
this.tagData = this.glAccount.allowedLiabilitiesTagOptions;
break;
case 3: this.parentData = this.glAccount.equityHeaderAccountOptions;
this.tagData = this.glAccount.allowedEquityTagOptions;
break;
case 4: this.parentData = this.glAccount.incomeHeaderAccountOptions;
this.tagData = this.glAccount.allowedIncomeTagOptions;
break;
case 5: this.parentData = this.glAccount.expenseHeaderAccountOptions;
this.tagData = this.glAccount.allowedExpensesTagOptions;
break;
case 1:
this.parentData = this.glAccount.assetHeaderAccountOptions;
this.tagData = this.glAccount.allowedAssetsTagOptions;
break;
case 2:
this.parentData = this.glAccount.liabilityHeaderAccountOptions;
this.tagData = this.glAccount.allowedLiabilitiesTagOptions;
break;
case 3:
this.parentData = this.glAccount.equityHeaderAccountOptions;
this.tagData = this.glAccount.allowedEquityTagOptions;
break;
case 4:
this.parentData = this.glAccount.incomeHeaderAccountOptions;
this.tagData = this.glAccount.allowedIncomeTagOptions;
break;
case 5:
this.parentData = this.glAccount.expenseHeaderAccountOptions;
this.tagData = this.glAccount.allowedExpensesTagOptions;
break;
}
});
@@ -103,10 +124,14 @@ export class EditGlAccountComponent implements OnInit {
* if successful redirects to view updated account.
*/
submit() {
this.accountingService.updateGlAccount(this.glAccount.id, this.glAccountForm.value)
.subscribe((response: any) => {
this.router.navigate(['../../', response.resourceId], { relativeTo: this.route });
});
this.accountingService.updateGlAccount(this.glAccount.id, this.glAccountForm.value).subscribe((response: any) => {
this.router.navigate(
[
'../../',
response.resourceId
],
{ relativeTo: this.route }
);
});
}
}
@@ -14,7 +14,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class GlAccountAndChartOfAccountsTemplateResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -31,16 +30,21 @@ export class GlAccountAndChartOfAccountsTemplateResolver implements Resolve<Obje
map((glAccountData: any) => {
let accountOptions = [];
switch (glAccountData.type.value) {
case 'ASSET': accountOptions = glAccountData.assetHeaderAccountOptions;
break;
case 'EQUITY': accountOptions = glAccountData.equityHeaderAccountOptions;
break;
case 'EXPENSE': accountOptions = glAccountData.expenseHeaderAccountOptions;
break;
case 'INCOME': accountOptions = glAccountData.incomeHeaderAccountOptions;
break;
case 'LIABILITY': accountOptions = glAccountData.liabilityHeaderAccountOptions;
break;
case 'ASSET':
accountOptions = glAccountData.assetHeaderAccountOptions;
break;
case 'EQUITY':
accountOptions = glAccountData.equityHeaderAccountOptions;
break;
case 'EXPENSE':
accountOptions = glAccountData.expenseHeaderAccountOptions;
break;
case 'INCOME':
accountOptions = glAccountData.incomeHeaderAccountOptions;
break;
case 'LIABILITY':
accountOptions = glAccountData.liabilityHeaderAccountOptions;
break;
}
if (glAccountData.parentId) {
glAccountData.parent = accountOptions.find((accountOption: any) => {
@@ -51,5 +55,4 @@ export class GlAccountAndChartOfAccountsTemplateResolver implements Resolve<Obje
})
);
}
}
@@ -2,7 +2,6 @@
* GL Account Node model.
*/
export class GLAccountNode {
/** GL Account Node children. */
children: GLAccountNode[];
@@ -13,12 +12,14 @@ export class GLAccountNode {
manualEntriesAllowed: boolean;
description: string;
constructor(name: string,
glCode: string = '',
type: string = '',
usage: string = '',
manualEntriesAllowed: boolean = false,
description: string = '') {
constructor(
name: string,
glCode: string = '',
type: string = '',
usage: string = '',
manualEntriesAllowed: boolean = false,
description: string = ''
) {
this.name = name;
this.glCode = glCode;
this.type = type;
@@ -27,5 +28,4 @@ export class GLAccountNode {
this.description = description;
this.children = [];
}
}
@@ -16,7 +16,6 @@ import { GLAccount } from 'app/shared/models/general.model';
providedIn: 'root'
})
export class GlAccountTreeService {
/** GL Account data. */
glAccountData: any;
/** Chart of accounts tree data behavior subject to represent chart of accounts tree nodes. */
@@ -25,10 +24,11 @@ export class GlAccountTreeService {
/**
* Gets the chart of accounts tree nodes.
*/
get treeData(): GLAccountNode[] { return this.treeDataChange.value; }
get treeData(): GLAccountNode[] {
return this.treeDataChange.value;
}
constructor(
private translateService: TranslateService) { }
constructor(private translateService: TranslateService) {}
/**
* Builds the chart of accounts tree and emits the value.
@@ -51,9 +51,13 @@ export class GlAccountTreeService {
glAccountTree.push(new GLAccountNode('ACCOUNTS'));
glAccountTree[0].children.push(new GLAccountNode(this.translateService.instant('labels.inputs.accounting.ASSET')));
glAccountTree[0].children.push(new GLAccountNode(this.translateService.instant('labels.inputs.accounting.EQUITY')));
glAccountTree[0].children.push(new GLAccountNode(this.translateService.instant('labels.inputs.accounting.EXPENSE')));
glAccountTree[0].children.push(
new GLAccountNode(this.translateService.instant('labels.inputs.accounting.EXPENSE'))
);
glAccountTree[0].children.push(new GLAccountNode(this.translateService.instant('labels.inputs.accounting.INCOME')));
glAccountTree[0].children.push(new GLAccountNode(this.translateService.instant('labels.inputs.accounting.LIABILITY')));
glAccountTree[0].children.push(
new GLAccountNode(this.translateService.instant('labels.inputs.accounting.LIABILITY'))
);
// Sort by parent id (so that child nodes can be added properly)
if (!glAccountData[0].parentId) {
@@ -70,8 +74,14 @@ export class GlAccountTreeService {
// Add gl accounts to any array where index for each is denoted by its id
for (const glAccount of glAccountData) {
glAccounts[glAccount.id] =
new GLAccountNode(glAccount.name, glAccount.glCode, glAccount.type.value, glAccount.usage.value, glAccount.manualEntriesAllowed, glAccount.description);
glAccounts[glAccount.id] = new GLAccountNode(
glAccount.name,
glAccount.glCode,
glAccount.type.value,
glAccount.usage.value,
glAccount.manualEntriesAllowed,
glAccount.description
);
}
// Construct gl account tree by adding all nodes belonging to headers (with parent id = 0) by their type,
@@ -99,5 +109,4 @@ export class GlAccountTreeService {
return glAccountTree;
}
}
@@ -8,9 +8,8 @@ describe('ViewGlAccountComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewGlAccountComponent ]
})
.compileComponents();
declarations: [ViewGlAccountComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -19,7 +19,6 @@ import { Location } from '@angular/common';
styleUrls: ['./view-gl-account.component.scss']
})
export class ViewGlAccountComponent {
/** GL Account. */
glAccount: any;
@@ -30,11 +29,13 @@ export class ViewGlAccountComponent {
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference.
*/
constructor(private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog,
private location: Location) {
constructor(
private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog,
private location: Location
) {
this.route.data.subscribe((data: { glAccountAndChartOfAccountsTemplate: any }) => {
this.glAccount = data.glAccountAndChartOfAccountsTemplate;
});
@@ -49,10 +50,9 @@ export class ViewGlAccountComponent {
});
deleteGlAccountDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.accountingService.deleteGlAccount(this.glAccount.id)
.subscribe(() => {
this.router.navigate(['/accounting/chart-of-accounts']);
});
this.accountingService.deleteGlAccount(this.glAccount.id).subscribe(() => {
this.router.navigate(['/accounting/chart-of-accounts']);
});
}
});
}
@@ -61,7 +61,8 @@ export class ViewGlAccountComponent {
* Changes state of gl account. (enabled/disabled)
*/
changeGlAccountState() {
this.accountingService.updateGlAccount(this.glAccount.id, { disabled: !this.glAccount.disabled })
this.accountingService
.updateGlAccount(this.glAccount.id, { disabled: !this.glAccount.disabled })
.subscribe((response: any) => {
this.glAccount.disabled = response.changes.disabled;
});
@@ -70,5 +71,4 @@ export class ViewGlAccountComponent {
goBack(): void {
this.location.back();
}
}