diff --git a/src/app/accounting/accounting-routing.module.ts b/src/app/accounting/accounting-routing.module.ts index e4416f9cb..820dbaa18 100644 --- a/src/app/accounting/accounting-routing.module.ts +++ b/src/app/accounting/accounting-routing.module.ts @@ -2,6 +2,7 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { Route, extract } from '../core'; + import { AccountingComponent } from './accounting.component'; import { FrequentPostingsComponent } from './frequent-postings/frequent-postings.component'; import { ViewTransactionComponent } from './view-transaction/view-transaction.component'; @@ -11,6 +12,9 @@ import { FinancialActivityMappingsComponent } from './financial-activity-mapping import { CreateFinancialActivityMappingComponent } from './financial-activity-mappings/create-financial-activity-mapping/create-financial-activity-mapping.component'; import { ViewFinancialActivityMappingComponent } from './financial-activity-mappings/view-financial-activity-mapping/view-financial-activity-mapping.component'; import { EditFinancialActivityMappingComponent } from './financial-activity-mappings/edit-financial-activity-mapping/edit-financial-activity-mapping.component'; +import { ChartOfAccountsComponent } from './chart-of-accounts/chart-of-accounts.component'; + +import { ChartOfAccountsResolver } from './chart-of-accounts/chart-of-accounts.resolver'; const routes: Routes = [ Route.withShell([ @@ -77,6 +81,14 @@ const routes: Routes = [ ] } ] + }, + { + path: 'chart-of-accounts', + component: ChartOfAccountsComponent, + data: { title: extract('Chart of Accounts'), breadcrumb: 'Chart of Accounts' }, + resolve: { + glAccountData: ChartOfAccountsResolver + } } ] } @@ -86,6 +98,6 @@ const routes: Routes = [ @NgModule({ imports: [RouterModule.forChild(routes)], exports: [RouterModule], - providers: [] + providers: [ChartOfAccountsResolver] }) export class AccountingRoutingModule { } diff --git a/src/app/accounting/accounting.component.html b/src/app/accounting/accounting.component.html index d9e694bd3..7c210baee 100644 --- a/src/app/accounting/accounting.component.html +++ b/src/app/accounting/accounting.component.html @@ -46,11 +46,9 @@ - + device_hub - - Chart of Accounts - +

Chart of Accounts

List of accounts used by the organisation

