feat: add list view in chart of accounts component
Add list view for GL accounts in chart of accounts component.
This commit is contained in:
@@ -2,6 +2,7 @@ import { NgModule } from '@angular/core';
|
|||||||
import { Routes, RouterModule } from '@angular/router';
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
|
|
||||||
import { Route, extract } from '../core';
|
import { Route, extract } from '../core';
|
||||||
|
|
||||||
import { AccountingComponent } from './accounting.component';
|
import { AccountingComponent } from './accounting.component';
|
||||||
import { FrequentPostingsComponent } from './frequent-postings/frequent-postings.component';
|
import { FrequentPostingsComponent } from './frequent-postings/frequent-postings.component';
|
||||||
import { ViewTransactionComponent } from './view-transaction/view-transaction.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 { 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 { 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 { 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 = [
|
const routes: Routes = [
|
||||||
Route.withShell([
|
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({
|
@NgModule({
|
||||||
imports: [RouterModule.forChild(routes)],
|
imports: [RouterModule.forChild(routes)],
|
||||||
exports: [RouterModule],
|
exports: [RouterModule],
|
||||||
providers: []
|
providers: [ChartOfAccountsResolver]
|
||||||
})
|
})
|
||||||
export class AccountingRoutingModule { }
|
export class AccountingRoutingModule { }
|
||||||
|
|||||||
@@ -46,11 +46,9 @@
|
|||||||
|
|
||||||
<mat-nav-list>
|
<mat-nav-list>
|
||||||
|
|
||||||
<mat-list-item>
|
<mat-list-item [routerLink]="['/accounting/chart-of-accounts']">
|
||||||
<mat-icon matListIcon>device_hub</mat-icon>
|
<mat-icon matListIcon>device_hub</mat-icon>
|
||||||
<a matLine href="https://www.google.com">
|
<h4 matLine>Chart of Accounts</h4>
|
||||||
Chart of Accounts
|
|
||||||
</a>
|
|
||||||
<p matLine>List of accounts used by the organisation</p>
|
<p matLine>List of accounts used by the organisation</p>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
|
|
||||||
|
|||||||
@@ -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 { 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 { 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 { 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({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -35,7 +36,8 @@ import { EditFinancialActivityMappingComponent } from './financial-activity-mapp
|
|||||||
FinancialActivityMappingsComponent,
|
FinancialActivityMappingsComponent,
|
||||||
CreateFinancialActivityMappingComponent,
|
CreateFinancialActivityMappingComponent,
|
||||||
ViewFinancialActivityMappingComponent,
|
ViewFinancialActivityMappingComponent,
|
||||||
EditFinancialActivityMappingComponent
|
EditFinancialActivityMappingComponent,
|
||||||
|
ChartOfAccountsComponent
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
RevertTransactionComponent,
|
RevertTransactionComponent,
|
||||||
|
|||||||
@@ -96,4 +96,8 @@ export class AccountingService {
|
|||||||
return this.http.delete(`/financialactivityaccounts/${financialActivityAccountId}`);
|
return this.http.delete(`/financialactivityaccounts/${financialActivityAccountId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getChartOfAccounts() {
|
||||||
|
return this.http.get('/glaccounts');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
<div class="container m-b-20" fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px">
|
||||||
|
<mat-button-toggle-group [formControl]="viewGroup">
|
||||||
|
<mat-button-toggle value="listView">
|
||||||
|
<mat-icon>list</mat-icon>
|
||||||
|
</mat-button-toggle>
|
||||||
|
<mat-button-toggle value="treeView">
|
||||||
|
<mat-icon>device_hub</mat-icon>
|
||||||
|
</mat-button-toggle>
|
||||||
|
</mat-button-toggle-group>
|
||||||
|
<button mat-raised-button color="primary">
|
||||||
|
<mat-icon>add</mat-icon> Add Account
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- List View -->
|
||||||
|
|
||||||
|
<div class="container" *ngIf="viewGroup.value === 'listView'">
|
||||||
|
|
||||||
|
<div fxLayout="row" fxLayoutGap="20px">
|
||||||
|
<mat-form-field fxFlex>
|
||||||
|
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mat-elevation-z8">
|
||||||
|
|
||||||
|
<table mat-table [dataSource]="tableDataSource" matSort>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="name">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Account </th>
|
||||||
|
<td mat-cell *matCellDef="let glAccount"> {{ glAccount.name }} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="glCode">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> GL Code </th>
|
||||||
|
<td mat-cell *matCellDef="let glAccount"> {{ glAccount.glCode }} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="glAccountType">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Type </th>
|
||||||
|
<td mat-cell *matCellDef="let glAccount"> {{ glAccount.type.value }} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="disabled">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Disabled </th>
|
||||||
|
<td mat-cell *matCellDef="let glAccount">
|
||||||
|
<div [className]="glAccount.disabled === true ? 'disabled' : 'enabled'">
|
||||||
|
<mat-icon matTooltip="{{ glAccount.disabled === true ? 'Disabled' : 'Enabled' }}" matTooltipPosition="right">lens</mat-icon>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="manualEntriesAllowed">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Manual Entries Allowed </th>
|
||||||
|
<td mat-cell *matCellDef="let glAccount">
|
||||||
|
<mat-icon *ngIf="glAccount.manualEntriesAllowed" class="manual-entries-allowed" matTooltip="Allowed" matTooltipPosition="right">check_circle</mat-icon>
|
||||||
|
<mat-icon *ngIf="!glAccount.manualEntriesAllowed" class="manual-entries-not-allowed" matTooltip="Not Allowed" matTooltipPosition="right">cancel</mat-icon>
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="usedAs">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Used as </th>
|
||||||
|
<td mat-cell *matCellDef="let glAccount"> {{ glAccount.usage.value }} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="viewGLAccount(row)" class="select"></tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Tree View -->
|
||||||
|
|
||||||
|
<div class="container" *ngIf="viewGroup.value === 'treeView'">
|
||||||
|
|
||||||
|
TREE VIEW
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.disabled {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enabled {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.manual-entries-allowed {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.manual-entries-not-allowed {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
@@ -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<ChartOfAccountsComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ ChartOfAccountsComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ChartOfAccountsComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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<Object> {
|
||||||
|
|
||||||
|
constructor(private accountingService: AccountingService) {}
|
||||||
|
|
||||||
|
resolve(): Observable<any> {
|
||||||
|
return this.accountingService.getChartOfAccounts();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user