Tax is added directly to product for sale
Auth guard and auth service simplified and fixed so that user is updated upon login Home component changed to use square buttons Fixed showing the totals in the bill ng linted the project
This commit is contained in:
@ -1,21 +1,21 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { MatDialog } from "@angular/material";
|
||||
import { concatMap, map, switchMap, tap } from "rxjs/operators";
|
||||
import { iif, Observable, of as observableOf, throwError } from "rxjs";
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { concatMap, map, switchMap, tap } from 'rxjs/operators';
|
||||
import { iif, Observable, of as observableOf, throwError } from 'rxjs';
|
||||
import { BillService } from '../bill.service';
|
||||
import { ToasterService } from "../../core/toaster.service";
|
||||
import { DiscountComponent } from "../discount/discount.component";
|
||||
import { SaleCategoryService } from "../../sale-category/sale-category.service";
|
||||
import { BillTypeComponent } from "../bill-type/bill-type.component";
|
||||
import { PrintType } from "../bills/bill";
|
||||
import { AuthService } from "../../auth/auth.service";
|
||||
import { ReceivePaymentComponent } from "../receive-payment/receive-payment.component";
|
||||
import { TableService } from "../../tables/table.service";
|
||||
import { Table } from "../../core/table";
|
||||
import { TablesDialogComponent } from "../tables-dialog/tables-dialog.component";
|
||||
import { ConfirmDialogComponent } from "../../shared/confirm-dialog/confirm-dialog.component";
|
||||
import { VoidReasonComponent } from "../void-reason/void-reason.component";
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { DiscountComponent } from '../discount/discount.component';
|
||||
import { SaleCategoryService } from '../../sale-category/sale-category.service';
|
||||
import { BillTypeComponent } from '../bill-type/bill-type.component';
|
||||
import { PrintType } from '../bills/bill';
|
||||
import { AuthService } from '../../auth/auth.service';
|
||||
import { ReceivePaymentComponent } from '../receive-payment/receive-payment.component';
|
||||
import { TableService } from '../../tables/table.service';
|
||||
import { Table } from '../../core/table';
|
||||
import { TablesDialogComponent } from '../tables-dialog/tables-dialog.component';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { VoidReasonComponent } from '../void-reason/void-reason.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sales-home',
|
||||
@ -40,8 +40,8 @@ export class SalesHomeComponent implements OnInit {
|
||||
|
||||
printKot() {
|
||||
let guestBookId = null;
|
||||
if (this.route.snapshot.queryParamMap.has("guest")) {
|
||||
guestBookId = this.route.snapshot.queryParamMap.get("guest");
|
||||
if (this.route.snapshot.queryParamMap.has('guest')) {
|
||||
guestBookId = this.route.snapshot.queryParamMap.get('guest');
|
||||
}
|
||||
this.bs.printKot(guestBookId).subscribe(x => {
|
||||
this.toaster.show('Success', '');
|
||||
@ -50,7 +50,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
}
|
||||
|
||||
discount(): void {
|
||||
if (this.auth.hasPermission("Discount")) {
|
||||
if (this.auth.hasPermission('Discount')) {
|
||||
this.showDiscount().subscribe();
|
||||
}
|
||||
}
|
||||
@ -66,15 +66,15 @@ export class SalesHomeComponent implements OnInit {
|
||||
this.bs.discount(result as { id: string, name: string, discount: number }[]);
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
discountDialog (canGiveDiscount: boolean) : Observable<any> {
|
||||
discountDialog (canGiveDiscount: boolean): Observable<any> {
|
||||
let discObs = null;
|
||||
if (canGiveDiscount) {
|
||||
return discObs = this.showDiscount();
|
||||
} else {
|
||||
return discObs = observableOf("");
|
||||
return discObs = observableOf('');
|
||||
}
|
||||
|
||||
}
|
||||
@ -83,10 +83,10 @@ export class SalesHomeComponent implements OnInit {
|
||||
return this.dialog.open(BillTypeComponent).afterClosed().pipe(
|
||||
tap(x => {
|
||||
if (!x) {
|
||||
throwError ("No Bill Type Chosen")
|
||||
throwError ('No Bill Type Chosen');
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
confirmMoveTableDialog(table: Table): Observable<{table: Table, confirmed: boolean}> {
|
||||
@ -108,10 +108,10 @@ export class SalesHomeComponent implements OnInit {
|
||||
}
|
||||
|
||||
printBill() {
|
||||
const canGiveDiscount = this.auth.hasPermission("Discount");
|
||||
const canGiveDiscount = this.auth.hasPermission('Discount');
|
||||
let guestBookId = null;
|
||||
if (this.route.snapshot.queryParamMap.has("guest")) {
|
||||
guestBookId = this.route.snapshot.queryParamMap.get("guest");
|
||||
if (this.route.snapshot.queryParamMap.has('guest')) {
|
||||
guestBookId = this.route.snapshot.queryParamMap.get('guest');
|
||||
}
|
||||
this.discountDialog(canGiveDiscount).pipe(
|
||||
concatMap(() => this.billTypeDialog())
|
||||
@ -128,13 +128,13 @@ export class SalesHomeComponent implements OnInit {
|
||||
this.router.navigate(['/sales']);
|
||||
},
|
||||
x => {
|
||||
this.toaster.show('Error', "No Bill Type Chosen")
|
||||
this.toaster.show('Error', 'No Bill Type Chosen');
|
||||
});
|
||||
}
|
||||
|
||||
receivePayment() {
|
||||
let amount = this.bs.amount();
|
||||
let type = this.bs.type();
|
||||
const amount = this.bs.amountVal();
|
||||
const type = this.bs.type();
|
||||
const dialogRef = this.dialog.open(ReceivePaymentComponent, {
|
||||
// width: '750px',
|
||||
data: {
|
||||
@ -149,7 +149,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
this.router.navigate(['/sales']);
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
moveTable() {
|
||||
@ -164,14 +164,14 @@ export class SalesHomeComponent implements OnInit {
|
||||
if (!!x) {
|
||||
return this.confirmMoveTableDialog(x as Table);
|
||||
} else {
|
||||
return throwError("Please choose a table");
|
||||
return throwError('Please choose a table');
|
||||
}
|
||||
}),
|
||||
switchMap((value: { table: Table, confirmed: boolean }, index: number) => {
|
||||
if (!!value.confirmed) {
|
||||
return this.bs.moveTable(value.table)
|
||||
return this.bs.moveTable(value.table);
|
||||
} else {
|
||||
return throwError("Please confirm move")
|
||||
return throwError('Please confirm move');
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -180,8 +180,8 @@ export class SalesHomeComponent implements OnInit {
|
||||
this.router.navigate(['/sales']);
|
||||
},
|
||||
x => {
|
||||
this.toaster.show('Error', x)
|
||||
})
|
||||
this.toaster.show('Error', x);
|
||||
});
|
||||
}
|
||||
|
||||
voidBill() {
|
||||
@ -192,14 +192,14 @@ export class SalesHomeComponent implements OnInit {
|
||||
if (!!x) {
|
||||
return this.confirmVoidDialog(x as string);
|
||||
} else {
|
||||
return throwError("Please choose a reason to void the bill");
|
||||
return throwError('Please choose a reason to void the bill');
|
||||
}
|
||||
}),
|
||||
switchMap((x: boolean | string) => {
|
||||
if (!!x) {
|
||||
return this.bs.voidBill(x as string)
|
||||
return this.bs.voidBill(x as string);
|
||||
} else {
|
||||
return throwError("You chose not to void the bill")
|
||||
return throwError('You chose not to void the bill');
|
||||
}
|
||||
})
|
||||
).subscribe((x) => {
|
||||
@ -207,7 +207,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
this.router.navigate(['/sales']);
|
||||
},
|
||||
x => {
|
||||
this.toaster.show('Error', x)
|
||||
})
|
||||
this.toaster.show('Error', x);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user