diff --git a/src/app/organization/organization-routing.module.ts b/src/app/organization/organization-routing.module.ts index 7b2a27036..2e871634c 100644 --- a/src/app/organization/organization-routing.module.ts +++ b/src/app/organization/organization-routing.module.ts @@ -42,6 +42,7 @@ import { ViewCampaignComponent } from './sms-campaigns/view-campaign/view-campai import { ManageFundsComponent } from './manage-funds/manage-funds.component'; import { ManageCurrenciesComponent } from './currencies/manage-currencies/manage-currencies.component'; import { CashiersComponent } from './tellers/cashiers/cashiers.component'; +import { TransactionsComponent } from './tellers/transactions/transactions.component'; /** Custom Resolvers */ import { LoanProvisioningCriteriaResolver } from './loan-provisioning-criteria/loan-provisioning-criteria.resolver'; @@ -339,11 +340,24 @@ const routes: Routes = [ }, { path: ':id', - component: ViewCashierComponent, - data: { title: extract('View Cashier'), breadcrumb: 'View Cashier', routeParamBreadcrumb: 'id' }, - resolve: { - cashier: CashierResolver - } + data: { title: extract('View Cashier'), routeParamBreadcrumb: 'id' }, + children: [ + { + path: '', + component: ViewCashierComponent, + resolve: { + cashier: CashierResolver + } + }, + { + path: 'transactions', + data: { title: extract('Cashier Transactions'), breadcrumb: 'Transactions', routeParamBreadcrumb: false }, + component: TransactionsComponent, + resolve: { + currencies: CurrenciesResolver + } + } + ] } ] } diff --git a/src/app/organization/organization.module.ts b/src/app/organization/organization.module.ts index cec7a6419..968d474d1 100644 --- a/src/app/organization/organization.module.ts +++ b/src/app/organization/organization.module.ts @@ -45,6 +45,7 @@ import { ViewCampaignComponent } from './sms-campaigns/view-campaign/view-campai import { ManageFundsComponent } from './manage-funds/manage-funds.component'; import { ManageCurrenciesComponent } from './currencies/manage-currencies/manage-currencies.component'; import { CashiersComponent } from './tellers/cashiers/cashiers.component'; +import { TransactionsComponent } from './tellers/transactions/transactions.component'; /** * Organization Module @@ -95,7 +96,8 @@ import { CashiersComponent } from './tellers/cashiers/cashiers.component'; ViewCampaignComponent, ManageFundsComponent, ManageCurrenciesComponent, - CashiersComponent + CashiersComponent, + TransactionsComponent ] }) export class OrganizationModule { } diff --git a/src/app/organization/organization.service.ts b/src/app/organization/organization.service.ts index 26b0d4aa4..457b1d849 100644 --- a/src/app/organization/organization.service.ts +++ b/src/app/organization/organization.service.ts @@ -273,6 +273,17 @@ export class OrganizationService { return this.http.get(`/tellers/${tellerId}/cashiers/${cashierId}`); } + /** + * @param {string} tellerId Teller Id + * @param {string} cashierId Cashier Id + * @param {string} currencyCode Currency Code + * @returns {Observable} + */ + getCashierSummaryAndTransactions(tellerId: string, cashierId: string, currencyCode: string): Observable { + const httpParams = new HttpParams().set('currencyCode', currencyCode); + return this.http.get(`/tellers/${tellerId}/cashiers/${cashierId}/summaryandtransactions`, { params: httpParams }); + } + /** * @param {string} tellerId Teller ID of teller to be deleted. * @returns {Observable} diff --git a/src/app/organization/tellers/cashiers/cashiers.component.html b/src/app/organization/tellers/cashiers/cashiers.component.html index ce26bb9a7..94cab6bde 100644 --- a/src/app/organization/tellers/cashiers/cashiers.component.html +++ b/src/app/organization/tellers/cashiers/cashiers.component.html @@ -44,7 +44,8 @@ - diff --git a/src/app/organization/tellers/cashiers/cashiers.component.ts b/src/app/organization/tellers/cashiers/cashiers.component.ts index 6b93cb9aa..1af15e516 100644 --- a/src/app/organization/tellers/cashiers/cashiers.component.ts +++ b/src/app/organization/tellers/cashiers/cashiers.component.ts @@ -32,7 +32,6 @@ export class CashiersComponent implements OnInit { constructor(private route: ActivatedRoute) { this.route.data.subscribe(( data: { cashiersData: any }) => { this.cashiersData = data.cashiersData.cashiers; - console.log(this.cashiersData); }); } @@ -60,4 +59,12 @@ export class CashiersComponent implements OnInit { this.dataSource.sort = this.sort; } + /** + * Stops the propagation to view pages. + * @param $event Mouse Event + */ + routeEdit($event: MouseEvent) { + $event.stopPropagation(); + } + } diff --git a/src/app/organization/tellers/transactions/transactions.component.html b/src/app/organization/tellers/transactions/transactions.component.html new file mode 100644 index 000000000..0cb379383 --- /dev/null +++ b/src/app/organization/tellers/transactions/transactions.component.html @@ -0,0 +1,127 @@ +
+ + +
+ +
+ + + + + +
+ +
+ Branch +
+ +
+ {{ cashierData.officeName }} +
+ +
+ Teller +
+ +
+ {{ cashierData.tellerName }} +
+ +
+ Cashier +
+ +
+ {{ cashierData.cashierName }} +
+ +
+ Net Cash +
+ +
+ {{ cashierData.netCash | number }} [{{currencySelector.value}}] +
+ +
+ +
+ +
+ +
+ +
+ + + +
+ + + Filter + + + + + Select Currency + + + {{ currency.name }} + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Date {{ transaction.txnDate | date }} Transactions {{ transaction.txnType.value }} Allocation ({{cashierData.sumCashAllocation | number}}) {{ transaction.txnType.value === "Allocate Cash" ? (transaction.txnAmount | number) : '-' }} Cash In ({{cashierData.sumInwardCash | number}}) {{ transaction.txnType.value === "Cash In" ? (transaction.txnAmount | number) : '-' }} Cash Out ({{cashierData.sumOutwardCash | number}}) {{ transaction.txnType.value === "Cash Out" ? (transaction.txnAmount | number) : '-' }} Settlement ({{cashierData.sumCashSettlement | number}}) {{ transaction.txnType.value === "Settle Cash" ? (transaction.txnAmount | number) : '-' }}
+ + + +
+ +
+ +
diff --git a/src/app/organization/tellers/transactions/transactions.component.scss b/src/app/organization/tellers/transactions/transactions.component.scss new file mode 100644 index 000000000..6de1f0505 --- /dev/null +++ b/src/app/organization/tellers/transactions/transactions.component.scss @@ -0,0 +1,13 @@ +.content { + div { + line-height: 3rem; + + &.header { + font-weight: 500; + } + } +} + +table { + width: 100%; +} diff --git a/src/app/organization/tellers/transactions/transactions.component.spec.ts b/src/app/organization/tellers/transactions/transactions.component.spec.ts new file mode 100644 index 000000000..b7cf5cf65 --- /dev/null +++ b/src/app/organization/tellers/transactions/transactions.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TransactionsComponent } from './transactions.component'; + +describe('TransactionsComponent', () => { + let component: TransactionsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ TransactionsComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TransactionsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/organization/tellers/transactions/transactions.component.ts b/src/app/organization/tellers/transactions/transactions.component.ts new file mode 100644 index 000000000..1570c5f53 --- /dev/null +++ b/src/app/organization/tellers/transactions/transactions.component.ts @@ -0,0 +1,91 @@ +/** Angular Imports */ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { MatTableDataSource, MatSort, MatPaginator } from '@angular/material'; +import { ActivatedRoute } from '@angular/router'; +import { FormControl } from '@angular/forms'; + +/** Custom Services */ +import { OrganizationService } from 'app/organization/organization.service'; + +/** + * Cashier Transactions Component. + */ +@Component({ + selector: 'mifosx-transactions', + templateUrl: './transactions.component.html', + styleUrls: ['./transactions.component.scss'] +}) +export class TransactionsComponent implements OnInit { + + /** Currency selector. */ + currencySelector = new FormControl(); + /** Cashier Id */ + cashierId: any; + /** Teller Id */ + tellerId: any; + /** Cashier data. */ + cashierData: any; + /** Currencys data. */ + currencyData: any; + /** Columns to be displayed in transactions table. */ + displayedColumns: string[] = ['date', 'transactions', 'allocation', 'cashIn', 'cashOut', 'settlement']; + /** Data source for transactions table. */ + dataSource: MatTableDataSource; + + /** Paginator for transactions table. */ + @ViewChild(MatPaginator) paginator: MatPaginator; + /** Sorter for transactions table. */ + @ViewChild(MatSort) sort: MatSort; + + /** + * Retrieves the currencies data from `resolve`. + * @param {OrganizationService} organizationService Organization Service. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private organizationService: OrganizationService, + private route: ActivatedRoute) { + this.route.data.subscribe(( data: { currencies: any }) => { + this.currencyData = data.currencies.selectedCurrencyOptions; + }); + this.tellerId = this.route.parent.parent.parent.snapshot.params['id']; + this.cashierId = this.route.parent.snapshot.params['id']; + } + + /** + * Filters data in transactions table based on passed value. + * @param {string} filterValue Value to filter data. + */ + applyFilter(filterValue: string) { + this.dataSource.filter = filterValue.trim().toLowerCase(); + } + + /** + * Retrieves transactions data on changing currency. + */ + ngOnInit() { + this.onChangeCurrency(); + } + + /** + * Retrieves the transactions data on changing currency and sets the transactions table. + */ + onChangeCurrency() { + this.currencySelector.valueChanges.subscribe((currencyCode: any) => { + this.organizationService.getCashierSummaryAndTransactions(this.tellerId, this.cashierId, currencyCode) + .subscribe((response: any) => { + this.cashierData = response; + this.setTransactions(); + }); + }); + } + + /** + * Initializes the data source, paginator and sorter for transactions table. + */ + setTransactions() { + this.dataSource = new MatTableDataSource(this.cashierData.cashierTransactions.pageItems); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } + +} diff --git a/src/app/shared/icons.module.ts b/src/app/shared/icons.module.ts index df49cd91d..2cd6fa44b 100644 --- a/src/app/shared/icons.module.ts +++ b/src/app/shared/icons.module.ts @@ -90,7 +90,9 @@ import { faMoneyBill, faChartLine, faPen, - faFlag + faFlag, + faArrowUp, + faArrowDown } from '@fortawesome/free-solid-svg-icons'; /** Add icons to the library for convenient access in other components. */ @@ -180,7 +182,9 @@ library.add( faMoneyBill, faChartLine, faPen, - faFlag + faFlag, + faArrowUp, + faArrowDown ); /**