diff --git a/src/app/accounting/accounting.module.ts b/src/app/accounting/accounting.module.ts index 0c40c79ca..5fb733c8c 100644 --- a/src/app/accounting/accounting.module.ts +++ b/src/app/accounting/accounting.module.ts @@ -15,6 +15,7 @@ import { FinancialActivityMappingsComponent } from './financial-activity-mapping import { CreateFinancialActivityMappingComponent } from './financial-activity-mappings/create-financial-activity-mapping/create-financial-activity-mapping.component'; import { ViewFinancialActivityMappingComponent } from './financial-activity-mappings/view-financial-activity-mapping/view-financial-activity-mapping.component'; import { EditFinancialActivityMappingComponent } from './financial-activity-mappings/edit-financial-activity-mapping/edit-financial-activity-mapping.component'; +import { ChartOfAccountsComponent } from './chart-of-accounts/chart-of-accounts.component'; @NgModule({ imports: [ @@ -35,7 +36,8 @@ import { EditFinancialActivityMappingComponent } from './financial-activity-mapp FinancialActivityMappingsComponent, CreateFinancialActivityMappingComponent, ViewFinancialActivityMappingComponent, - EditFinancialActivityMappingComponent + EditFinancialActivityMappingComponent, + ChartOfAccountsComponent ], entryComponents: [ RevertTransactionComponent, diff --git a/src/app/accounting/accounting.service.ts b/src/app/accounting/accounting.service.ts index 2072df0f1..a08e5bf18 100644 --- a/src/app/accounting/accounting.service.ts +++ b/src/app/accounting/accounting.service.ts @@ -96,4 +96,8 @@ export class AccountingService { return this.http.delete(`/financialactivityaccounts/${financialActivityAccountId}`); } + getChartOfAccounts() { + return this.http.get('/glaccounts'); + } + } diff --git a/src/app/accounting/chart-of-accounts/chart-of-accounts.component.html b/src/app/accounting/chart-of-accounts/chart-of-accounts.component.html new file mode 100644 index 000000000..1d3962a84 --- /dev/null +++ b/src/app/accounting/chart-of-accounts/chart-of-accounts.component.html @@ -0,0 +1,85 @@ +
+ + + list + + + device_hub + + + +
+ + + + +
+ +
+ + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Account {{ glAccount.name }} GL Code {{ glAccount.glCode }} Type {{ glAccount.type.value }} Disabled +
+ lens +
+
Manual Entries Allowed + check_circle + cancel + Used as {{ glAccount.usage.value }}
+ + + +
+ +
+ + + + +
+ + TREE VIEW + +
diff --git a/src/app/accounting/chart-of-accounts/chart-of-accounts.component.scss b/src/app/accounting/chart-of-accounts/chart-of-accounts.component.scss new file mode 100644 index 000000000..b209ba200 --- /dev/null +++ b/src/app/accounting/chart-of-accounts/chart-of-accounts.component.scss @@ -0,0 +1,19 @@ +table { + width: 100%; +} + +.disabled { + color: red; +} + +.enabled { + color: green; +} + +.manual-entries-allowed { + color: green; +} + +.manual-entries-not-allowed { + color: red; +} diff --git a/src/app/accounting/chart-of-accounts/chart-of-accounts.component.spec.ts b/src/app/accounting/chart-of-accounts/chart-of-accounts.component.spec.ts new file mode 100644 index 000000000..226cb278c --- /dev/null +++ b/src/app/accounting/chart-of-accounts/chart-of-accounts.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ChartOfAccountsComponent } from './chart-of-accounts.component'; + +describe('ChartOfAccountsComponent', () => { + let component: ChartOfAccountsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ChartOfAccountsComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ChartOfAccountsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/accounting/chart-of-accounts/chart-of-accounts.component.ts b/src/app/accounting/chart-of-accounts/chart-of-accounts.component.ts new file mode 100644 index 000000000..68c781ce0 --- /dev/null +++ b/src/app/accounting/chart-of-accounts/chart-of-accounts.component.ts @@ -0,0 +1,52 @@ +import { Component, ViewChild, OnInit, AfterViewInit } from '@angular/core'; +import { MatPaginator, MatSort, MatTableDataSource } from '@angular/material'; +import { FormControl } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; + +@Component({ + selector: 'mifosx-chart-of-accounts', + templateUrl: './chart-of-accounts.component.html', + styleUrls: ['./chart-of-accounts.component.scss'] +}) +export class ChartOfAccountsComponent implements AfterViewInit, OnInit { + + viewGroup = new FormControl('listView'); + glAccountData: any; + + displayedColumns: string[] = ['name', 'glCode', 'glAccountType', 'disabled', 'manualEntriesAllowed', 'usedAs']; + tableDataSource: any; + + @ViewChild(MatPaginator) paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + + constructor(private route: ActivatedRoute) { + this.route.data.subscribe((data: { glAccountData: any }) => { + this.glAccountData = data.glAccountData; + }); + } + + ngOnInit() { + this.tableDataSource = new MatTableDataSource(this.glAccountData); + } + + ngAfterViewInit() { + 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]; + } + }; + this.tableDataSource.sort = this.sort; + } + + applyFilter(filterValue: string) { + this.tableDataSource.filter = filterValue.trim().toLowerCase(); + } + + viewGLAccount(glAccount: any) { + console.log(glAccount); + } + +} diff --git a/src/app/accounting/chart-of-accounts/chart-of-accounts.resolver.ts b/src/app/accounting/chart-of-accounts/chart-of-accounts.resolver.ts new file mode 100644 index 000000000..34a55cfbd --- /dev/null +++ b/src/app/accounting/chart-of-accounts/chart-of-accounts.resolver.ts @@ -0,0 +1,16 @@ +import { Injectable } from '@angular/core'; +import { Resolve } from '@angular/router'; + +import { Observable } from 'rxjs'; +import { AccountingService } from '../accounting.service'; + +@Injectable() +export class ChartOfAccountsResolver implements Resolve { + + constructor(private accountingService: AccountingService) {} + + resolve(): Observable { + return this.accountingService.getChartOfAccounts(); + } + +}