Blacked and isorted the python files
Prettied and eslinted the typescript/html files
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {ActiveCashiersResolver} from './active-cashiers-resolver.service';
|
||||
import { ActiveCashiersResolver } from './active-cashiers-resolver.service';
|
||||
|
||||
describe('ActiveCashiersResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [ActiveCashiersResolver]
|
||||
providers: [ActiveCashiersResolver],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { CashierReportService } from './cashier-report.service';
|
||||
|
||||
import { User } from '../core/user';
|
||||
|
||||
import { CashierReportService } from './cashier-report.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ActiveCashiersResolver implements Resolve<User[]> {
|
||||
constructor(private ser: CashierReportService) {}
|
||||
|
||||
constructor(private ser: CashierReportService) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<User[]> {
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<User[]> {
|
||||
const startDate = route.queryParamMap.get('startDate') || null;
|
||||
const finishDate = route.queryParamMap.get('finishDate') || null;
|
||||
return this.ser.activeCashiers(startDate, finishDate);
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { CashierReportDisplayItem } from './cashier-report';
|
||||
|
||||
import { CashierReportDisplayItem } from './cashier-report-display-item';
|
||||
|
||||
export class CashierReportDataSource extends DataSource<CashierReportDisplayItem> {
|
||||
|
||||
constructor(public data: CashierReportDisplayItem[]) {
|
||||
super();
|
||||
}
|
||||
@ -13,6 +12,5 @@ export class CashierReportDataSource extends DataSource<CashierReportDisplayItem
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
disconnect() {}
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
export class CashierReportDisplayItem {
|
||||
name: string;
|
||||
amount: number;
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
export class CashierReportPrintItem {
|
||||
date: string;
|
||||
billId: string;
|
||||
customer: string;
|
||||
amount: number;
|
||||
}
|
||||
@ -1,11 +1,11 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {CashierReportResolver} from './cashier-report-resolver.service';
|
||||
import { CashierReportResolver } from './cashier-report-resolver.service';
|
||||
|
||||
describe('CashierReportResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [CashierReportResolver]
|
||||
providers: [CashierReportResolver],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,18 +1,17 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {CashierReport} from './cashier-report';
|
||||
import {CashierReportService} from './cashier-report.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { CashierReport } from './cashier-report';
|
||||
import { CashierReportService } from './cashier-report.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CashierReportResolver implements Resolve<CashierReport> {
|
||||
constructor(private ser: CashierReportService) {}
|
||||
|
||||
constructor(private ser: CashierReportService) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<CashierReport> {
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<CashierReport> {
|
||||
const id = route.paramMap.get('id');
|
||||
const startDate = route.queryParamMap.get('startDate') || null;
|
||||
const finishDate = route.queryParamMap.get('finishDate') || null;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {CashierReportRoutingModule} from './cashier-report-routing.module';
|
||||
import { CashierReportRoutingModule } from './cashier-report-routing.module';
|
||||
|
||||
describe('CashierReportRoutingModule', () => {
|
||||
let cashierReportRoutingModule: CashierReportRoutingModule;
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { CashierReportResolver } from './cashier-report-resolver.service';
|
||||
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { CashierReportComponent } from './cashier-report.component';
|
||||
|
||||
import { ActiveCashiersResolver } from './active-cashiers-resolver.service';
|
||||
import { CashierReportResolver } from './cashier-report-resolver.service';
|
||||
import { CashierReportComponent } from './cashier-report.component';
|
||||
|
||||
const cashierReportRoutes: Routes = [
|
||||
{
|
||||
@ -12,41 +14,32 @@ const cashierReportRoutes: Routes = [
|
||||
component: CashierReportComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Cashier Report'
|
||||
permission: 'Cashier Report',
|
||||
},
|
||||
resolve: {
|
||||
info: CashierReportResolver,
|
||||
cashiers: ActiveCashiersResolver
|
||||
cashiers: ActiveCashiersResolver,
|
||||
},
|
||||
runGuardsAndResolvers: 'always'
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: CashierReportComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Cashier Report'
|
||||
permission: 'Cashier Report',
|
||||
},
|
||||
resolve: {
|
||||
info: CashierReportResolver,
|
||||
cashiers: ActiveCashiersResolver
|
||||
cashiers: ActiveCashiersResolver,
|
||||
},
|
||||
runGuardsAndResolvers: 'always'
|
||||
}
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(cashierReportRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
CashierReportResolver
|
||||
]
|
||||
imports: [CommonModule, RouterModule.forChild(cashierReportRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [CashierReportResolver],
|
||||
})
|
||||
export class CashierReportRoutingModule {
|
||||
}
|
||||
export class CashierReportRoutingModule {}
|
||||
|
||||
@ -7,50 +7,71 @@
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
<div fxLayout="row" fxLayout.lt-md="column" fxLayoutGap="20px" fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<input matInput [matDatepicker]="startDate" (focus)="startDate.open()" placeholder="Start Date"
|
||||
formControlName="startDate" autocomplete="off">
|
||||
<input
|
||||
matInput
|
||||
[matDatepicker]="startDate"
|
||||
(focus)="startDate.open()"
|
||||
placeholder="Start Date"
|
||||
formControlName="startDate"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<mat-datepicker-toggle matSuffix [for]="startDate"></mat-datepicker-toggle>
|
||||
<mat-datepicker #startDate></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex>
|
||||
<input matInput [matDatepicker]="finishDate" (focus)="finishDate.open()" placeholder="Finish Date"
|
||||
formControlName="finishDate" autocomplete="off">
|
||||
<input
|
||||
matInput
|
||||
[matDatepicker]="finishDate"
|
||||
(focus)="finishDate.open()"
|
||||
placeholder="Finish Date"
|
||||
formControlName="finishDate"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<mat-datepicker-toggle matSuffix [for]="finishDate"></mat-datepicker-toggle>
|
||||
<mat-datepicker #finishDate></mat-datepicker>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayout.lt-md="column" fxLayoutGap="20px" fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start">
|
||||
<mat-form-field fxFlex="80">
|
||||
<mat-label>Cashier</mat-label>
|
||||
<mat-select placeholder="Cashier" formControlName="cashier">
|
||||
<mat-option>-- Cashier --</mat-option>
|
||||
<mat-option *ngFor="let ac of activeCashiers" [value]="ac.id">
|
||||
{{ ac.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start"
|
||||
>
|
||||
<mat-form-field fxFlex="80">
|
||||
<mat-label>Cashier</mat-label>
|
||||
<mat-select placeholder="Cashier" formControlName="cashier">
|
||||
<mat-option>-- Cashier --</mat-option>
|
||||
<mat-option *ngFor="let ac of activeCashiers" [value]="ac.id">
|
||||
{{ ac.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<button fxFlex="20" mat-raised-button color="primary" (click)="show()">Show</button>
|
||||
</div>
|
||||
</form>
|
||||
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.name}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.name }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Amount Column -->
|
||||
<ng-container matColumnDef="amount">
|
||||
<mat-header-cell *matHeaderCellDef class="right">Amount</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.amount | currency:'INR'}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{ row.amount | currency: 'INR' }}</mat-cell>
|
||||
</ng-container>
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||
</mat-table>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {CashierReportComponent} from './cashier-report.component';
|
||||
import { CashierReportComponent } from './cashier-report.component';
|
||||
|
||||
describe('CashierReportComponent', () => {
|
||||
let component: CashierReportComponent;
|
||||
@ -8,9 +8,8 @@ describe('CashierReportComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [CashierReportComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [CashierReportComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -2,15 +2,17 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
import { CashierReportDataSource } from './cashier-report-datasource';
|
||||
import { CashierReport } from './cashier-report';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
import { User } from '../core/user';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
import { CashierReport } from './cashier-report';
|
||||
import { CashierReportDataSource } from './cashier-report-datasource';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cashier-report',
|
||||
templateUrl: './cashier-report.component.html',
|
||||
styleUrls: ['./cashier-report.component.css']
|
||||
styleUrls: ['./cashier-report.component.css'],
|
||||
})
|
||||
export class CashierReportComponent implements OnInit {
|
||||
dataSource: CashierReportDataSource;
|
||||
@ -21,42 +23,39 @@ export class CashierReportComponent implements OnInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'amount'];
|
||||
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private fb: FormBuilder,
|
||||
private toCsv: ToCsvService
|
||||
private toCsv: ToCsvService,
|
||||
) {
|
||||
this.createForm();
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { cashiers: User[], info: CashierReport }) => {
|
||||
this.activeCashiers = data.cashiers;
|
||||
this.info = data.info;
|
||||
this.form.setValue({
|
||||
cashier: this.info.user.id,
|
||||
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
|
||||
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate()
|
||||
});
|
||||
this.dataSource = new CashierReportDataSource(this.info.amounts);
|
||||
this.route.data.subscribe((data: { cashiers: User[]; info: CashierReport }) => {
|
||||
this.activeCashiers = data.cashiers;
|
||||
this.info = data.info;
|
||||
this.form.setValue({
|
||||
cashier: this.info.user.id,
|
||||
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
|
||||
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate(),
|
||||
});
|
||||
this.dataSource = new CashierReportDataSource(this.info.amounts);
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
const info = this.getInfo();
|
||||
const url = ['cashier-report'];
|
||||
if (!!info.user.id) {
|
||||
if (info.user.id) {
|
||||
url.push(info.user.id);
|
||||
}
|
||||
this.router.navigate(url, {
|
||||
queryParams: {
|
||||
startDate: info.startDate,
|
||||
finishDate: info.finishDate
|
||||
}
|
||||
finishDate: info.finishDate,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@ -64,7 +63,7 @@ export class CashierReportComponent implements OnInit {
|
||||
this.form = this.fb.group({
|
||||
startDate: '',
|
||||
finishDate: '',
|
||||
cashier: ''
|
||||
cashier: '',
|
||||
});
|
||||
}
|
||||
|
||||
@ -72,18 +71,20 @@ export class CashierReportComponent implements OnInit {
|
||||
const formModel = this.form.value;
|
||||
|
||||
return {
|
||||
user: new User({id: formModel.cashier}),
|
||||
user: new User({ id: formModel.cashier }),
|
||||
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
|
||||
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY')
|
||||
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
|
||||
};
|
||||
}
|
||||
|
||||
exportCsv() {
|
||||
const headers = {
|
||||
Name: 'name',
|
||||
Amount: 'amount'
|
||||
Amount: 'amount',
|
||||
};
|
||||
const csvData = new Blob([this.toCsv.toCsv(headers, this.dataSource.data)], {type: 'text/csv;charset=utf-8;'});
|
||||
const csvData = new Blob([this.toCsv.toCsv(headers, this.dataSource.data)], {
|
||||
type: 'text/csv;charset=utf-8;',
|
||||
});
|
||||
const link = document.createElement('a');
|
||||
link.href = window.URL.createObjectURL(csvData);
|
||||
link.setAttribute('download', 'cashier-report.csv');
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {CashierReportModule} from './cashier-report.module';
|
||||
import { CashierReportModule } from './cashier-report.module';
|
||||
|
||||
describe('CashierReportModule', () => {
|
||||
let cashierReportModule: CashierReportModule;
|
||||
|
||||
@ -1,27 +1,34 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MatNativeDateModule } from '@angular/material/core';
|
||||
import {
|
||||
DateAdapter,
|
||||
MAT_DATE_FORMATS,
|
||||
MAT_DATE_LOCALE,
|
||||
MatNativeDateModule,
|
||||
} from '@angular/material/core';
|
||||
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatPaginatorModule } from '@angular/material/paginator';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatSortModule } from '@angular/material/sort';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { SharedModule} from '../shared/shared.module';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
|
||||
import { CashierReportRoutingModule } from './cashier-report-routing.module';
|
||||
import { CashierReportComponent } from './cashier-report.component';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
|
||||
export const MY_FORMATS = {
|
||||
parse: {
|
||||
@ -57,15 +64,12 @@ export const MY_FORMATS = {
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
SharedModule,
|
||||
CashierReportRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
CashierReportComponent
|
||||
CashierReportRoutingModule,
|
||||
],
|
||||
declarations: [CashierReportComponent],
|
||||
providers: [
|
||||
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
|
||||
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
|
||||
]
|
||||
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
|
||||
{ provide: MAT_DATE_FORMATS, useValue: MY_FORMATS },
|
||||
],
|
||||
})
|
||||
export class CashierReportModule {
|
||||
}
|
||||
export class CashierReportModule {}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {CashierReportService} from './cashier-report.service';
|
||||
import { CashierReportService } from './cashier-report.service';
|
||||
|
||||
describe('CashierReportService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [CashierReportService]
|
||||
providers: [CashierReportService],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,54 +1,49 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { CashierReport } from './cashier-report';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { User } from '../core/user';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
import { CashierReport } from './cashier-report';
|
||||
|
||||
const url = '/api/cashier-report';
|
||||
const serviceName = 'CashierReportService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CashierReportService {
|
||||
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
list(id: string, startDate: string, finishDate): Observable<CashierReport> {
|
||||
const listUrl = (id === null) ? url : `${url}/${id}`;
|
||||
const options = {params: new HttpParams()};
|
||||
const listUrl = id === null ? url : `${url}/${id}`;
|
||||
const options = { params: new HttpParams() };
|
||||
if (startDate !== null) {
|
||||
options.params = options.params.set('s', startDate);
|
||||
}
|
||||
if (finishDate !== null) {
|
||||
options.params = options.params.set('f', finishDate);
|
||||
}
|
||||
return <Observable<CashierReport>>this.http.get<CashierReport>(listUrl, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
return <Observable<CashierReport>>(
|
||||
this.http
|
||||
.get<CashierReport>(listUrl, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list')))
|
||||
);
|
||||
}
|
||||
|
||||
activeCashiers(startDate: string, finishDate): Observable<User[]> {
|
||||
const options = {params: new HttpParams()};
|
||||
const options = { params: new HttpParams() };
|
||||
if (startDate !== null) {
|
||||
options.params = options.params.set('s', startDate);
|
||||
}
|
||||
if (finishDate !== null) {
|
||||
options.params = options.params.set('f', finishDate);
|
||||
}
|
||||
return <Observable<User[]>>this.http.get<User[]>(`${url}/active`, options)
|
||||
return <Observable<User[]>>this.http
|
||||
.get<User[]>(`${url}/active`, options)
|
||||
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'activeCashiers'))
|
||||
);
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'activeCashiers')));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,16 +1,7 @@
|
||||
import { User } from '../core/user';
|
||||
|
||||
export class CashierReportPrintItem {
|
||||
date: string;
|
||||
billId: string;
|
||||
customer: string;
|
||||
amount: number;
|
||||
}
|
||||
|
||||
export class CashierReportDisplayItem {
|
||||
name: string;
|
||||
amount: number;
|
||||
}
|
||||
import { CashierReportDisplayItem } from './cashier-report-display-item';
|
||||
import { CashierReportPrintItem } from './cashier-report-print-item';
|
||||
|
||||
export class CashierReport {
|
||||
startDate: string;
|
||||
|
||||
Reference in New Issue
Block a user