feat(accounting): add closing entries component
Add closing entries component to view accounting closures.
This commit is contained in:
@@ -15,11 +15,14 @@ import { EditFinancialActivityMappingComponent } from './financial-activity-mapp
|
||||
import { ChartOfAccountsComponent } from './chart-of-accounts/chart-of-accounts.component';
|
||||
|
||||
import { ChartOfAccountsResolver } from './chart-of-accounts/chart-of-accounts.resolver';
|
||||
|
||||
import { CreateGlAccountComponent } from './chart-of-accounts/create-gl-account/create-gl-account.component';
|
||||
import { ViewGlAccountComponent } from './chart-of-accounts/view-gl-account/view-gl-account.component';
|
||||
import { ViewGlAccountResolver } from './chart-of-accounts/view-gl-account/view-gl-account.resolver';
|
||||
import { EditGlAccountComponent } from './chart-of-accounts/edit-gl-account/edit-gl-account.component';
|
||||
|
||||
import { ClosingEntriesComponent } from './closing-entries/closing-entries.component';
|
||||
|
||||
const routes: Routes = [
|
||||
Route.withShell([
|
||||
{
|
||||
@@ -89,6 +92,9 @@ const routes: Routes = [
|
||||
{
|
||||
path: 'chart-of-accounts',
|
||||
data: { title: extract('Chart of Accounts'), breadcrumb: 'Chart of Accounts' },
|
||||
resolve: {
|
||||
glAccountData: ChartOfAccountsResolver
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
@@ -122,6 +128,11 @@ const routes: Routes = [
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'closing-entries',
|
||||
component: ClosingEntriesComponent,
|
||||
data: { title: extract('Accounting Closures'), breadcrumb: 'Closing Entries' }
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -52,11 +52,9 @@
|
||||
<p matLine>List of accounts used by the organisation</p>
|
||||
</mat-list-item>
|
||||
|
||||
<mat-list-item>
|
||||
<mat-list-item [routerLink]="['/accounting/closing-entries']">
|
||||
<mat-icon matListIcon>archive</mat-icon>
|
||||
<a matLine href="https://www.google.com">
|
||||
Closing Entries
|
||||
</a>
|
||||
<h4 matLine>Closing Entries</h4>
|
||||
<p matLine>Journal entries made at the end of accounting period</p>
|
||||
</mat-list-item>
|
||||
|
||||
|
||||
@@ -16,9 +16,11 @@ import { CreateFinancialActivityMappingComponent } from './financial-activity-ma
|
||||
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 { CreateGlAccountComponent } from './chart-of-accounts/create-gl-account/create-gl-account.component';
|
||||
import { ViewGlAccountComponent } from './chart-of-accounts/view-gl-account/view-gl-account.component';
|
||||
import { EditGlAccountComponent } from './chart-of-accounts/edit-gl-account/edit-gl-account.component';
|
||||
import { ClosingEntriesComponent } from './closing-entries/closing-entries.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -43,7 +45,8 @@ import { EditGlAccountComponent } from './chart-of-accounts/edit-gl-account/edit
|
||||
ChartOfAccountsComponent,
|
||||
CreateGlAccountComponent,
|
||||
ViewGlAccountComponent,
|
||||
EditGlAccountComponent
|
||||
EditGlAccountComponent,
|
||||
ClosingEntriesComponent
|
||||
],
|
||||
entryComponents: [
|
||||
RevertTransactionComponent,
|
||||
|
||||
@@ -121,4 +121,8 @@ export class AccountingService {
|
||||
return this.http.delete(`/glaccounts/${glAccountId}`);
|
||||
}
|
||||
|
||||
getAccountingClosures() {
|
||||
return this.http.get('/glclosures');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<div class="container m-b-20" fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px">
|
||||
<button mat-raised-button color="primary">
|
||||
<mat-icon>add</mat-icon> Create Closure
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="container" fxLayout="row wrap" fxLayoutGap="2%" fxLayout.lt-md="column">
|
||||
<mat-form-field fxFlex>
|
||||
<input matInput placeholder="Office Name" [formControl]="officeName" [matAutocomplete]="officeNameAutocomplete">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<!-- Autocomplete data -->
|
||||
<mat-autocomplete autoActiveFirstOption #officeNameAutocomplete="matAutocomplete">
|
||||
<mat-option *ngFor="let office of filteredOfficeData | async" [value]="office.name">
|
||||
{{ office.name }}
|
||||
</mat-option>
|
||||
</mat-autocomplete>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="mat-elevation-z8">
|
||||
|
||||
<table mat-table [dataSource]="dataSource" matSort>
|
||||
|
||||
<ng-container matColumnDef="officeName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Office </th>
|
||||
<td mat-cell *matCellDef="let glAccountClosure"> {{ glAccountClosure.officeName }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="closingDate">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Closure Date </th>
|
||||
<td mat-cell *matCellDef="let glAccountClosure"> {{ glAccountClosure.closingDate }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="comments">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Comments </th>
|
||||
<td mat-cell *matCellDef="let glAccountClosure"> {{ glAccountClosure.comments }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="createdByUsername">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Created By </th>
|
||||
<td mat-cell *matCellDef="let glAccountClosure">{{ glAccountClosure.createdByUsername }}</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ClosingEntriesComponent } from './closing-entries.component';
|
||||
|
||||
describe('ClosingEntriesComponent', () => {
|
||||
let component: ClosingEntriesComponent;
|
||||
let fixture: ComponentFixture<ClosingEntriesComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ClosingEntriesComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ClosingEntriesComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,63 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatPaginator, MatSort, MatTableDataSource } from '@angular/material';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { startWith, map, tap } from 'rxjs/operators';
|
||||
|
||||
import { AccountingService } from '../accounting.service';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-closing-entries',
|
||||
templateUrl: './closing-entries.component.html',
|
||||
styleUrls: ['./closing-entries.component.scss']
|
||||
})
|
||||
export class ClosingEntriesComponent implements OnInit {
|
||||
|
||||
displayedColumns: string[] = ['officeName', 'closingDate', 'comments', 'createdByUsername'];
|
||||
dataSource: any;
|
||||
|
||||
officeName = new FormControl();
|
||||
officeData: any;
|
||||
filteredOfficeData: any;
|
||||
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
constructor(private accountingService: AccountingService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.getOffices();
|
||||
this.applyFilter();
|
||||
this.getAccountingClosures();
|
||||
}
|
||||
|
||||
applyFilter() {
|
||||
this.officeName.valueChanges.subscribe((filterValue: string) => {
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
});
|
||||
}
|
||||
|
||||
getAccountingClosures() {
|
||||
this.accountingService.getAccountingClosures().subscribe((glAccountClosureData: any) => {
|
||||
this.dataSource = new MatTableDataSource(glAccountClosureData);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
});
|
||||
}
|
||||
|
||||
getOffices() {
|
||||
this.accountingService.getOffices().subscribe(officeData => {
|
||||
this.officeData = officeData;
|
||||
this.filteredOfficeData = this.officeName.valueChanges
|
||||
.pipe(
|
||||
startWith(''),
|
||||
map((office: any) => typeof office === 'string' ? office : office.name),
|
||||
map((officeName: string) => officeName ? this.filterOfficeAutocompleteData(this.officeData, officeName) : this.officeData)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private filterOfficeAutocompleteData(officeData: any, officeName: string): any {
|
||||
return officeData.filter((office: any) => office.name.toLowerCase().includes(officeName.toLowerCase()));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user