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
@@ -84,7 +84,7 @@ const routes: Routes = [
resolve: {
offices: OfficesResolver,
glAccounts: GlAccountsResolver
},
}
},
{
path: 'frequent-postings',
@@ -121,7 +121,7 @@ const routes: Routes = [
}
}
]
},
}
]
},
{
@@ -199,7 +199,10 @@ const routes: Routes = [
},
{
path: 'view/:id',
data: { title: 'View GL Account', routeResolveBreadcrumb: ['glAccountAndChartOfAccountsTemplate', 'name'] },
data: { title: 'View GL Account', routeResolveBreadcrumb: [
'glAccountAndChartOfAccountsTemplate',
'name'
] },
resolve: {
glAccountAndChartOfAccountsTemplate: GlAccountAndChartOfAccountsTemplateResolver
},
@@ -282,7 +285,10 @@ const routes: Routes = [
},
{
path: 'view/:id',
data: { title: 'View Accounting Rule', routeResolveBreadcrumb: ['accountingRule', 'name'] },
data: { title: 'View Accounting Rule', routeResolveBreadcrumb: [
'accountingRule',
'name'
] },
resolve: {
accountingRule: AccountingRuleResolver
},
@@ -357,7 +363,7 @@ const routes: Routes = [
},
{
path: 'journal-entry',
data: {title: 'Journal Entries', breadcrumb: 'Journal Entries' },
data: { title: 'Journal Entries', breadcrumb: 'Journal Entries' },
children: [
{
path: 'view/:id',
@@ -378,6 +384,7 @@ const routes: Routes = [
]
}
])
];
/**
@@ -415,4 +422,4 @@ const routes: Routes = [
ProvisioningJournalEntriesResolver
]
})
export class AccountingRoutingModule { }
export class AccountingRoutingModule {}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class AccountingRuleResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -27,5 +26,4 @@ export class AccountingRuleResolver implements Resolve<Object> {
const id = route.paramMap.get('id');
return this.accountingService.getAccountingRule(id);
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class AccountingRulesTemplateResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class AccountingRulesTemplateResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.accountingService.getAccountingRulesTemplate();
}
}
@@ -8,9 +8,8 @@ describe('AccountingRulesComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AccountingRulesComponent ]
})
.compileComponents();
declarations: [AccountingRulesComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -14,11 +14,17 @@ import { ActivatedRoute } from '@angular/router';
styleUrls: ['./accounting-rules.component.scss']
})
export class AccountingRulesComponent implements OnInit {
/** Accounting rule data. */
accountingRuleData: any;
/** Columns to be displayed in accounting rules table. */
displayedColumns: string[] = ['name', 'officeName', 'debitTags', 'debitAccount', 'creditTags', 'creditAccount'];
displayedColumns: string[] = [
'name',
'officeName',
'debitTags',
'debitAccount',
'creditTags',
'creditAccount'
];
/** Data source for accounting rules table. */
dataSource: MatTableDataSource<any>;
@@ -49,16 +55,23 @@ export class AccountingRulesComponent implements OnInit {
*/
setAccountingRules() {
this.accountingRuleData.forEach((accountingRule: any) => {
accountingRule.debitTags = accountingRule.debitTags ? accountingRule.debitTags.map((debitTag: any) => debitTag.tag.name).join(', ') : '';
accountingRule.creditTags = accountingRule.creditTags ? accountingRule.creditTags.map((creditTag: any) => creditTag.tag.name).join(', ') : '';
accountingRule.debitTags = accountingRule.debitTags
? accountingRule.debitTags.map((debitTag: any) => debitTag.tag.name).join(', ')
: '';
accountingRule.creditTags = accountingRule.creditTags
? accountingRule.creditTags.map((creditTag: any) => creditTag.tag.name).join(', ')
: '';
});
this.dataSource = new MatTableDataSource(this.accountingRuleData);
this.dataSource.paginator = this.paginator;
this.dataSource.sortingDataAccessor = (accountingRule: any, property: any) => {
switch (property) {
case 'debitAccount': return accountingRule.debitAccounts[0].name;
case 'creditAccount': return accountingRule.creditAccounts[0].name;
default: return accountingRule[property];
case 'debitAccount':
return accountingRule.debitAccounts[0].name;
case 'creditAccount':
return accountingRule.creditAccounts[0].name;
default:
return accountingRule[property];
}
};
this.dataSource.sort = this.sort;
@@ -71,5 +84,4 @@ export class AccountingRulesComponent implements OnInit {
applyFilter(filterValue: string) {
this.dataSource.filter = filterValue.trim().toLowerCase();
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class AccountingRulesResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class AccountingRulesResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.accountingService.getAccountingRules();
}
}
@@ -8,9 +8,8 @@ describe('CreateRuleComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CreateRuleComponent ]
})
.compileComponents();
declarations: [CreateRuleComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -18,7 +18,6 @@ import { oneOfTheFieldsIsRequiredValidator } from '../one-of-the-fields-is-requi
styleUrls: ['./create-rule.component.scss']
})
export class CreateRuleComponent implements OnInit {
/** Accounting rule form. */
accountingRuleForm: UntypedFormGroup;
/** Office data. */
@@ -37,10 +36,12 @@ export class CreateRuleComponent 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: { accountingRulesTemplate: any }) => {
this.officeData = data.accountingRulesTemplate.allowedOffices;
this.glAccountData = data.accountingRulesTemplate.allowedAccounts;
@@ -61,19 +62,28 @@ export class CreateRuleComponent implements OnInit {
* Creates accounting rule form.
*/
createAccountingRuleForm() {
this.accountingRuleForm = this.formBuilder.group({
'name': ['', Validators.required],
'officeId': ['', Validators.required],
'debitRuleType': ['fixedAccount'],
'accountToDebit': [''],
'debitTags': [''],
'allowMultipleDebitEntries': [''],
'creditRuleType': ['fixedAccount'],
'accountToCredit': [''],
'creditTags': [''],
'allowMultipleCreditEntries': [''],
'description': ['']
}, { validator: oneOfTheFieldsIsRequiredValidator });
this.accountingRuleForm = this.formBuilder.group(
{
name: [
'',
Validators.required
],
officeId: [
'',
Validators.required
],
debitRuleType: ['fixedAccount'],
accountToDebit: [''],
debitTags: [''],
allowMultipleDebitEntries: [''],
creditRuleType: ['fixedAccount'],
accountToCredit: [''],
creditTags: [''],
allowMultipleCreditEntries: [''],
description: ['']
},
{ validator: oneOfTheFieldsIsRequiredValidator }
);
}
/**
@@ -121,8 +131,13 @@ export class CreateRuleComponent implements OnInit {
delete accountingRule.debitRuleType;
delete accountingRule.creditRuleType;
this.accountingService.createAccountingRule(accountingRule).subscribe((response: any) => {
this.router.navigate(['../view', response.resourceId], { relativeTo: this.route });
this.router.navigate(
[
'../view',
response.resourceId
],
{ relativeTo: this.route }
);
});
}
}
@@ -8,9 +8,8 @@ describe('EditRuleComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditRuleComponent ]
})
.compileComponents();
declarations: [EditRuleComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -18,7 +18,6 @@ import { oneOfTheFieldsIsRequiredValidator } from '../one-of-the-fields-is-requi
styleUrls: ['./edit-rule.component.scss']
})
export class EditRuleComponent implements OnInit {
/** Accounting rule form. */
accountingRuleForm: UntypedFormGroup;
/** Accounting rule. */
@@ -39,20 +38,19 @@ export class EditRuleComponent 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) {
this.route.data.subscribe((data: {
accountingRulesTemplate: any,
accountingRule: any
}) => {
this.officeData = data.accountingRulesTemplate.allowedOffices;
this.glAccountData = data.accountingRulesTemplate.allowedAccounts;
this.debitTagData = data.accountingRulesTemplate.allowedDebitTagOptions;
this.creditTagData = data.accountingRulesTemplate.allowedCreditTagOptions;
this.accountingRule = data.accountingRule;
});
constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router
) {
this.route.data.subscribe((data: { accountingRulesTemplate: any; accountingRule: any }) => {
this.officeData = data.accountingRulesTemplate.allowedOffices;
this.glAccountData = data.accountingRulesTemplate.allowedAccounts;
this.debitTagData = data.accountingRulesTemplate.allowedDebitTagOptions;
this.creditTagData = data.accountingRulesTemplate.allowedCreditTagOptions;
this.accountingRule = data.accountingRule;
});
}
/**
@@ -67,26 +65,35 @@ export class EditRuleComponent implements OnInit {
* Creates accounting rule form.
*/
createAccountingRuleForm() {
this.accountingRuleForm = this.formBuilder.group({
'name': [this.accountingRule.name, Validators.required],
'officeId': [this.accountingRule.officeId, Validators.required],
'debitRuleType': [''],
'accountToDebit': [''],
'debitTags': [''],
'allowMultipleDebitEntries': [''],
'creditRuleType': [''],
'accountToCredit': [''],
'creditTags': [''],
'allowMultipleCreditEntries': [''],
'description': [this.accountingRule.description]
}, { validator: oneOfTheFieldsIsRequiredValidator });
this.accountingRuleForm = this.formBuilder.group(
{
name: [
this.accountingRule.name,
Validators.required
],
officeId: [
this.accountingRule.officeId,
Validators.required
],
debitRuleType: [''],
accountToDebit: [''],
debitTags: [''],
allowMultipleDebitEntries: [''],
creditRuleType: [''],
accountToCredit: [''],
creditTags: [''],
allowMultipleCreditEntries: [''],
description: [this.accountingRule.description]
},
{ validator: oneOfTheFieldsIsRequiredValidator }
);
}
/**
* Sets accounting rule form for selected accounting rule type.
*/
setAccountingRulesForm() {
this.accountingRuleForm.get('debitRuleType').valueChanges.subscribe(debitRuleType => {
this.accountingRuleForm.get('debitRuleType').valueChanges.subscribe((debitRuleType) => {
if (debitRuleType === 'fixedAccount') {
this.accountingRuleForm.get('debitTags').reset();
this.accountingRuleForm.get('allowMultipleDebitEntries').reset();
@@ -95,7 +102,7 @@ export class EditRuleComponent implements OnInit {
this.accountingRuleForm.get('allowMultipleDebitEntries').setValue(false);
}
});
this.accountingRuleForm.get('creditRuleType').valueChanges.subscribe(creditRuleType => {
this.accountingRuleForm.get('creditRuleType').valueChanges.subscribe((creditRuleType) => {
if (creditRuleType === 'fixedAccount') {
this.accountingRuleForm.get('creditTags').reset();
this.accountingRuleForm.get('allowMultipleCreditEntries').reset();
@@ -110,7 +117,9 @@ export class EditRuleComponent implements OnInit {
this.accountingRuleForm.get('accountToDebit').setValue(this.accountingRule.debitAccounts[0].id);
} else {
this.accountingRuleForm.get('debitRuleType').setValue('listOfAccounts');
this.accountingRuleForm.get('debitTags').setValue(this.accountingRule.debitTags.map((debitTag: any) => debitTag.tag.id));
this.accountingRuleForm
.get('debitTags')
.setValue(this.accountingRule.debitTags.map((debitTag: any) => debitTag.tag.id));
this.accountingRuleForm.get('allowMultipleDebitEntries').setValue(this.accountingRule.allowMultipleDebitEntries);
}
@@ -119,8 +128,12 @@ export class EditRuleComponent implements OnInit {
this.accountingRuleForm.get('accountToCredit').setValue(this.accountingRule.creditAccounts[0].id);
} else {
this.accountingRuleForm.get('creditRuleType').setValue('listOfAccounts');
this.accountingRuleForm.get('creditTags').setValue(this.accountingRule.creditTags.map((creditTag: any) => creditTag.tag.id));
this.accountingRuleForm.get('allowMultipleCreditEntries').setValue(this.accountingRule.allowMultipleCreditEntries);
this.accountingRuleForm
.get('creditTags')
.setValue(this.accountingRule.creditTags.map((creditTag: any) => creditTag.tag.id));
this.accountingRuleForm
.get('allowMultipleCreditEntries')
.setValue(this.accountingRule.allowMultipleCreditEntries);
}
}
@@ -145,8 +158,13 @@ export class EditRuleComponent implements OnInit {
delete accountingRule.debitRuleType;
delete accountingRule.creditRuleType;
this.accountingService.updateAccountingRule(this.accountingRule.id, accountingRule).subscribe((response: any) => {
this.router.navigate(['../../', response.resourceId], { relativeTo: this.route });
this.router.navigate(
[
'../../',
response.resourceId
],
{ relativeTo: this.route }
);
});
}
}
@@ -2,10 +2,12 @@
import { UntypedFormGroup, ValidatorFn, ValidationErrors } from '@angular/forms';
/** Validates that one of the fields for debit or credit is filled for a given accounting rule type. */
export const oneOfTheFieldsIsRequiredValidator: ValidatorFn = (accountingRuleForm: UntypedFormGroup): ValidationErrors | null => {
export const oneOfTheFieldsIsRequiredValidator: ValidatorFn = (
accountingRuleForm: UntypedFormGroup
): ValidationErrors | null => {
const accountToDebit = accountingRuleForm.controls.accountToDebit.value;
const debitTags = accountingRuleForm.controls.debitTags.value;
const accountToCredit = accountingRuleForm.controls.accountToCredit.value;
const creditTags = accountingRuleForm.controls.creditTags.value;
return ((accountToDebit || debitTags) && (accountToCredit || creditTags)) ? null : { 'error': true };
return (accountToDebit || debitTags) && (accountToCredit || creditTags) ? null : { error: true };
};
@@ -8,9 +8,8 @@ describe('ViewRuleComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewRuleComponent ]
})
.compileComponents();
declarations: [ViewRuleComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -18,7 +18,6 @@ import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dial
styleUrls: ['./view-rule.component.scss']
})
export class ViewRuleComponent {
/** Accounting rule. */
accountingRule: any;
@@ -29,10 +28,12 @@ export class ViewRuleComponent {
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference.
*/
constructor(private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router,
public dialog: MatDialog) {
constructor(
private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router,
public dialog: MatDialog
) {
this.route.data.subscribe((data: { accountingRule: any }) => {
this.accountingRule = data.accountingRule;
});
@@ -47,12 +48,10 @@ export class ViewRuleComponent {
});
deleteAccountingRuleDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.accountingService.deleteAccountingRule(this.accountingRule.id)
.subscribe(() => {
this.router.navigate(['/accounting/accounting-rules']);
});
this.accountingService.deleteAccountingRule(this.accountingRule.id).subscribe(() => {
this.router.navigate(['/accounting/accounting-rules']);
});
}
});
}
}
+17 -7
View File
@@ -15,7 +15,6 @@ import { PopoverService } from '../configuration-wizard/popover/popover.service'
styleUrls: ['./accounting.component.scss']
})
export class AccountingComponent implements AfterViewInit {
/* Reference of Chart of Accounts */
@ViewChild('chartofAccounts') chartofAccounts: ElementRef<any>;
/* Template for popover on Chart of Accounts */
@@ -44,9 +43,11 @@ export class AccountingComponent implements AfterViewInit {
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService.
*/
constructor(private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) { }
constructor(
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService
) {}
/**
* Popover function
@@ -56,7 +57,12 @@ export class AccountingComponent implements AfterViewInit {
* @param backdrop Boolean.
* @param arrowNumber - The index of the boolean value to toggle.
*/
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);
}
@@ -76,7 +82,12 @@ export class AccountingComponent implements AfterViewInit {
}
if (this.configurationWizardService.showMigrateOpeningBalances === true) {
setTimeout(() => {
this.showPopover(this.templateMigrateOpeningBalances, this.migrateOpeningBalances.nativeElement, 'bottom', true);
this.showPopover(
this.templateMigrateOpeningBalances,
this.migrateOpeningBalances.nativeElement,
'bottom',
true
);
});
}
if (this.configurationWizardService.showClosingEntries === true) {
@@ -181,5 +192,4 @@ export class AccountingComponent implements AfterViewInit {
// Toggle the boolean value at the given index
this.arrowBooleans[arrowNumber] = !this.arrowBooleans[arrowNumber];
}
}
+1 -1
View File
@@ -78,4 +78,4 @@ import { PipesModule } from 'app/pipes/pipes.module';
ViewProvisioningJournalEntriesComponent
]
})
export class AccountingModule { }
export class AccountingModule {}
+4 -11
View File
@@ -14,18 +14,17 @@ import { Observable } from 'rxjs';
providedIn: 'root'
})
export class AccountingService {
/**
* @param {HttpClient} http Http Client to send requests.
*/
constructor(private http: HttpClient) { }
constructor(private http: HttpClient) {}
/**
* @returns {Observable<any>} Offices data ordered by id.
*/
getOffices(): Observable<any> {
const httpParams = new HttpParams().set('orderBy', 'id');
return this.http.get('/offices', { params: httpParams });
return this.http.get('/offices', { params: httpParams });
}
/**
@@ -66,10 +65,7 @@ export class AccountingService {
* @returns {Observable<any>} GL Accounts.
*/
getGlAccounts(): Observable<any> {
const httpParams = new HttpParams()
.set('manualEntriesAllowed', 'true')
.set('usage', '1')
.set('disabled', 'false');
const httpParams = new HttpParams().set('manualEntriesAllowed', 'true').set('usage', '1').set('disabled', 'false');
return this.http.get(`/glaccounts`, { params: httpParams });
}
@@ -78,9 +74,7 @@ export class AccountingService {
* @returns {Observable<any>} Journal Entries.
*/
getJournalEntry(transactionId: string): Observable<any> {
const httpParams = new HttpParams()
.set('transactionId', transactionId)
.set('transactionDetails', 'true');
const httpParams = new HttpParams().set('transactionId', transactionId).set('transactionDetails', 'true');
return this.http.get(`/journalentries`, { params: httpParams });
}
@@ -397,5 +391,4 @@ export class AccountingService {
const httpParams = new HttpParams().set('command', 'recreateprovisioningentry');
return this.http.post(`/provisioningentries/${provisioningEntryId}`, {}, { params: httpParams });
}
}
@@ -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();
}
}
@@ -8,9 +8,8 @@ describe('ClosingEntriesComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ClosingEntriesComponent ]
})
.compileComponents();
declarations: [ClosingEntriesComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -22,9 +22,13 @@ import { ConfigurationWizardService } from '../../configuration-wizard/configura
styleUrls: ['./closing-entries.component.scss']
})
export class ClosingEntriesComponent implements OnInit, AfterViewInit {
/** Columns to be displayed in closing entries table. */
displayedColumns: string[] = ['officeName', 'closingDate', 'comments', 'createdByUsername'];
displayedColumns: string[] = [
'officeName',
'closingDate',
'comments',
'createdByUsername'
];
/** Data source for closing entries table. */
dataSource: MatTableDataSource<any>;
/** Office name filter form control. */
@@ -57,14 +61,13 @@ export class ClosingEntriesComponent implements OnInit, AfterViewInit {
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService.
*/
constructor(private route: ActivatedRoute,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) {
this.route.data.subscribe((data: {
offices: any,
glAccountClosures: any
}) => {
constructor(
private route: ActivatedRoute,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService
) {
this.route.data.subscribe((data: { offices: any; glAccountClosures: any }) => {
this.officeData = data.offices;
this.glAccountClosureData = data.glAccountClosures;
});
@@ -101,11 +104,10 @@ export class ClosingEntriesComponent implements OnInit, AfterViewInit {
* Sets filtered offices for autocomplete.
*/
setFilteredOffices() {
this.filteredOfficeData = this.officeName.valueChanges
.pipe(
this.filteredOfficeData = this.officeName.valueChanges.pipe(
startWith(''),
map((office: any) => typeof office === 'string' ? office : office.name),
map((officeName: string) => officeName ? this.filterOfficeAutocompleteData(officeName) : this.officeData)
map((office: any) => (typeof office === 'string' ? office : office.name)),
map((officeName: string) => (officeName ? this.filterOfficeAutocompleteData(officeName) : this.officeData))
);
}
@@ -125,7 +127,12 @@ export class ClosingEntriesComponent 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);
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class ClosingEntriesResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class ClosingEntriesResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.accountingService.getAccountingClosures();
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class ClosingEntryResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -27,5 +26,4 @@ export class ClosingEntryResolver implements Resolve<Object> {
const glAccountClosureId = route.paramMap.get('id');
return this.accountingService.getAccountingClosure(glAccountClosureId);
}
}
@@ -8,9 +8,8 @@ describe('CreateClosureComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CreateClosureComponent ]
})
.compileComponents();
declarations: [CreateClosureComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -16,7 +16,6 @@ import { Dates } from 'app/core/utils/dates';
styleUrls: ['./create-closure.component.scss']
})
export class CreateClosureComponent implements OnInit {
/** Minimum closing date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum closing date allowed. */
@@ -34,12 +33,14 @@ export class CreateClosureComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
*/
constructor(private formBuilder: UntypedFormBuilder,
constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) {
private router: Router
) {
this.route.data.subscribe((data: { offices: any }) => {
this.officeData = data.offices;
});
@@ -58,9 +59,15 @@ export class CreateClosureComponent implements OnInit {
*/
createAccountingClosureForm() {
this.accountingClosureForm = this.formBuilder.group({
'officeId': ['', Validators.required],
'closingDate': ['', Validators.required],
'comments': ['']
officeId: [
'',
Validators.required
],
closingDate: [
'',
Validators.required
],
comments: ['']
});
}
@@ -74,11 +81,19 @@ export class CreateClosureComponent implements OnInit {
accountingClosure.locale = this.settingsService.language.code;
accountingClosure.dateFormat = this.settingsService.dateFormat;
if (accountingClosure.closingDate) {
accountingClosure.closingDate = this.dateUtils.formatDate(accountingClosure.closingDate, this.settingsService.dateFormat);
accountingClosure.closingDate = this.dateUtils.formatDate(
accountingClosure.closingDate,
this.settingsService.dateFormat
);
}
this.accountingService.createAccountingClosure(accountingClosure).subscribe((response: any) => {
this.router.navigate(['../view', response.resourceId], { relativeTo: this.route });
this.router.navigate(
[
'../view',
response.resourceId
],
{ relativeTo: this.route }
);
});
}
}
@@ -8,9 +8,8 @@ describe('EditClosureComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditClosureComponent ]
})
.compileComponents();
declarations: [EditClosureComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -15,7 +15,6 @@ import { AccountingService } from '../../accounting.service';
styleUrls: ['./edit-closure.component.scss']
})
export class EditClosureComponent implements OnInit {
/** Accounting closure form. */
accountingClosureForm: UntypedFormGroup;
/** GL Account closure. */
@@ -30,10 +29,12 @@ export class EditClosureComponent 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: { glAccountClosure: any }) => {
this.glAccountClosure = data.glAccountClosure;
});
@@ -52,9 +53,15 @@ export class EditClosureComponent implements OnInit {
*/
createAccountingClosureForm() {
this.accountingClosureForm = this.formBuilder.group({
'officeId': [{ value: '', disabled: true }, Validators.required],
'closingDate': [{ value: '', disabled: true }, Validators.required],
'comments': ['']
officeId: [
{ value: '', disabled: true },
Validators.required
],
closingDate: [
{ value: '', disabled: true },
Validators.required
],
comments: ['']
});
}
@@ -68,17 +75,21 @@ export class EditClosureComponent implements OnInit {
this.accountingClosureForm.get('comments').setValue(this.glAccountClosure.comments);
}
/**
* Submits the accounting closure form and updates accounting closure,
* if successful redirects to view updated closure.
*/
submit() {
this.accountingService.updateAccountingClosure(this.glAccountClosure.id,
{ comments: this.accountingClosureForm.value.comments })
this.accountingService
.updateAccountingClosure(this.glAccountClosure.id, { comments: this.accountingClosureForm.value.comments })
.subscribe((response: any) => {
this.router.navigate(['../../', response.resourceId], { relativeTo: this.route });
this.router.navigate(
[
'../../',
response.resourceId
],
{ relativeTo: this.route }
);
});
}
}
@@ -8,9 +8,8 @@ describe('ViewClosureComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewClosureComponent ]
})
.compileComponents();
declarations: [ViewClosureComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -18,7 +18,6 @@ import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dial
styleUrls: ['./view-closure.component.scss']
})
export class ViewClosureComponent {
/** GL Account closure. */
glAccountClosure: any;
@@ -29,10 +28,12 @@ export class ViewClosureComponent {
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference.
*/
constructor(private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router,
public dialog: MatDialog) {
constructor(
private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router,
public dialog: MatDialog
) {
this.route.data.subscribe((data: { glAccountClosure: any }) => {
this.glAccountClosure = data.glAccountClosure;
});
@@ -47,12 +48,10 @@ export class ViewClosureComponent {
});
deleteAccountingClosureDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.accountingService.deleteAccountingClosure(this.glAccountClosure.id)
.subscribe(() => {
this.router.navigate(['/accounting/closing-entries']);
});
this.accountingService.deleteAccountingClosure(this.glAccountClosure.id).subscribe(() => {
this.router.navigate(['/accounting/closing-entries']);
});
}
});
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class AccountingRulesAssociationsResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class AccountingRulesAssociationsResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.accountingService.getAccountingRules(true);
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class CurrenciesResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class CurrenciesResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.accountingService.getCurrencies();
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class GlAccountsResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class GlAccountsResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.accountingService.getGlAccounts();
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class JournalEntryTransactionResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -27,5 +26,4 @@ export class JournalEntryTransactionResolver implements Resolve<Object> {
const transactionId = route.paramMap.get('id');
return this.accountingService.getJournalEntry(transactionId);
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class LoanProductsResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class LoanProductsResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.accountingService.getLoanProducts();
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class OfficesResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class OfficesResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.accountingService.getOffices();
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class PaymentTypesResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class PaymentTypesResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.accountingService.getPaymentTypes();
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class ProvisioningCategoriesResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class ProvisioningCategoriesResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.accountingService.getProvisioningCategories();
}
}
@@ -8,9 +8,8 @@ describe('CreateJournalEntryComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CreateJournalEntryComponent ]
})
.compileComponents();
declarations: [CreateJournalEntryComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -22,7 +22,6 @@ import { NextStepDialogComponent } from '../../configuration-wizard/next-step-di
styleUrls: ['./create-journal-entry.component.scss']
})
export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
/** Minimum transaction date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum transaction date allowed. */
@@ -53,7 +52,8 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService.
*/
constructor(private formBuilder: UntypedFormBuilder,
constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
@@ -61,13 +61,9 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
private router: Router,
private dialog: MatDialog,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) {
this.route.data.subscribe((data: {
offices: any,
currencies: any,
paymentTypes: any,
glAccounts: any
}) => {
private popoverService: PopoverService
) {
this.route.data.subscribe((data: { offices: any; currencies: any; paymentTypes: any; glAccounts: any }) => {
this.officeData = data.offices;
this.currencyData = data.currencies.selectedCurrencyOptions;
this.paymentTypeData = data.paymentTypes;
@@ -88,19 +84,28 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
*/
createJournalEntryForm() {
this.journalEntryForm = this.formBuilder.group({
'officeId': ['', Validators.required],
'currencyCode': ['', Validators.required],
'debits': this.formBuilder.array([this.createAffectedGLEntryForm()]),
'credits': this.formBuilder.array([this.createAffectedGLEntryForm()]),
'referenceNumber': [''],
'transactionDate': ['', Validators.required],
'paymentTypeId': [''],
'accountNumber': [''],
'checkNumber': [''],
'routingCode': [''],
'receiptNumber': [''],
'bankNumber': [''],
'comments': ['']
officeId: [
'',
Validators.required
],
currencyCode: [
'',
Validators.required
],
debits: this.formBuilder.array([this.createAffectedGLEntryForm()]),
credits: this.formBuilder.array([this.createAffectedGLEntryForm()]),
referenceNumber: [''],
transactionDate: [
'',
Validators.required
],
paymentTypeId: [''],
accountNumber: [''],
checkNumber: [''],
routingCode: [''],
receiptNumber: [''],
bankNumber: [''],
comments: ['']
});
}
@@ -110,8 +115,14 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
*/
createAffectedGLEntryForm(): UntypedFormGroup {
return this.formBuilder.group({
'glAccountId': ['', Validators.required],
'amount': ['', Validators.required]
glAccountId: [
'',
Validators.required
],
amount: [
'',
Validators.required
]
});
}
@@ -158,10 +169,19 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
journalEntry.locale = this.settingsService.language.code;
journalEntry.dateFormat = this.settingsService.dateFormat;
if (journalEntry.transactionDate) {
journalEntry.transactionDate = this.dateUtils.formatDate(journalEntry.transactionDate, this.settingsService.dateFormat);
journalEntry.transactionDate = this.dateUtils.formatDate(
journalEntry.transactionDate,
this.settingsService.dateFormat
);
}
this.accountingService.createJournalEntry(journalEntry).subscribe(response => {
this.router.navigate(['../transactions/view', response.transactionId], { relativeTo: this.route });
this.accountingService.createJournalEntry(journalEntry).subscribe((response) => {
this.router.navigate(
[
'../transactions/view',
response.transactionId
],
{ relativeTo: this.route }
);
});
}
@@ -172,7 +192,12 @@ export class CreateJournalEntryComponent 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);
}
@@ -206,21 +231,21 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
* Next Step (Products) Dialog Configuration Wizard.
*/
openNextStepDialog() {
const nextStepDialogRef = this.dialog.open( NextStepDialogComponent, {
const nextStepDialogRef = this.dialog.open(NextStepDialogComponent, {
data: {
nextStepName: 'Setup Products',
previousStepName: 'Accounting',
stepPercentage: 74
},
}
});
nextStepDialogRef.afterClosed().subscribe((response: { nextStep: boolean }) => {
if (response.nextStep) {
this.configurationWizardService.showCreateJournalEntries = false;
this.configurationWizardService.showCharges = true;
this.router.navigate(['/products']);
if (response.nextStep) {
this.configurationWizardService.showCreateJournalEntries = false;
this.configurationWizardService.showCharges = true;
this.router.navigate(['/products']);
} else {
this.configurationWizardService.showCreateJournalEntries = false;
this.router.navigate(['/home']);
this.configurationWizardService.showCreateJournalEntries = false;
this.router.navigate(['/home']);
}
});
}
@@ -8,9 +8,8 @@ describe('CreateFinancialActivityMappingComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CreateFinancialActivityMappingComponent ]
})
.compileComponents();
declarations: [CreateFinancialActivityMappingComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -16,7 +16,6 @@ import { GLAccount } from 'app/shared/models/general.model';
styleUrls: ['./create-financial-activity-mapping.component.scss']
})
export class CreateFinancialActivityMappingComponent implements OnInit {
/** Financial activity mapping form. */
financialActivityMappingForm: UntypedFormGroup;
/** GL Account options. */
@@ -33,10 +32,12 @@ export class CreateFinancialActivityMappingComponent 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: { financialActivityAccountsTemplate: any }) => {
this.glAccountOptions = data.financialActivityAccountsTemplate.glAccountOptions;
this.financialActivityData = data.financialActivityAccountsTemplate.financialActivityOptions;
@@ -56,8 +57,14 @@ export class CreateFinancialActivityMappingComponent implements OnInit {
*/
createFinancialActivityMappingForm() {
this.financialActivityMappingForm = this.formBuilder.group({
'financialActivityId': ['', Validators.required],
'glAccountId': ['', Validators.required]
financialActivityId: [
'',
Validators.required
],
glAccountId: [
'',
Validators.required
]
});
}
@@ -65,21 +72,23 @@ export class CreateFinancialActivityMappingComponent implements OnInit {
* Sets the gl account data on the basis of selected financial activity.
*/
setGlAccountData() {
this.financialActivityMappingForm.get('financialActivityId').valueChanges
.subscribe(financialActivityId => {
switch (financialActivityId) {
case 100:
case 101:
case 102:
case 103: this.glAccountData = this.glAccountOptions.assetAccountOptions;
this.financialActivityMappingForm.get('financialActivityId').valueChanges.subscribe((financialActivityId) => {
switch (financialActivityId) {
case 100:
case 101:
case 102:
case 103:
this.glAccountData = this.glAccountOptions.assetAccountOptions;
break;
case 200:
case 201: this.glAccountData = this.glAccountOptions.liabilityAccountOptions;
case 200:
case 201:
this.glAccountData = this.glAccountOptions.liabilityAccountOptions;
break;
case 300: this.glAccountData = this.glAccountOptions.equityAccountOptions;
case 300:
this.glAccountData = this.glAccountOptions.equityAccountOptions;
break;
}
});
}
});
}
/**
@@ -87,10 +96,16 @@ export class CreateFinancialActivityMappingComponent implements OnInit {
* if successful redirects to view created account.
*/
submit() {
this.accountingService.createFinancialActivityAccount(this.financialActivityMappingForm.value)
this.accountingService
.createFinancialActivityAccount(this.financialActivityMappingForm.value)
.subscribe((response: any) => {
this.router.navigate(['../view', response.resourceId], { relativeTo: this.route });
});
this.router.navigate(
[
'../view',
response.resourceId
],
{ relativeTo: this.route }
);
});
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../../accounting.service';
*/
@Injectable()
export class FinancialActivityMappingsTemplateResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class FinancialActivityMappingsTemplateResolver implements Resolve<Object
resolve(): Observable<any> {
return this.accountingService.getFinancialActivityAccountsTemplate();
}
}
@@ -8,9 +8,8 @@ describe('EditFinancialActivityMappingComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditFinancialActivityMappingComponent ]
})
.compileComponents();
declarations: [EditFinancialActivityMappingComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -16,7 +16,6 @@ import { GLAccount } from 'app/shared/models/general.model';
styleUrls: ['./edit-financial-activity-mapping.component.scss']
})
export class EditFinancialActivityMappingComponent implements OnInit {
/** Financial activity mapping form. */
financialActivityMappingForm: UntypedFormGroup;
/** GL Account options. */
@@ -39,10 +38,12 @@ export class EditFinancialActivityMappingComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
*/
constructor(private formBuider: UntypedFormBuilder,
private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router) {
constructor(
private formBuider: UntypedFormBuilder,
private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router
) {
this.route.data.subscribe((data: { financialActivityAccountAndTemplate: any }) => {
this.financialActivityAccountId = data.financialActivityAccountAndTemplate.id;
console.log(data.financialActivityAccountAndTemplate.financialActivityData);
@@ -68,8 +69,14 @@ export class EditFinancialActivityMappingComponent implements OnInit {
*/
createFinancialActivityMappingForm() {
this.financialActivityMappingForm = this.formBuider.group({
'financialActivityId': ['', Validators.required],
'glAccountId': ['', Validators.required]
financialActivityId: [
'',
Validators.required
],
glAccountId: [
'',
Validators.required
]
});
}
@@ -77,21 +84,23 @@ export class EditFinancialActivityMappingComponent implements OnInit {
* Sets the gl account data on the basis of selected financial activity.
*/
setGLAccountData() {
this.financialActivityMappingForm.get('financialActivityId').valueChanges
.subscribe(financialActivityId => {
switch (financialActivityId) {
case 100:
case 101:
case 102:
case 103: this.glAccountData = this.glAccountOptions.assetAccountOptions;
this.financialActivityMappingForm.get('financialActivityId').valueChanges.subscribe((financialActivityId) => {
switch (financialActivityId) {
case 100:
case 101:
case 102:
case 103:
this.glAccountData = this.glAccountOptions.assetAccountOptions;
break;
case 200:
case 201: this.glAccountData = this.glAccountOptions.liabilityAccountOptions;
case 200:
case 201:
this.glAccountData = this.glAccountOptions.liabilityAccountOptions;
break;
case 300: this.glAccountData = this.glAccountOptions.equityAccountOptions;
case 300:
this.glAccountData = this.glAccountOptions.equityAccountOptions;
break;
}
});
}
});
}
/**
@@ -99,10 +108,16 @@ export class EditFinancialActivityMappingComponent implements OnInit {
* if successful redirects to view updated account.
*/
submit() {
this.accountingService.updateFinancialActivityAccount(this.financialActivityAccountId, this.financialActivityMappingForm.value)
this.accountingService
.updateFinancialActivityAccount(this.financialActivityAccountId, this.financialActivityMappingForm.value)
.subscribe((response: any) => {
this.router.navigate(['../../', response.resourceId], { relativeTo: this.route });
});
this.router.navigate(
[
'../../',
response.resourceId
],
{ relativeTo: this.route }
);
});
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../../accounting.service';
*/
@Injectable()
export class FinancialActivityMappingAndTemplateResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -27,5 +26,4 @@ export class FinancialActivityMappingAndTemplateResolver implements Resolve<Obje
const financialActivityAccountId = route.paramMap.get('id');
return this.accountingService.getFinancialActivityAccount(financialActivityAccountId, true);
}
}
@@ -8,9 +8,8 @@ describe('FinancialActivityMappingsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ FinancialActivityMappingsComponent ]
})
.compileComponents();
declarations: [FinancialActivityMappingsComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -18,11 +18,15 @@ import { ConfigurationWizardService } from '../../configuration-wizard/configura
styleUrls: ['./financial-activity-mappings.component.scss']
})
export class FinancialActivityMappingsComponent implements OnInit, AfterViewInit {
/** Financial activity account data. */
financialActivityAccountData: any;
/** Columns to be displayed in financial activity mappings table. */
displayedColumns: string[] = ['financialActivity', 'glAccountType', 'glAccountCode', 'glAccountName'];
displayedColumns: string[] = [
'financialActivity',
'glAccountType',
'glAccountCode',
'glAccountName'
];
/** Data source for financial activity mappings table. */
dataSource: MatTableDataSource<any>;
@@ -47,11 +51,13 @@ export class FinancialActivityMappingsComponent implements OnInit, AfterViewInit
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService.
*/
constructor(private route: ActivatedRoute,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) {
this.route.data.subscribe(( data: { financialActivityAccounts: any }) => {
constructor(
private route: ActivatedRoute,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService
) {
this.route.data.subscribe((data: { financialActivityAccounts: any }) => {
this.financialActivityAccountData = data.financialActivityAccounts;
});
}
@@ -71,10 +77,14 @@ export class FinancialActivityMappingsComponent implements OnInit, AfterViewInit
this.dataSource.paginator = this.paginator;
this.dataSource.sortingDataAccessor = (financialActivityAccount: any, property: any) => {
switch (property) {
case 'financialActivity': return financialActivityAccount.financialActivityData.name;
case 'glAccountName': return financialActivityAccount.glAccountData.name;
case 'glAccountCode': return financialActivityAccount.glAccountData.glCode;
default: return financialActivityAccount[property];
case 'financialActivity':
return financialActivityAccount.financialActivityData.name;
case 'glAccountName':
return financialActivityAccount.glAccountData.name;
case 'glAccountCode':
return financialActivityAccount.glAccountData.glCode;
default:
return financialActivityAccount[property];
}
};
this.dataSource.sort = this.sort;
@@ -87,7 +97,12 @@ export class FinancialActivityMappingsComponent 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);
}
@@ -127,5 +142,4 @@ export class FinancialActivityMappingsComponent implements OnInit, AfterViewInit
this.configurationWizardService.showAccountsLinked = true;
this.router.navigate(['/accounting']);
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class FinancialActivityMappingsResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class FinancialActivityMappingsResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.accountingService.getFinancialActivityAccounts();
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../../accounting.service';
*/
@Injectable()
export class FinancialActivityMappingResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -27,5 +26,4 @@ export class FinancialActivityMappingResolver implements Resolve<Object> {
const financialActivityAccountId = route.paramMap.get('id');
return this.accountingService.getFinancialActivityAccount(financialActivityAccountId, false);
}
}
@@ -8,9 +8,8 @@ describe('ViewFinancialActivityMappingComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewFinancialActivityMappingComponent ]
})
.compileComponents();
declarations: [ViewFinancialActivityMappingComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -19,7 +19,6 @@ import { Location } from '@angular/common';
styleUrls: ['./view-financial-activity-mapping.component.scss']
})
export class ViewFinancialActivityMappingComponent {
/** Financial activity account ID. */
financialActivityAccountId: any;
/** Financial activity account data. */
@@ -32,11 +31,13 @@ export class ViewFinancialActivityMappingComponent {
* @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: { financialActivityAccount: any }) => {
this.financialActivityAccount = data.financialActivityAccount;
this.financialActivityAccountId = data.financialActivityAccount.id;
@@ -52,10 +53,9 @@ export class ViewFinancialActivityMappingComponent {
});
deleteFinancialActivityAccountDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.accountingService.deleteFinancialActivityAccount(this.financialActivityAccountId)
.subscribe(() => {
this.router.navigate(['/accounting/financial-activity-mappings']);
});
this.accountingService.deleteFinancialActivityAccount(this.financialActivityAccountId).subscribe(() => {
this.router.navigate(['/accounting/financial-activity-mappings']);
});
}
});
}
@@ -63,5 +63,4 @@ export class ViewFinancialActivityMappingComponent {
goBack(): void {
this.location.back();
}
}
@@ -8,9 +8,8 @@ describe('FrequentPostingsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ FrequentPostingsComponent ]
})
.compileComponents();
declarations: [FrequentPostingsComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -16,7 +16,6 @@ import { Dates } from 'app/core/utils/dates';
styleUrls: ['./frequent-postings.component.scss']
})
export class FrequentPostingsComponent implements OnInit {
/** Minimum transaction date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum transaction date allowed. */
@@ -48,23 +47,20 @@ export class FrequentPostingsComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
*/
constructor(private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) {
this.route.data.subscribe((data: {
offices: any,
accountingRules: any,
currencies: any,
paymentTypes: any
}) => {
this.officeData = data.offices;
this.accountingRuleData = data.accountingRules;
this.currencyData = data.currencies.selectedCurrencyOptions;
this.paymentTypeData = data.paymentTypes;
});
constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router
) {
this.route.data.subscribe((data: { offices: any; accountingRules: any; currencies: any; paymentTypes: any }) => {
this.officeData = data.offices;
this.accountingRuleData = data.accountingRules;
this.currencyData = data.currencies.selectedCurrencyOptions;
this.paymentTypeData = data.paymentTypes;
});
}
/**
@@ -81,20 +77,32 @@ export class FrequentPostingsComponent implements OnInit {
*/
createFrequentPostingsForm() {
this.frequentPostingsForm = this.formBuilder.group({
'officeId': ['', Validators.required],
'accountingRule': ['', Validators.required],
'currencyCode': ['', Validators.required],
'debits': this.formBuilder.array([]),
'credits': this.formBuilder.array([]),
'referenceNumber': [''],
'transactionDate': ['', Validators.required],
'paymentTypeId': [''],
'accountNumber': [''],
'checkNumber': [''],
'routingCode': [''],
'receiptNumber': [''],
'bankNumber': [''],
'comments': ['']
officeId: [
'',
Validators.required
],
accountingRule: [
'',
Validators.required
],
currencyCode: [
'',
Validators.required
],
debits: this.formBuilder.array([]),
credits: this.formBuilder.array([]),
referenceNumber: [''],
transactionDate: [
'',
Validators.required
],
paymentTypeId: [''],
accountNumber: [''],
checkNumber: [''],
routingCode: [''],
receiptNumber: [''],
bankNumber: [''],
comments: ['']
});
}
@@ -102,7 +110,7 @@ export class FrequentPostingsComponent implements OnInit {
* Sets the affected gl entry form array.
*/
setAffectedGLEntryForm() {
this.frequentPostingsForm.get('accountingRule').valueChanges.subscribe(accountingRule => {
this.frequentPostingsForm.get('accountingRule').valueChanges.subscribe((accountingRule) => {
while (this.debits.length) {
this.debits.removeAt(0);
}
@@ -124,8 +132,14 @@ export class FrequentPostingsComponent implements OnInit {
*/
createAffectedGLEntryForm(): UntypedFormGroup {
return this.formBuilder.group({
'glAccountId': ['', Validators.required],
'amount': ['', Validators.required]
glAccountId: [
'',
Validators.required
],
amount: [
'',
Validators.required
]
});
}
@@ -173,11 +187,19 @@ export class FrequentPostingsComponent implements OnInit {
journalEntry.locale = this.settingsService.language.code;
journalEntry.dateFormat = this.settingsService.dateFormat;
if (journalEntry.transactionDate instanceof Date) {
journalEntry.transactionDate = this.dateUtils.formatDate(journalEntry.transactionDate, this.settingsService.dateFormat);
journalEntry.transactionDate = this.dateUtils.formatDate(
journalEntry.transactionDate,
this.settingsService.dateFormat
);
}
this.accountingService.createJournalEntry(journalEntry).subscribe(response => {
this.router.navigate(['../transactions/view', response.transactionId], { relativeTo: this.route });
this.accountingService.createJournalEntry(journalEntry).subscribe((response) => {
this.router.navigate(
[
'../transactions/view',
response.transactionId
],
{ relativeTo: this.route }
);
});
}
}
@@ -8,9 +8,8 @@ describe('MigrateOpeningBalancesComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ MigrateOpeningBalancesComponent ]
})
.compileComponents();
declarations: [MigrateOpeningBalancesComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -23,7 +23,6 @@ import { TranslateService } from '@ngx-translate/core';
styleUrls: ['./migrate-opening-balances.component.scss']
})
export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
/** Minimum opening balances date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum opening balances date allowed. */
@@ -57,7 +56,8 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService.
*/
constructor(private formBuilder: UntypedFormBuilder,
constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
@@ -65,11 +65,9 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService,
private translateService: TranslateService) {
this.route.data.subscribe((data: {
offices: any,
currencies: any
}) => {
private translateService: TranslateService
) {
this.route.data.subscribe((data: { offices: any; currencies: any }) => {
this.officeData = data.offices;
this.currencyData = data.currencies.selectedCurrencyOptions;
});
@@ -88,10 +86,19 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
*/
createOpeningBalancesForm() {
this.openingBalancesForm = this.formBuilder.group({
'officeId': ['', Validators.required],
'currencyCode': ['', Validators.required],
'transactionDate': ['', Validators.required],
'glAccountEntries': this.formBuilder.array([])
officeId: [
'',
Validators.required
],
currencyCode: [
'',
Validators.required
],
transactionDate: [
'',
Validators.required
],
glAccountEntries: this.formBuilder.array([])
});
this.openingBalancesForm.controls.currencyCode.valueChanges.subscribe((value: string) => {
@@ -105,11 +112,14 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
* @returns {FormGroup} GL Account entry form.
*/
createGLAccountEntryForm(glAccount: any): UntypedFormGroup {
return this.formBuilder.group({
'glAccountId': [glAccount.glAccountId],
'debit': [null],
'credit': [null]
}, { validator: onlyOneOfTheFieldsIsRequiredValidator });
return this.formBuilder.group(
{
glAccountId: [glAccount.glAccountId],
debit: [null],
credit: [null]
},
{ validator: onlyOneOfTheFieldsIsRequiredValidator }
);
}
/**
@@ -124,15 +134,17 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
* Retrieves gl accounts on the basis of specified office.
*/
retrieveOpeningBalances() {
this.accountingService.retrieveOpeningBalances(this.openingBalancesForm.value.officeId)
this.accountingService
.retrieveOpeningBalances(this.openingBalancesForm.value.officeId)
.subscribe((openingBalancesData: any) => {
const entry = this.openingBalancesForm.get('glAccountEntries') as UntypedFormArray;
openingBalancesData.glAccounts = openingBalancesData.assetAccountOpeningBalances
.concat(openingBalancesData.liabityAccountOpeningBalances,
openingBalancesData.equityAccountOpeningBalances,
openingBalancesData.incomeAccountOpeningBalances,
openingBalancesData.expenseAccountOpeningBalances);
openingBalancesData.glAccounts = openingBalancesData.assetAccountOpeningBalances.concat(
openingBalancesData.liabityAccountOpeningBalances,
openingBalancesData.equityAccountOpeningBalances,
openingBalancesData.incomeAccountOpeningBalances,
openingBalancesData.expenseAccountOpeningBalances
);
openingBalancesData.glAccounts.forEach((glAccount: any) => {
entry.push(this.createGLAccountEntryForm(glAccount));
@@ -143,7 +155,7 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
entry.valueChanges.subscribe(() => {
this.debitsSum = 0;
this.creditsSum = 0;
entry.controls.forEach(value => {
entry.controls.forEach((value) => {
this.debitsSum += value.value.debit;
this.creditsSum += value.value.credit;
});
@@ -161,7 +173,10 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
openingBalances.locale = this.settingsService.language.code;
openingBalances.dateFormat = this.settingsService.dateFormat;
if (openingBalances.transactionDate instanceof Date) {
openingBalances.transactionDate = this.dateUtils.formatDate(openingBalances.transactionDate, this.settingsService.dateFormat);
openingBalances.transactionDate = this.dateUtils.formatDate(
openingBalances.transactionDate,
this.settingsService.dateFormat
);
}
openingBalances.debits = [];
openingBalances.credits = [];
@@ -175,7 +190,10 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
});
delete openingBalances.glAccountEntries;
this.accountingService.defineOpeningBalances(openingBalances).subscribe((response: any) => {
this.router.navigate(['/accounting/journal-entries/transactions/view', response.transactionId]);
this.router.navigate([
'/accounting/journal-entries/transactions/view',
response.transactionId
]);
});
}
}
@@ -187,7 +205,12 @@ export class MigrateOpeningBalancesComponent 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);
}
@@ -229,11 +252,10 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
creditsSum = creditsSum + entry.credit;
}
});
return (debitsSum > 0 && debitsSum === creditsSum);
return debitsSum > 0 && debitsSum === creditsSum;
}
glAccountTypeLabel(accountType: string): string {
return this.translateService.instant('labels.inputs.accounting.' + accountType);
}
}
@@ -2,12 +2,14 @@
import { UntypedFormGroup, ValidatorFn, ValidationErrors } from '@angular/forms';
/** Validates that atleast one of the fields debit or credit is filled (but not both) for a given gl account. */
export const onlyOneOfTheFieldsIsRequiredValidator: ValidatorFn = (glAccountEntriesForm: UntypedFormGroup): ValidationErrors | null => {
export const onlyOneOfTheFieldsIsRequiredValidator: ValidatorFn = (
glAccountEntriesForm: UntypedFormGroup
): ValidationErrors | null => {
const debit = glAccountEntriesForm.controls.debit.value;
const credit = glAccountEntriesForm.controls.credit.value;
if (debit && credit) {
if (debit > 0 && credit > 0) {
return { 'error': true };
return { error: true };
}
}
return null;
@@ -8,9 +8,8 @@ describe('PeriodicAccrualsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PeriodicAccrualsComponent ]
})
.compileComponents();
declarations: [PeriodicAccrualsComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -16,7 +16,6 @@ import { Dates } from 'app/core/utils/dates';
styleUrls: ['./periodic-accruals.component.scss']
})
export class PeriodicAccrualsComponent implements OnInit {
/** Minimum accrue date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum accrue date allowed. */
@@ -31,12 +30,14 @@ export class PeriodicAccrualsComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
*/
constructor(private formBuilder: UntypedFormBuilder,
constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) { }
private router: Router
) {}
/**
* Creates periodic accruals form.
@@ -51,7 +52,10 @@ export class PeriodicAccrualsComponent implements OnInit {
*/
createPeriodicAccrualsForm() {
this.periodicAccrualsForm = this.formBuilder.group({
'tillDate': ['', Validators.required]
tillDate: [
'',
Validators.required
]
});
}
@@ -71,5 +75,4 @@ export class PeriodicAccrualsComponent implements OnInit {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
}
@@ -8,9 +8,8 @@ describe('CreateProvisioningEntryComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CreateProvisioningEntryComponent ]
})
.compileComponents();
declarations: [CreateProvisioningEntryComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -16,7 +16,6 @@ import { Dates } from 'app/core/utils/dates';
styleUrls: ['./create-provisioning-entry.component.scss']
})
export class CreateProvisioningEntryComponent implements OnInit {
/** Minimum provisioning date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum provisioning date allowed. */
@@ -31,12 +30,14 @@ export class CreateProvisioningEntryComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
*/
constructor(private formBuilder: UntypedFormBuilder,
constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) { }
private router: Router
) {}
/**
* Creates the provisioning entry form.
@@ -51,8 +52,11 @@ export class CreateProvisioningEntryComponent implements OnInit {
*/
createProvisioningEntryForm() {
this.provisioningEntryForm = this.formBuilder.group({
'date': ['', Validators.required],
'createjournalentries': [false]
date: [
'',
Validators.required
],
createjournalentries: [false]
});
}
@@ -68,10 +72,14 @@ export class CreateProvisioningEntryComponent implements OnInit {
if (provisioningEntry.date instanceof Date) {
provisioningEntry.date = this.dateUtils.formatDate(provisioningEntry.date, this.settingsService.dateFormat);
}
this.accountingService.createProvisioningEntry(provisioningEntry)
.subscribe((response: any) => {
this.router.navigate(['../view', response.resourceId], { relativeTo: this.route });
});
this.accountingService.createProvisioningEntry(provisioningEntry).subscribe((response: any) => {
this.router.navigate(
[
'../view',
response.resourceId
],
{ relativeTo: this.route }
);
});
}
}
@@ -8,9 +8,8 @@ describe('ProvisioningEntriesComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ProvisioningEntriesComponent ]
})
.compileComponents();
declarations: [ProvisioningEntriesComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -17,11 +17,17 @@ import { AccountingService } from '../accounting.service';
styleUrls: ['./provisioning-entries.component.scss']
})
export class ProvisioningEntriesComponent implements OnInit {
/** Provisioning entry data. */
provisioningEntryData: any;
/** Columns to be displayed in provisioning entries table. */
displayedColumns: string[] = ['createdUser', 'createdDate', 'journalEntry', 'viewReport', 'recreateProvisioning', 'viewJournalEntry'];
displayedColumns: string[] = [
'createdUser',
'createdDate',
'journalEntry',
'viewReport',
'recreateProvisioning',
'viewJournalEntry'
];
/** Data source for provisioning entries table. */
dataSource: MatTableDataSource<any>;
@@ -36,9 +42,11 @@ export class ProvisioningEntriesComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
*/
constructor(private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router) {
constructor(
private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router
) {
this.route.data.subscribe((data: { provisioningEntries: any }) => {
this.provisioningEntryData = data.provisioningEntries.pageItems;
});
@@ -74,10 +82,15 @@ export class ProvisioningEntriesComponent implements OnInit {
* @param {string} provisioningEntryId Provisioning entry id.
*/
recreateProvisioning($event: Event, provisioningEntryId: string) {
this.accountingService.recreateProvisioningEntries(provisioningEntryId)
.subscribe((response: any) => {
this.router.navigate(['view', response.resourceId], { relativeTo: this.route });
});
this.accountingService.recreateProvisioningEntries(provisioningEntryId).subscribe((response: any) => {
this.router.navigate(
[
'view',
response.resourceId
],
{ relativeTo: this.route }
);
});
$event.stopPropagation();
}
@@ -87,8 +100,13 @@ export class ProvisioningEntriesComponent implements OnInit {
* @param {number} provisioningEntryId Provisioning entry id.
*/
viewJournalEntry($event: Event, provisioningEntryId: number) {
this.router.navigate(['journal-entries/view', provisioningEntryId], { relativeTo: this.route });
this.router.navigate(
[
'journal-entries/view',
provisioningEntryId
],
{ relativeTo: this.route }
);
$event.stopPropagation();
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/
@Injectable()
export class ProvisioningEntriesResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -26,5 +25,4 @@ export class ProvisioningEntriesResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.accountingService.getProvisioningEntries();
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../../accounting.service';
*/
@Injectable()
export class ProvisioningEntryEntriesResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -27,5 +26,4 @@ export class ProvisioningEntryEntriesResolver implements Resolve<Object> {
const provisioningEntryId = route.paramMap.get('id');
return this.accountingService.getProvisioningEntryEntries(provisioningEntryId);
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../../accounting.service';
*/
@Injectable()
export class ProvisioningEntryResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -27,5 +26,4 @@ export class ProvisioningEntryResolver implements Resolve<Object> {
const provisioningEntryId = route.paramMap.get('id');
return this.accountingService.getProvisioningEntry(provisioningEntryId);
}
}
@@ -8,9 +8,8 @@ describe('ViewProvisioningEntryComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewProvisioningEntryComponent ]
})
.compileComponents();
declarations: [ViewProvisioningEntryComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -21,7 +21,6 @@ import { AccountingService } from '../../accounting.service';
styleUrls: ['./view-provisioning-entry.component.scss']
})
export class ViewProvisioningEntryComponent implements OnInit, AfterViewInit {
/** Provisioning entry id. */
provisioningEntryId: string;
/** Provisioning entry. */
@@ -47,7 +46,15 @@ export class ViewProvisioningEntryComponent implements OnInit, AfterViewInit {
/** Filtered provisioning category data for autocomplete. */
filteredProvisioningCategoryData: any;
/** Columns to be displayed in provisioning entry entries table. */
displayedColumns: string[] = ['officeName', 'productName', 'currencyCode', 'categoryName', 'amountreserved', 'liabilityAccountName', 'expenseAccountName'];
displayedColumns: string[] = [
'officeName',
'productName',
'currencyCode',
'categoryName',
'amountreserved',
'liabilityAccountName',
'expenseAccountName'
];
/** Data source for provisioning entry entries table. */
dataSource: MatTableDataSource<any>;
/** Provisioning entry entries filter. */
@@ -69,15 +76,18 @@ export class ViewProvisioningEntryComponent implements OnInit, AfterViewInit {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
*/
constructor(private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router) {
this.route.data.subscribe((data: {
provisioningEntry: any,
provisioningEntryEntries: any,
offices: any,
loanProducts: any,
provisiningCategories: any
constructor(
private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router
) {
this.route.data.subscribe(
(data: {
provisioningEntry: any;
provisioningEntryEntries: any;
offices: any;
loanProducts: any;
provisiningCategories: any;
}) => {
this.provisioningEntryId = data.provisioningEntry.id;
this.provisioningEntry = data.provisioningEntry;
@@ -85,7 +95,8 @@ export class ViewProvisioningEntryComponent implements OnInit, AfterViewInit {
this.officeData = data.offices;
this.loanProductData = data.loanProducts;
this.provisioningCategoryData = data.provisiningCategories;
});
}
);
}
/**
@@ -106,7 +117,7 @@ export class ViewProvisioningEntryComponent implements OnInit, AfterViewInit {
ngAfterViewInit() {
this.officeName.valueChanges
.pipe(
map(value => value.toLowerCase()),
map((value) => value.toLowerCase()),
debounceTime(500),
distinctUntilChanged(),
tap((filterValue) => {
@@ -117,7 +128,7 @@ export class ViewProvisioningEntryComponent implements OnInit, AfterViewInit {
this.loanProduct.valueChanges
.pipe(
map(value => value.toLowerCase()),
map((value) => value.toLowerCase()),
debounceTime(500),
distinctUntilChanged(),
tap((filterValue) => {
@@ -128,7 +139,7 @@ export class ViewProvisioningEntryComponent implements OnInit, AfterViewInit {
this.provisioningCategory.valueChanges
.pipe(
map(value => value.toLowerCase()),
map((value) => value.toLowerCase()),
debounceTime(500),
distinctUntilChanged(),
tap((filterValue) => {
@@ -144,9 +155,11 @@ export class ViewProvisioningEntryComponent implements OnInit, AfterViewInit {
* @param {any} filterValue Values to filter data by.
*/
filterPredicate(data: any, filterValue: any) {
return data.officeName.toLowerCase().indexOf(filterValue['officeName']) !== -1
&& data.productName.toLowerCase().indexOf(filterValue['productName']) !== -1
&& data.categoryName.toLowerCase().indexOf(filterValue['categoryName']) !== -1;
return (
data.officeName.toLowerCase().indexOf(filterValue['officeName']) !== -1 &&
data.productName.toLowerCase().indexOf(filterValue['productName']) !== -1 &&
data.categoryName.toLowerCase().indexOf(filterValue['categoryName']) !== -1
);
}
/**
@@ -174,11 +187,10 @@ export class ViewProvisioningEntryComponent implements OnInit, AfterViewInit {
* Sets filtered offices for autocomplete.
*/
setFilteredOffices() {
this.filteredOfficeData = this.officeName.valueChanges
.pipe(
this.filteredOfficeData = this.officeName.valueChanges.pipe(
startWith(''),
map((office: any) => typeof office === 'string' ? office : office.name),
map((officeName: string) => officeName ? this.filterOfficeAutocompleteData(officeName) : this.officeData)
map((office: any) => (typeof office === 'string' ? office : office.name)),
map((officeName: string) => (officeName ? this.filterOfficeAutocompleteData(officeName) : this.officeData))
);
}
@@ -186,11 +198,12 @@ export class ViewProvisioningEntryComponent implements OnInit, AfterViewInit {
* Sets filtered loan products for autocomplete.
*/
setFilteredLoanProducts() {
this.filteredLoanProductData = this.loanProduct.valueChanges
.pipe(
this.filteredLoanProductData = this.loanProduct.valueChanges.pipe(
startWith(''),
map((loanProduct: any) => typeof loanProduct === 'string' ? loanProduct : loanProduct.name),
map((loanProductName: string) => loanProductName ? this.filterLoanProductAutocompleteData(loanProductName) : this.loanProductData)
map((loanProduct: any) => (typeof loanProduct === 'string' ? loanProduct : loanProduct.name)),
map((loanProductName: string) =>
loanProductName ? this.filterLoanProductAutocompleteData(loanProductName) : this.loanProductData
)
);
}
@@ -198,11 +211,16 @@ export class ViewProvisioningEntryComponent implements OnInit, AfterViewInit {
* Sets filtered provisioning categories for autocomplete.
*/
setFilteredProvisioningCategories() {
this.filteredProvisioningCategoryData = this.provisioningCategory.valueChanges
.pipe(
this.filteredProvisioningCategoryData = this.provisioningCategory.valueChanges.pipe(
startWith(''),
map((provisioningCategory: any) => typeof provisioningCategory === 'string' ? provisioningCategory : provisioningCategory.categoryName),
map((provisioningCategoryName: string) => provisioningCategoryName ? this.filterProvisioningCategoryAutocompleteData(provisioningCategoryName) : this.provisioningCategoryData)
map((provisioningCategory: any) =>
typeof provisioningCategory === 'string' ? provisioningCategory : provisioningCategory.categoryName
),
map((provisioningCategoryName: string) =>
provisioningCategoryName
? this.filterProvisioningCategoryAutocompleteData(provisioningCategoryName)
: this.provisioningCategoryData
)
);
}
@@ -221,7 +239,9 @@ export class ViewProvisioningEntryComponent implements OnInit, AfterViewInit {
* @returns {any} Filtered loan products.
*/
private filterLoanProductAutocompleteData(loanProductName: string): any {
return this.loanProductData.filter((loanProduct: any) => loanProduct.name.toLowerCase().includes(loanProductName.toLocaleLowerCase()));
return this.loanProductData.filter((loanProduct: any) =>
loanProduct.name.toLowerCase().includes(loanProductName.toLocaleLowerCase())
);
}
/**
@@ -230,7 +250,9 @@ export class ViewProvisioningEntryComponent implements OnInit, AfterViewInit {
* @returns {any} Filtered provisioning categories.
*/
private filterProvisioningCategoryAutocompleteData(provisioningCategoryName: string): any {
return this.provisioningCategoryData.filter((provisioningCategory: any) => provisioningCategory.categoryName.toLowerCase().includes(provisioningCategoryName.toLocaleLowerCase()));
return this.provisioningCategoryData.filter((provisioningCategory: any) =>
provisioningCategory.categoryName.toLowerCase().includes(provisioningCategoryName.toLocaleLowerCase())
);
}
/**
@@ -238,10 +260,14 @@ export class ViewProvisioningEntryComponent implements OnInit, AfterViewInit {
* and redirects to created entries.
*/
createProvisioningJournalEntries() {
this.accountingService.createProvisioningJournalEntries(this.provisioningEntryId)
.subscribe((response: any) => {
this.router.navigate(['../../journal-entries/view', response.resourceId], { relativeTo: this.route });
});
this.accountingService.createProvisioningJournalEntries(this.provisioningEntryId).subscribe((response: any) => {
this.router.navigate(
[
'../../journal-entries/view',
response.resourceId
],
{ relativeTo: this.route }
);
});
}
}
@@ -13,7 +13,6 @@ import { AccountingService } from '../../accounting.service';
*/
@Injectable()
export class ProvisioningJournalEntriesResolver implements Resolve<Object> {
/**
* @param {AccountingService} accountingService Accounting service.
*/
@@ -27,5 +26,4 @@ export class ProvisioningJournalEntriesResolver implements Resolve<Object> {
const id = route.paramMap.get('id');
return this.accountingService.getProvisioningJournalEntries(id);
}
}
@@ -8,9 +8,8 @@ describe('ViewProvisioningJournalEntriesComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewProvisioningJournalEntriesComponent ]
})
.compileComponents();
declarations: [ViewProvisioningJournalEntriesComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -14,11 +14,21 @@ import { MatTableDataSource } from '@angular/material/table';
styleUrls: ['./view-provisioning-journal-entries.component.scss']
})
export class ViewProvisioningJournalEntriesComponent implements OnInit {
/** Provisioning journal entry data. */
provisioningJournalEntryData: any;
/** Columns to be displayed in provisioning journal entries table. */
displayedColumns: string[] = ['id', 'officeName', 'transactionDate', 'transactionId', 'glAccountType', 'createdByUserName', 'glAccountCode', 'glAccountName', 'debit', 'credit'];
displayedColumns: string[] = [
'id',
'officeName',
'transactionDate',
'transactionId',
'glAccountType',
'createdByUserName',
'glAccountCode',
'glAccountName',
'debit',
'credit'
];
/** Data source for provisioning journal entries table. */
dataSource: MatTableDataSource<any>;
@@ -52,10 +62,14 @@ export class ViewProvisioningJournalEntriesComponent implements OnInit {
this.dataSource.paginator = this.paginator;
this.dataSource.sortingDataAccessor = (transaction: any, property: any) => {
switch (property) {
case 'glAccountType': return transaction.glAccountType.value;
case 'debit': return transaction.amount;
case 'credit': return transaction.amount;
default: return transaction[property];
case 'glAccountType':
return transaction.glAccountType.value;
case 'debit':
return transaction.amount;
case 'credit':
return transaction.amount;
default:
return transaction[property];
}
};
this.dataSource.sort = this.sort;
@@ -68,5 +82,4 @@ export class ViewProvisioningJournalEntriesComponent implements OnInit {
applyFilter(filterValue: string) {
this.dataSource.filter = filterValue.trim().toLowerCase();
}
}
@@ -8,9 +8,8 @@ describe('RevertTransactionComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ RevertTransactionComponent ]
})
.compileComponents();
declarations: [RevertTransactionComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -12,7 +12,6 @@ import { UntypedFormControl } from '@angular/forms';
styleUrls: ['./revert-transaction.component.scss']
})
export class RevertTransactionComponent {
/** Comments input form control. */
comments = new UntypedFormControl('');
@@ -20,7 +19,8 @@ export class RevertTransactionComponent {
* @param {MatDialogRef} dialogRef Component reference to dialog.
* @param {any} data Provides comments or reverted transaction ID.
*/
constructor(public dialogRef: MatDialogRef<RevertTransactionComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) { }
constructor(
public dialogRef: MatDialogRef<RevertTransactionComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) {}
}
@@ -11,7 +11,6 @@ import { AccountingService } from '../accounting.service';
* Journal entries custom data source to implement server side filtering, pagination and sorting.
*/
export class JournalEntriesDataSource implements DataSource<any> {
/** Journal entries behavior subject to represent loaded journal entries page. */
private journalEntriesSubject = new BehaviorSubject<any[]>([]);
/** Records subject to represent total number of filtered journal entry records. */
@@ -22,7 +21,7 @@ export class JournalEntriesDataSource implements DataSource<any> {
/**
* @param {AccountingService} accountingService Accounting Service
*/
constructor(private accountingService: AccountingService) { }
constructor(private accountingService: AccountingService) {}
/**
* Gets journal entries on the basis of provided parameters and emits the value.
@@ -32,10 +31,17 @@ export class JournalEntriesDataSource implements DataSource<any> {
* @param {number} pageIndex Page number.
* @param {number} limit Number of entries within the page.
*/
getJournalEntries(filterBy: any, orderBy: string = '', sortOrder: string = '', pageIndex: number = 0, limit: number = 10) {
getJournalEntries(
filterBy: any,
orderBy: string = '',
sortOrder: string = '',
pageIndex: number = 0,
limit: number = 10
) {
this.journalEntriesSubject.next([]);
orderBy = (orderBy === 'debit' || orderBy === 'credit') ? 'amount' : orderBy;
this.accountingService.getJournalEntries(filterBy, orderBy, sortOrder, pageIndex * limit, limit)
orderBy = orderBy === 'debit' || orderBy === 'credit' ? 'amount' : orderBy;
this.accountingService
.getJournalEntries(filterBy, orderBy, sortOrder, pageIndex * limit, limit)
.subscribe((journalEntries: any) => {
this.recordsSubject.next(journalEntries.totalFilteredRecords);
this.journalEntriesSubject.next(journalEntries.pageItems);
@@ -56,5 +62,4 @@ export class JournalEntriesDataSource implements DataSource<any> {
this.journalEntriesSubject.complete();
this.recordsSubject.complete();
}
}
@@ -8,9 +8,8 @@ describe('SearchJournalEntryComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SearchJournalEntryComponent ]
})
.compileComponents();
declarations: [SearchJournalEntryComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -7,7 +7,7 @@ import { ActivatedRoute } from '@angular/router';
/** rxjs Imports */
import { merge } from 'rxjs';
import { tap, startWith, map, distinctUntilChanged, debounceTime} from 'rxjs/operators';
import { tap, startWith, map, distinctUntilChanged, debounceTime } from 'rxjs/operators';
/** Custom Services */
import { AccountingService } from '../accounting.service';
@@ -25,7 +25,6 @@ import { Dates } from 'app/core/utils/dates';
styleUrls: ['./search-journal-entry.component.scss']
})
export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
/** Minimum transaction date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum transaction date allowed. */
@@ -56,7 +55,7 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
},
{
option: 'System Entries',
value: false // Bug: unable to implement from server side
value: false // Bug: unable to implement from server side
}
];
/** Transaction date from form control. */
@@ -70,7 +69,20 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
/** Submitted on date to form control. */
submittedOnDateTo = new UntypedFormControl();
/** Columns to be displayed in journal entries table. */
displayedColumns: string[] = ['id', 'officeName', 'transactionId', 'transactionDate', 'glAccountType', 'createdByUserName', 'submittedOnDate', 'glAccountCode', 'glAccountName', 'currency', 'debit', 'credit'];
displayedColumns: string[] = [
'id',
'officeName',
'transactionId',
'transactionDate',
'glAccountType',
'createdByUserName',
'submittedOnDate',
'glAccountCode',
'glAccountName',
'currency',
'debit',
'credit'
];
/** Data source for journal entries table. */
dataSource: JournalEntriesDataSource;
/** Journal entries filter. */
@@ -93,7 +105,10 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
},
{
type: 'fromDate',
value: this.dateUtils.formatDate(new Date(new Date().setMonth(new Date().getMonth() - 1)), this.settingsService.dateFormat)
value: this.dateUtils.formatDate(
new Date(new Date().setMonth(new Date().getMonth() - 1)),
this.settingsService.dateFormat
)
},
{
type: 'toDate',
@@ -128,17 +143,16 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
* @param {ActivatedRoute} route Activated Route.
* @param {SettingsService} settingsService Settings Service.
*/
constructor(private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute) {
this.route.data.subscribe((data: {
offices: any,
glAccounts: any
}) => {
this.officeData = data.offices;
this.glAccountData = data.glAccounts;
});
constructor(
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute
) {
this.route.data.subscribe((data: { offices: any; glAccounts: any }) => {
this.officeData = data.offices;
this.glAccountData = data.glAccounts;
});
}
/**
@@ -159,7 +173,7 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
ngAfterViewInit() {
this.officeName.valueChanges
.pipe(
map(value => value.id ? value.id : ''),
map((value) => (value.id ? value.id : '')),
debounceTime(500),
distinctUntilChanged(),
tap((filterValue) => {
@@ -170,7 +184,7 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
this.glAccount.valueChanges
.pipe(
map(value => value ? value : ''),
map((value) => (value ? value : '')),
debounceTime(500),
distinctUntilChanged(),
tap((filterValue) => {
@@ -209,12 +223,15 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
)
.subscribe();
this.submittedOnDateFrom.valueChanges
this.submittedOnDateFrom.valueChanges
.pipe(
debounceTime(500),
distinctUntilChanged(),
tap((filterValue) => {
this.applyFilter(this.dateUtils.formatDate(filterValue, this.settingsService.dateFormat), 'submittedOnDateFrom');
this.applyFilter(
this.dateUtils.formatDate(filterValue, this.settingsService.dateFormat),
'submittedOnDateFrom'
);
})
)
.subscribe();
@@ -224,17 +241,18 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
debounceTime(500),
distinctUntilChanged(),
tap((filterValue) => {
this.applyFilter(this.dateUtils.formatDate(filterValue, this.settingsService.dateFormat), 'submittedOnDateTo');
this.applyFilter(
this.dateUtils.formatDate(filterValue, this.settingsService.dateFormat),
'submittedOnDateTo'
);
})
)
.subscribe();
this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0);
this.sort.sortChange.subscribe(() => (this.paginator.pageIndex = 0));
merge(this.sort.sortChange, this.paginator.page)
.pipe(
tap(() => this.loadJournalEntriesPage())
)
.pipe(tap(() => this.loadJournalEntriesPage()))
.subscribe();
}
@@ -245,7 +263,13 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
if (!this.sort.direction) {
delete this.sort.active;
}
this.dataSource.getJournalEntries(this.filterJournalEntriesBy, this.sort.active, this.sort.direction, this.paginator.pageIndex, this.paginator.pageSize);
this.dataSource.getJournalEntries(
this.filterJournalEntriesBy,
this.sort.active,
this.sort.direction,
this.paginator.pageIndex,
this.paginator.pageSize
);
}
/**
@@ -255,7 +279,7 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
*/
applyFilter(filterValue: string, property: string) {
this.paginator.pageIndex = 0;
const findIndex = this.filterJournalEntriesBy.findIndex(filter => filter.type === property);
const findIndex = this.filterJournalEntriesBy.findIndex((filter) => filter.type === property);
this.filterJournalEntriesBy[findIndex].value = filterValue;
this.loadJournalEntriesPage();
}
@@ -273,24 +297,24 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
* Sets filtered offices for autocomplete.
*/
setFilteredOffices() {
this.filteredOfficeData = this.officeName.valueChanges
.pipe(
startWith(''),
map((office: any) => typeof office === 'string' ? office : office.name),
map((officeName: string) => officeName ? this.filterOfficeAutocompleteData(officeName) : this.officeData)
);
this.filteredOfficeData = this.officeName.valueChanges.pipe(
startWith(''),
map((office: any) => (typeof office === 'string' ? office : office.name)),
map((officeName: string) => (officeName ? this.filterOfficeAutocompleteData(officeName) : this.officeData))
);
}
/**
* Sets filtered gl accounts for autocomplete.
*/
setFilteredGlAccounts() {
this.filteredGLAccountData = this.glAccount.valueChanges
.pipe(
startWith(''),
map((glAccount: any) => typeof glAccount === 'string' ? glAccount : glAccount.name + ' (' + glAccount.glCode + ')'),
map((glAccount: string) => glAccount ? this.filterGLAccountAutocompleteData(glAccount) : this.glAccountData)
);
this.filteredGLAccountData = this.glAccount.valueChanges.pipe(
startWith(''),
map((glAccount: any) =>
typeof glAccount === 'string' ? glAccount : glAccount.name + ' (' + glAccount.glCode + ')'
),
map((glAccount: string) => (glAccount ? this.filterGLAccountAutocompleteData(glAccount) : this.glAccountData))
);
}
/**
@@ -308,7 +332,9 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
* @returns {any} Filtered gl accounts.
*/
private filterGLAccountAutocompleteData(glAccount: string): any {
return this.glAccountData.filter((option: any) => (option.name + ' (' + option.glCode + ')').toLowerCase().includes(glAccount.toLowerCase()));
return this.glAccountData.filter((option: any) =>
(option.name + ' (' + option.glCode + ')').toLowerCase().includes(glAccount.toLowerCase())
);
}
/**
@@ -316,6 +342,12 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
*/
getJournalEntries() {
this.dataSource = new JournalEntriesDataSource(this.accountingService);
this.dataSource.getJournalEntries(this.filterJournalEntriesBy, this.sort.active, this.sort.direction, this.paginator.pageIndex, this.paginator.pageSize);
this.dataSource.getJournalEntries(
this.filterJournalEntriesBy,
this.sort.active,
this.sort.direction,
this.paginator.pageIndex,
this.paginator.pageSize
);
}
}