Bump to version 3.0.0
Printing done on: Cashier Report Discount Report Sale Report
This commit is contained in:
@ -2,3 +2,7 @@
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Cashier Report</mat-card-title>
|
||||
<button mat-button mat-icon-button (click)="exportCsv()">
|
||||
<span class="spacer"></span>
|
||||
<button mat-button mat-icon-button [disabled]="!info.cashier.id" (click)="exportCsv()">
|
||||
<mat-icon>save_alt</mat-icon>
|
||||
</button>
|
||||
<button mat-button mat-icon-button [disabled]="!info.cashier.id" (click)="print()">
|
||||
<mat-icon>print</mat-icon>
|
||||
</button>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
|
||||
@ -3,11 +3,13 @@ import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
import { User } from '../core/user';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
import { CashierReport } from './cashier-report';
|
||||
import { CashierReportDataSource } from './cashier-report-datasource';
|
||||
import { CashierReportService } from './cashier-report.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cashier-report',
|
||||
@ -28,6 +30,8 @@ export class CashierReportComponent implements OnInit {
|
||||
private router: Router,
|
||||
private fb: FormBuilder,
|
||||
private toCsv: ToCsvService,
|
||||
private toaster: ToasterService,
|
||||
private ser: CashierReportService,
|
||||
) {
|
||||
this.createForm();
|
||||
}
|
||||
@ -37,7 +41,7 @@ export class CashierReportComponent implements OnInit {
|
||||
this.activeCashiers = data.cashiers;
|
||||
this.info = data.info;
|
||||
this.form.setValue({
|
||||
cashier: this.info.user.id,
|
||||
cashier: this.info.cashier.id,
|
||||
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
|
||||
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate(),
|
||||
});
|
||||
@ -48,8 +52,8 @@ export class CashierReportComponent implements OnInit {
|
||||
show() {
|
||||
const info = this.getInfo();
|
||||
const url = ['cashier-report'];
|
||||
if (info.user.id) {
|
||||
url.push(info.user.id);
|
||||
if (info.cashier.id) {
|
||||
url.push(info.cashier.id);
|
||||
}
|
||||
this.router.navigate(url, {
|
||||
queryParams: {
|
||||
@ -59,6 +63,17 @@ export class CashierReportComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
print() {
|
||||
this.ser.print(this.info.cashier.id, this.info.startDate, this.info.finishDate).subscribe(
|
||||
() => {
|
||||
this.toaster.show('', 'Successfully Printed');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Error', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
startDate: '',
|
||||
@ -71,7 +86,8 @@ export class CashierReportComponent implements OnInit {
|
||||
const formModel = this.form.value;
|
||||
|
||||
return {
|
||||
user: new User({ id: formModel.cashier }),
|
||||
cashier: new User({ id: formModel.cashier }),
|
||||
cashiers: this.info.cashiers,
|
||||
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
|
||||
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
|
||||
};
|
||||
|
||||
@ -46,4 +46,20 @@ export class CashierReportService {
|
||||
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'activeCashiers')));
|
||||
}
|
||||
|
||||
print(id: string, startDate: string, finishDate): Observable<boolean> {
|
||||
const printUrl = `${url}/print/${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<boolean>>(
|
||||
this.http
|
||||
.get<boolean>(printUrl, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'print')))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,8 @@ import { CashierReportPrintItem } from './cashier-report-print-item';
|
||||
export class CashierReport {
|
||||
startDate: string;
|
||||
finishDate: string;
|
||||
user: User;
|
||||
cashier: User;
|
||||
cashiers: string;
|
||||
amounts?: CashierReportDisplayItem[];
|
||||
info?: CashierReportPrintItem[];
|
||||
}
|
||||
|
||||
@ -2,3 +2,7 @@
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Discount Report</mat-card-title>
|
||||
<span class="spacer"></span>
|
||||
<button mat-button mat-icon-button (click)="exportCsv()">
|
||||
<mat-icon>save_alt</mat-icon>
|
||||
</button>
|
||||
<button mat-button mat-icon-button (click)="print()">
|
||||
<mat-icon>print</mat-icon>
|
||||
</button>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
|
||||
@ -3,10 +3,12 @@ import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
import { DiscountReport } from './discount-report';
|
||||
import { DiscountReportDataSource } from './discount-report-datasource';
|
||||
import { DiscountReportService } from './discount-report.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-discount-report',
|
||||
@ -26,6 +28,8 @@ export class DiscountReportComponent implements OnInit {
|
||||
private router: Router,
|
||||
private fb: FormBuilder,
|
||||
private toCsv: ToCsvService,
|
||||
private toaster: ToasterService,
|
||||
private ser: DiscountReportService,
|
||||
) {
|
||||
this.createForm();
|
||||
}
|
||||
@ -67,6 +71,17 @@ export class DiscountReportComponent implements OnInit {
|
||||
};
|
||||
}
|
||||
|
||||
print() {
|
||||
this.ser.print(this.info.startDate, this.info.finishDate).subscribe(
|
||||
() => {
|
||||
this.toaster.show('', 'Successfully Printed');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Error', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
exportCsv() {
|
||||
const headers = {
|
||||
Name: 'name',
|
||||
|
||||
@ -30,4 +30,20 @@ export class DiscountReportService {
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'get')))
|
||||
);
|
||||
}
|
||||
|
||||
print(startDate: string, finishDate): Observable<boolean> {
|
||||
const printUrl = `${url}/print`;
|
||||
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<boolean>>(
|
||||
this.http
|
||||
.get<boolean>(printUrl, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'print')))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,3 +2,7 @@
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Sale Report</mat-card-title>
|
||||
<span class="spacer"></span>
|
||||
<button mat-button mat-icon-button (click)="exportCsv()">
|
||||
<mat-icon>save_alt</mat-icon>
|
||||
</button>
|
||||
<button mat-button mat-icon-button (click)="print()">
|
||||
<mat-icon>print</mat-icon>
|
||||
</button>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
|
||||
@ -3,10 +3,12 @@ import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
import { SaleReport } from './sale-report';
|
||||
import { SaleReportDatasource } from './sale-report-datasource';
|
||||
import { SaleReportService } from './sale-report.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sale-report',
|
||||
@ -26,6 +28,8 @@ export class SaleReportComponent implements OnInit {
|
||||
private router: Router,
|
||||
private fb: FormBuilder,
|
||||
private toCsv: ToCsvService,
|
||||
private toaster: ToasterService,
|
||||
private ser: SaleReportService,
|
||||
) {
|
||||
this.createForm();
|
||||
}
|
||||
@ -67,6 +71,17 @@ export class SaleReportComponent implements OnInit {
|
||||
};
|
||||
}
|
||||
|
||||
print() {
|
||||
this.ser.print(this.info.startDate, this.info.finishDate).subscribe(
|
||||
() => {
|
||||
this.toaster.show('', 'Successfully Printed');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Error', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
exportCsv() {
|
||||
const headers = {
|
||||
Name: 'name',
|
||||
|
||||
@ -30,4 +30,20 @@ export class SaleReportService {
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'get')))
|
||||
);
|
||||
}
|
||||
|
||||
print(startDate: string, finishDate): Observable<boolean> {
|
||||
const printUrl = `${url}/print`;
|
||||
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<boolean>>(
|
||||
this.http
|
||||
.get<boolean>(printUrl, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'print')))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
export const environment = {
|
||||
production: true,
|
||||
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
|
||||
version: "2.0.0",
|
||||
version: '3.0.0',
|
||||
};
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
export const environment = {
|
||||
production: false,
|
||||
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
|
||||
version: "2.0.0",
|
||||
version: '3.0.0',
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user