-<eg-title i18n-prefix prefix="Cash Reports"></eg-title>
<eg-staff-banner bannerText="Cash Reports" i18n-bannerText>
</eg-staff-banner>
-<div class="mb-5 text-center">
- <div>
- <div class="row col-lg-12 ml-auto mr-auto">
- <div class="input-group col-lg-3 ml-auto mr-auto">
- <div class="input-group-prepend col-lg-12">
- <div class="input-group-text" i18n>Start Date</div>
- <eg-date-select [initialDate]="today" (onChangeAsYmd)="onStartDateChange($event)"></eg-date-select>
- </div>
- </div>
- <div class="input-group col-lg-3 ml-auto mr-auto">
- <div class="input-group-prepend col-lg-12">
- <div class="input-group-text" i18n>End Date</div>
- <eg-date-select [initialDate]="today" (onChangeAsYmd)="onEndDateChange($event)"></eg-date-select>
- </div>
- </div>
- <div class="input-group col-lg-4">
- <div class="input-group-prepend col-lg-6 ml-auto mr-auto">
- <div class="input-group-text" i18n>View reports for</div>
- <eg-org-select [applyDefault]="true" [disableOrgs]="disabledOrgs" (onChange)="onOrgChange($event)"></eg-org-select>
- </div>
- <button class="btn btn-primary col-lg-2" (click)="searchForData(startDate, endDate)">Submit</button>
- </div>
+<div class="mb-5">
+ <div>
+ <div class="row">
+ <div class="input-group col-lg-3">
+ <div class="input-group-prepend">
+ <div class="input-group-text" i18n>Start Date</div>
+ <eg-date-select [initialDate]="today" (onChangeAsYmd)="onStartDateChange($event)"></eg-date-select>
</div>
+ </div>
+ <div class="input-group col-lg-3">
+ <div class="input-group-prepend">
+ <div class="input-group-text" i18n>End Date</div>
+ <eg-date-select [initialDate]="today" (onChangeAsYmd)="onEndDateChange($event)"></eg-date-select>
+ </div>
+ </div>
+ <div class="input-group col-lg-4">
+ <div class="input-group-prepend">
+ <div class="input-group-text" i18n>View reports for</div>
+ </div>
+ <eg-org-select [applyDefault]="true" [disableOrgs]="disabledOrgs" (onChange)="onOrgChange($event)"></eg-org-select>
+ </div>
+ <div class="col-lg-2">
+ <button class="btn btn-primary" (click)="searchForData(startDate, endDate)">Submit</button>
+ </div>
</div>
+ </div>
</div>
-<ngb-tabset [destroyOnHide]="false" (tabChange)="eraseUserGrid()">
- <ngb-tab title="Desk Payments">
- <ng-template ngbTabContent>
- <div class="mb-5">
- <div class="row">
- <div class="col-sm-2" i18n>Total Cash Payments</div>
- <div class="col-sm-10">{{deskTotals.formatted_cash_payment}}</div>
- </div>
- <div class="row">
- <div class="col-sm-2" i18n>Total Check Payments</div>
- <div class="col-sm-10">{{deskTotals.formatted_check_payment}}</div>
- </div>
- <div class="row">
- <div class="col-sm-2" i18n>Total Credit Card Payments</div>
- <div class="col-sm-10">{{deskTotals.formatted_credit_card_payment}}</div>
- </div>
- <eg-grid #deskPaymentGrid
- [disableSelect]="true"
- [disablePaging]="true"
- [dataSource]="deskPaymentDataSource"
- [sortable]="false">
- <eg-grid-column label="Workstation" name="workstation" [index]="true" i18n-label></eg-grid-column>
- <eg-grid-column label="Cash Payment" name="cash_payment" i18n-label></eg-grid-column>
- <eg-grid-column label="Check Payment" name="check_payment" i18n-label></eg-grid-column>
- <eg-grid-column label="Credit Card Payment" name="credit_card_payment" i18n-label></eg-grid-column>
- </eg-grid>
+
+<ul ngbNav #cashReportsNav="ngbNav" class="nav-tabs"
+ [destroyOnHide]="false" activeId="deskPayments" (navChange)="eraseUserGrid()">
+ <li ngbNavItem="deskPayments">
+ <a ngbNavLink i18n>Desk Payments</a>
+ <ng-template ngbNavContent>
+ <div class="mt-3">
+ <div class="row">
+ <div class="col-sm-2" i18n>Total Cash Payments</div>
+ <div class="col-sm-10">{{deskTotals.cash_payment | currency}}</div>
+ </div>
+ <div class="row">
+ <div class="col-sm-2" i18n>Total Check Payments</div>
+ <div class="col-sm-10">{{deskTotals.check_payment | currency}}</div>
+ </div>
+ <div class="row">
+ <div class="col-sm-2" i18n>Total Credit Card Payments</div>
+ <div class="col-sm-10">{{deskTotals.credit_card_payment | currency}}</div>
+ </div>
+ <eg-grid #deskPaymentGrid
+ [disableSelect]="true"
+ [disablePaging]="true"
+ [dataSource]="deskPaymentDataSource"
+ [sortable]="false">
+ <eg-grid-column label="Workstation" name="workstation" [index]="true" i18n-label></eg-grid-column>
+ <eg-grid-column label="Cash Payment" name="cash_payment" i18n-label datatype="money"></eg-grid-column>
+ <eg-grid-column label="Check Payment" name="check_payment" i18n-label datatype="money"></eg-grid-column>
+ <eg-grid-column label="Credit Card Payment" name="credit_card_payment" i18n-label datatype="money"></eg-grid-column>
+ </eg-grid>
+ </div>
+ </ng-template>
+ </li>
+ <li ngbNavItem="userPayments">
+ <a ngbNavLink i18n>User Payments</a>
+ <ng-template ngbNavContent>
+ <div class="mt-3">
+ <div class="row">
+ <div class="col-sm-2" i18n>Total Credit Payments</div>
+ <div class="col-sm-10">{{userTotals.credit_payment | currency}}</div>
+ </div>
+ <div class="row">
+ <div class="col-sm-2" i18n>Total Forgive Payments</div>
+ <div class="col-sm-10">{{userTotals.forgive_payment | currency}}</div>
+ </div>
+ <div class="row">
+ <div class="col-sm-2" i18n>Total Work Payments</div>
+ <div class="col-sm-10">{{userTotals.work_payment | currency}}</div>
</div>
- </ng-template>
- </ngb-tab>
- <ngb-tab title="User Payments">
- <ng-template ngbTabContent>
- <div class="mb-3">
- <div class="row">
- <div class="col-sm-2" i18n>Total Credit Payments</div>
- <div class="col-sm-10">{{userTotals.formatted_credit_payment}}</div>
- </div>
- <div class="row">
- <div class="col-sm-2" i18n>Total Forgive Payments</div>
- <div class="col-sm-10">{{userTotals.formatted_forgive_payment}}</div>
- </div>
- <div class="row">
- <div class="col-sm-2" i18n>Total Work Payments</div>
- <div class="col-sm-10">{{userTotals.formatted_work_payment}}</div>
- </div>
- <div class="row">
- <div class="col-sm-2" i18n>Total Goods Payments</div>
- <div class="col-sm-10">{{userTotals.formatted_goods_payment}}</div>
- </div>
- <eg-grid #userPaymentGrid
- (onRowActivate) = "onRowActivate($event)"
- [disableSelect]="true"
- [disablePaging]="true"
- [dataSource]="userPaymentDataSource"
- [sortable]="false">
- <eg-grid-column label="User" name="usr" [index]="true" i18n-label></eg-grid-column>
- <eg-grid-column label="Credit Payment" name="credit_payment" i18n-label></eg-grid-column>
- <eg-grid-column label="Forgive Payment" name="forgive_payment" i18n-label></eg-grid-column>
- <eg-grid-column label="Work Payment" name="work_payment" i18n-label></eg-grid-column>
- <eg-grid-column label="Goods Payment" name="goods_payment" i18n-label></eg-grid-column>
- </eg-grid>
- </div>
- </ng-template>
- </ngb-tab>
-</ngb-tabset>
+ <div class="row">
+ <div class="col-sm-2" i18n>Total Goods Payments</div>
+ <div class="col-sm-10">{{userTotals.goods_payment | currency}}</div>
+ </div>
+ <eg-grid #userPaymentGrid
+ (onRowActivate) = "onRowActivate($event)"
+ [disableSelect]="true"
+ [disablePaging]="true"
+ [dataSource]="userPaymentDataSource"
+ [sortable]="false">
+ <eg-grid-column label="User" name="usr" [index]="true" i18n-label></eg-grid-column>
+ <eg-grid-column label="Credit Payment" name="credit_payment" i18n-label datatype="money"></eg-grid-column>
+ <eg-grid-column label="Forgive Payment" name="forgive_payment" i18n-label datatype="money"></eg-grid-column>
+ <eg-grid-column label="Work Payment" name="work_payment" i18n-label datatype="money"></eg-grid-column>
+ <eg-grid-column label="Goods Payment" name="goods_payment" i18n-label datatype="money"></eg-grid-column>
+ </eg-grid>
+ </div>
+ </ng-template>
+ </li>
+</ul>
+<div [ngbNavOutlet]="cashReportsNav"></div>
<eg-user-dialog #userDialog>
- <ng-container *ngIf="userDataSource.data && userDataSource.data.length>0">
- <eg-grid #userGrid
- [disableSelect]="true"
- [disablePaging]="true"
- [dataSource]="userDataSource"
- [sortable]="false">
- <eg-grid-column label="Card" name="card" [index]="true" i18n-label></eg-grid-column>
- <eg-grid-column label="Email" name="email" i18n-label></eg-grid-column>
- <eg-grid-column label="First Name" name="first_given_name" i18n-label></eg-grid-column>
- <eg-grid-column label="Family Name" name="family_name" i18n-label></eg-grid-column>
- <eg-grid-column label="Home OU" name="home_ou" i18n-label></eg-grid-column>
- </eg-grid>
- </ng-container>
+ <ng-container *ngIf="userDataSource.data && userDataSource.data.length>0">
+ <eg-grid #userGrid
+ [disableSelect]="true"
+ [disablePaging]="true"
+ [dataSource]="userDataSource"
+ [sortable]="false">
+ <eg-grid-column label="Card" name="card" [index]="true" i18n-label></eg-grid-column>
+ <eg-grid-column label="Email" name="email" i18n-label></eg-grid-column>
+ <eg-grid-column label="First Name" name="first_given_name" i18n-label></eg-grid-column>
+ <eg-grid-column label="Family Name" name="family_name" i18n-label></eg-grid-column>
+ <eg-grid-column label="Home OU" name="home_ou" i18n-label></eg-grid-column>
+ </eg-grid>
+ </ng-container>
</eg-user-dialog>
import {Component, OnInit, Input, ViewChild} from '@angular/core';
import {GridComponent} from '@eg/share/grid/grid.component';
import {GridDataSource, GridColumn, GridRowFlairEntry} from '@eg/share/grid/grid';
-import {FormatService} from '@eg/core/format.service';
import {IdlService} from '@eg/core/idl.service';
import {NetService} from '@eg/core/net.service';
import {AuthService} from '@eg/core/auth.service';
cash_payment = 0;
check_payment = 0;
credit_card_payment = 0;
- formatted_cash_payment = '0.00';
- formatted_check_payment = '0.00';
- formatted_credit_card_payment = '0.00';
-};
+}
class UserTotals {
forgive_payment = 0;
work_payment = 0;
credit_payment = 0;
goods_payment = 0;
- formatted_forgive_payment = '0.00';
- formatted_work_payment = '0.00';
- formatted_credit_payment = '0.00';
- formatted_goods_payment = '0.00';
-};
+}
@Component({
templateUrl: './cash-reports.component.html'
deskTotals = new DeskTotals();
userTotals = new UserTotals();
disabledOrgs = [];
+ activeTab = 'deskPayments';
// Default sort field, used when no grid sorting is applied.
@Input() sortField: string;
- @ViewChild('userDialog', { static: true }) userDialog: UserDialogComponent;
- @ViewChild('deskPaymentGrid', { static: true }) deskPaymentGrid: GridComponent;
- @ViewChild('userPaymentGrid', { static: true }) userPaymentGrid: GridComponent;
- @ViewChild('userGrid', { static: true }) userGrid: GridComponent;
+ @ViewChild('userDialog') userDialog: UserDialogComponent;
+ @ViewChild('deskPaymentGrid') deskPaymentGrid: GridComponent;
+ @ViewChild('userPaymentGrid') userPaymentGrid: GridComponent;
+ @ViewChild('userGrid') userGrid: GridComponent;
constructor(
private idl: IdlService,
private net: NetService,
private org: OrgService,
- private format: FormatService,
- private auth: AuthService){}
+ private auth: AuthService) {}
ngOnInit() {
this.disabledOrgs = this.getFilteredOrgList();
}
onRowActivate(userObject) {
- if(userObject.user && this.userDataSource.data.length === 0) {
+ if (userObject.user && this.userDataSource.data.length === 0) {
this.userDataSource.data = [userObject.user];
this.showUserInformation();
} else {
}
showUserInformation() {
- return new Promise((resolve, reject) => {
- this.userDialog.open({size: 'lg'}).subscribe(
- result => {
- resolve(result);
- },
- error => {
- reject(error);
- }
- );
- });
+ return this.userDialog.open({size: 'lg'}).toPromise();
}
searchForData(start, end) {
'open-ils.circ',
'open-ils.circ.money.org_unit.desk_payments',
this.auth.token(), this.selectedOrg.id(), start, end));
- this.fillGridData(this.userIdlClass,'userPaymentDataSource',
+
+ this.fillGridData(this.userIdlClass, 'userPaymentDataSource',
this.net.request(
'open-ils.circ',
'open-ils.circ.money.org_unit.user_payments',
fillGridData(idlClass, dataSource, data) {
data.subscribe((result) => {
- let dataForTotal;
- if(idlClass === this.deskIdlClass) {
- dataForTotal = this.getDeskTotal(result);
- this.deskTotals.formatted_cash_payment = this.format.transform({value: this.deskTotals.cash_payment, datatype: 'money'});
- this.deskTotals.formatted_check_payment = this.format.transform({value: this.deskTotals.check_payment, datatype: 'money'});
- this.deskTotals.formatted_credit_card_payment = this.format.transform({value: this.deskTotals.credit_card_payment, datatype: 'money'});
- } else if(idlClass === this.userIdlClass) {
- dataForTotal = this.getUserTotal(result);
- this.userTotals.formatted_credit_payment = this.format.transform({value: this.userTotals.credit_payment, datatype: 'money'});
- this.userTotals.formatted_forgive_payment = this.format.transform({value: this.userTotals.forgive_payment, datatype: 'money'});
- this.userTotals.formatted_work_payment = this.format.transform({value: this.userTotals.work_payment, datatype: 'money'});
- this.userTotals.formatted_goods_payment = this.format.transform({value: this.userTotals.goods_payment, datatype: 'money'});
+ if (idlClass === this.userIdlClass) {
result.forEach((userObject, index) => {
result[index].user = userObject.usr();
- result[index].usr(userObject.usr().usrname())
+ result[index].usr(userObject.usr().usrname());
});
}
- //if(result.length > 0) {
- // result.push(dataForTotal);
- //}
this[dataSource].data = result;
this.eraseUserGrid();
});
getDeskTotal(idlObjects) {
this.deskTotals = new DeskTotals();
- if(idlObjects.length > 0) {
- let idlObjectFormat = this.idl.create("mwps")
+
+ if (idlObjects.length > 0) {
+ const idlObjectFormat = this.idl.create('mwps');
idlObjects.forEach((idlObject) => {
this.deskTotals['cash_payment'] += parseFloat(idlObject.cash_payment());
this.deskTotals['check_payment'] += parseFloat(idlObject.check_payment());
getUserTotal(idlObjects) {
this.userTotals = new UserTotals();
- if(idlObjects.length > 0) {
- let idlObjectFormat = this.idl.create("mups")
+ if (idlObjects.length > 0) {
+ const idlObjectFormat = this.idl.create('mups');
idlObjects.forEach((idlObject, index) => {
this.userTotals['forgive_payment'] += parseFloat(idlObject.forgive_payment());
this.userTotals['work_payment'] += parseFloat(idlObject.work_payment());
}
getFilteredOrgList() {
- let orgFilter = {canHaveUsers:false}
+ const orgFilter = {canHaveUsers: false};
return this.org.filterList(orgFilter, true);
}
- // getOrgIds(orgs) {
- // orgs.forEach((element) => {
- // this.disabledOrgs.push(element.id());
- // });
- // return orgs;
- // }
-
onStartDateChange(date) {
this.startDate = date;
}