forked from xurror/web-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(accounting): search journal entry component
Add search journal entry component.
- Loading branch information
1 parent
621a2b1
commit 1a164c1
Showing
8 changed files
with
249 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
src/app/accounting/search-journal-entry/search-journal-entry.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<div class="container" fxLayout="row wrap" fxLayoutGap="2%"> | ||
<mat-form-field fxFlex="31%"> | ||
<mat-select placeholder="Office" [formControl]="officeName" (selectionChange)="applyFilter($event.value, 'officeName')"> | ||
<mat-option *ngFor="let office of officeData" [value]="office.name"> | ||
{{ office.name }} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
<mat-form-field fxFlex="31%"> | ||
<mat-select placeholder="Affected GL Entry" [formControl]="glAccountCode" (selectionChange)="applyFilter($event.value, 'glAccountCode')"> | ||
<mat-option *ngFor="let affectedGLEntryDebit of glAccountData" [value]="affectedGLEntryDebit.glCode"> | ||
{{ affectedGLEntryDebit.name + ' (' + affectedGLEntryDebit.glCode + ')' }} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
<mat-form-field fxFlex="31%"> | ||
<mat-select placeholder="Filter" [formControl]="filter" (selectionChange)="applyFilter($event.value, 'filter')"> | ||
<mat-option *ngFor="let filter of filterData" [value]="filter.value"> | ||
{{ filter.option }} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
<mat-form-field fxFlex="31%"> | ||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="transactionDateFromPicker" placeholder="Transaction Date From" [formControl]="transactionDateFrom"> | ||
<mat-datepicker-toggle matSuffix [for]="transactionDateFromPicker"></mat-datepicker-toggle> | ||
<mat-datepicker #transactionDateFromPicker></mat-datepicker> | ||
</mat-form-field> | ||
<mat-form-field fxFlex="31%"> | ||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="transactionDateToPicker" placeholder="Transaction Date To" [formControl]="transactionDateTo"> | ||
<mat-datepicker-toggle matSuffix [for]="transactionDateToPicker"></mat-datepicker-toggle> | ||
<mat-datepicker #transactionDateToPicker></mat-datepicker> | ||
</mat-form-field> | ||
<mat-form-field fxFlex="31%"> | ||
<input matInput placeholder="Transaction ID" [formControl]="transactionId" (keyup)="applyFilter($event.target.value, 'transactionId')"> | ||
</mat-form-field> | ||
<!-- <mat-form-field fxFlex="33%"> | ||
<mat-select placeholder="Transaction ID" [formControl]="transactionId"> | ||
<mat-option *ngFor="let transaction of dataSource?.data" [value]="transaction.transactionId"> | ||
{{ transaction.transactionId }} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> --> | ||
</div> | ||
|
||
<div class="mat-elevation-z8 container"> | ||
|
||
<table mat-table [dataSource]="dataSource" matSort> | ||
|
||
<ng-container matColumnDef="id"> | ||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Entry ID </th> | ||
<td mat-cell *matCellDef="let transaction"> {{ transaction.id }} </td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="officeName"> | ||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Office </th> | ||
<td mat-cell *matCellDef="let transaction"> {{ transaction.officeName }} </td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="transactionId"> | ||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Transaction ID </th> | ||
<td mat-cell *matCellDef="let transaction"> {{ transaction.transactionId }} </td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="transactionDate"> | ||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Transaction Date </th> | ||
<td mat-cell *matCellDef="let transaction"> {{ transaction.transactionDate }} </td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="glAccountType"> | ||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Type </th> | ||
<td mat-cell *matCellDef="let transaction"> {{ transaction.glAccountType.value }} </td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="createdByUserName"> | ||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Created by </th> | ||
<td mat-cell *matCellDef="let transaction"> {{ transaction.createdByUserName }} </td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="glAccountCode"> | ||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Account Code </th> | ||
<td mat-cell *matCellDef="let transaction"> {{ transaction.glAccountCode }} </td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="glAccountName"> | ||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Account Name </th> | ||
<td mat-cell *matCellDef="let transaction"> {{ transaction.glAccountName }} </td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="debit"> | ||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Debit </th> | ||
<td mat-cell *matCellDef="let transaction"><span *ngIf="transaction.entryType.value === 'DEBIT'"> {{ (transaction.currency.displaySymbol || transaction.currency.code) + ' ' + transaction.amount }} </span></td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="credit"> | ||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Credit </th> | ||
<td mat-cell *matCellDef="let transaction"><span *ngIf="transaction.entryType.value === 'CREDIT'"> {{ (transaction.currency.displaySymbol || transaction.currency.code) + ' ' + transaction.amount }} </span></td> | ||
</ng-container> | ||
|
||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> | ||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="viewTransaction(row)" class="select"></tr> | ||
|
||
</table> | ||
|
||
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator> | ||
|
||
</div> |
3 changes: 3 additions & 0 deletions
3
src/app/accounting/search-journal-entry/search-journal-entry.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table { | ||
width: 100%; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/app/accounting/search-journal-entry/search-journal-entry.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { SearchJournalEntryComponent } from './search-journal-entry.component'; | ||
|
||
describe('SearchJournalEntryComponent', () => { | ||
let component: SearchJournalEntryComponent; | ||
let fixture: ComponentFixture<SearchJournalEntryComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ SearchJournalEntryComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(SearchJournalEntryComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
100 changes: 100 additions & 0 deletions
100
src/app/accounting/search-journal-entry/search-journal-entry.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { Component, OnInit, ViewChild } from '@angular/core'; | ||
import { MatPaginator, MatSort, MatTableDataSource } from '@angular/material'; | ||
import { FormControl } from '@angular/forms'; | ||
import { Router } from '@angular/router'; | ||
|
||
import { AccountingService } from '../accounting.service'; | ||
|
||
@Component({ | ||
selector: 'mifosx-search-journal-entry', | ||
templateUrl: './search-journal-entry.component.html', | ||
styleUrls: ['./search-journal-entry.component.scss'] | ||
}) | ||
export class SearchJournalEntryComponent implements OnInit { | ||
|
||
officeName = new FormControl(); | ||
glAccountCode = new FormControl(); | ||
transactionDateFrom = new FormControl(new Date(2000, 0, 1)); | ||
transactionDateTo = new FormControl(new Date()); | ||
transactionId = new FormControl(); | ||
minDate = new Date(2000, 0, 1); | ||
maxDate = new Date(); | ||
filter = new FormControl(''); | ||
displayedColumns: string[] = ['id', 'officeName', 'transactionId', 'transactionDate', 'glAccountType', 'createdByUserName', 'glAccountCode', 'glAccountName', 'debit', 'credit']; | ||
dataSource: any; | ||
officeData: any; | ||
glAccountData: any; | ||
filterData = [ | ||
{ | ||
option: 'All', | ||
value: '' | ||
}, | ||
{ | ||
option: 'Manual Entries', | ||
value: true | ||
}, | ||
{ | ||
option: 'System Entries', | ||
value: false | ||
} | ||
]; | ||
filterValue: any = { officeName: '', glAccountCode: '', filter: '', transactionId: '' }; | ||
|
||
@ViewChild(MatPaginator) paginator: MatPaginator; | ||
@ViewChild(MatSort) sort: MatSort; | ||
|
||
constructor(private accountingService: AccountingService, | ||
private router: Router) { } | ||
|
||
ngOnInit() { | ||
this.getOffices(); | ||
this.getGlAccounts(); | ||
this.getJournalEntries(); | ||
} | ||
|
||
getJournalEntries() { | ||
this.accountingService.getJournalEntries().subscribe((journalEntryData: any) => { | ||
this.dataSource = new MatTableDataSource(journalEntryData.pageItems); | ||
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]; | ||
} | ||
}; | ||
this.dataSource.sort = this.sort; | ||
this.dataSource.filterPredicate = this.filterPredicate; | ||
}); | ||
} | ||
|
||
filterPredicate(data: any, filterValue: string) { | ||
return data.officeName.indexOf(filterValue['officeName']) != -1 | ||
&& data.glAccountCode.indexOf(filterValue['glAccountCode']) != -1 | ||
&& data.manualEntry.toString().indexOf(filterValue['filter']) != -1 | ||
&& data.transactionId.indexOf(filterValue['transactionId']) != -1; | ||
} | ||
|
||
applyFilter(filterValue: string, property: string) { | ||
this.filterValue[property] = filterValue; | ||
this.dataSource.filter = this.filterValue; | ||
} | ||
|
||
getOffices() { | ||
this.accountingService.getOffices().subscribe(officeData => { | ||
this.officeData = officeData; | ||
}); | ||
} | ||
|
||
getGlAccounts() { | ||
this.accountingService.getGlAccounts().subscribe(glAccountData => { | ||
this.glAccountData = glAccountData; | ||
}); | ||
} | ||
|
||
viewTransaction(journalEntry: any) { | ||
this.router.navigate(['/accounting/transactions/view', journalEntry.transactionId]); | ||
} | ||
|
||
} |