Ported:
Split bill done - TODO: If the products have different price due to paid modifiers
This commit is contained in:
@ -1,68 +1,68 @@
|
||||
<div fxLayout="row wrap" fxLayoutGap="grid 20px">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('guest-book') !== -1" [routerLink]="['/', 'guest-book']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('guest-book') !== -1" [routerLink]="['/', 'guest-book']">
|
||||
<h3 class="item-name">Guest Book</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('sales') !== -1" [routerLink]="['/', 'sales']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('sales') !== -1" [routerLink]="['/', 'sales']">
|
||||
<h3 class="item-name">Sales</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('cashier-report') !== -1" [routerLink]="['/', 'cashier-report']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('cashier-report') !== -1" [routerLink]="['/', 'cashier-report']">
|
||||
<h3 class="item-name">Cashier Report</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('sale-report') !== -1" [routerLink]="['/', 'sale-report']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('sale-report') !== -1" [routerLink]="['/', 'sale-report']">
|
||||
<h3 class="item-name">Sale Report</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('tax-report') !== -1" [routerLink]="['/', 'tax-report']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('tax-report') !== -1" [routerLink]="['/', 'tax-report']">
|
||||
<h3 class="item-name">Tax Report</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('product-sale-report') !== -1" [routerLink]="['/', 'product-sale-report']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('product-sale-report') !== -1" [routerLink]="['/', 'product-sale-report']">
|
||||
<h3 class="item-name">Product Sale Report</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('bill-settlement-report') !== -1" [routerLink]="['/', 'bill-settlement-report']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('bill-settlement-report') !== -1" [routerLink]="['/', 'bill-settlement-report']">
|
||||
<h3 class="item-name">Bill Settlement Report</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('beer-consumption-report') !== -1" [routerLink]="['/', 'beer-consumption-report']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('beer-consumption-report') !== -1" [routerLink]="['/', 'beer-consumption-report']">
|
||||
<h3 class="item-name">Beer Consumption Report</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('discount-report') !== -1" [routerLink]="['/', 'discount-report']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('discount-report') !== -1" [routerLink]="['/', 'discount-report']">
|
||||
<h3 class="item-name">Discount Report</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('tables') !== -1" [routerLink]="['/', 'tables']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('tables') !== -1" [routerLink]="['/', 'tables']">
|
||||
<h3 class="item-name">Tables</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('sections') !== -1" [routerLink]="['/', 'sections']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('sections') !== -1" [routerLink]="['/', 'sections']">
|
||||
<h3 class="item-name">Sections</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('products') !== -1" [routerLink]="['/', 'menu-categories']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('products') !== -1" [routerLink]="['/', 'menu-categories']">
|
||||
<h3 class="item-name">Menu Categories</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('products') !== -1" [routerLink]="['/', 'sale-categories']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('products') !== -1" [routerLink]="['/', 'sale-categories']">
|
||||
<h3 class="item-name">Sale Categories</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('products') !== -1" [routerLink]="['/', 'products']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('products') !== -1" [routerLink]="['/', 'products']">
|
||||
<h3 class="item-name">Products</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('modifiers') !== -1" [routerLink]="['/', 'modifier-categories']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('modifiers') !== -1" [routerLink]="['/', 'modifier-categories']">
|
||||
<h3 class="item-name">Modifier Categories</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('modifiers') !== -1" [routerLink]="['/', 'modifiers']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('modifiers') !== -1" [routerLink]="['/', 'modifiers']">
|
||||
<h3 class="item-name">Modifiers</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('taxes') !== -1" [routerLink]="['/', 'taxes']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('taxes') !== -1" [routerLink]="['/', 'taxes']">
|
||||
<h3 class="item-name">Taxes</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('devices') !== -1" [routerLink]="['/', 'devices']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('devices') !== -1" [routerLink]="['/', 'devices']">
|
||||
<h3 class="item-name">Devices</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('section-printers') !== -1" [routerLink]="['/', 'section-printers']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('section-printers') !== -1" [routerLink]="['/', 'section-printers']">
|
||||
<h3 class="item-name">Section Printers</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('printers') !== -1" [routerLink]="['/', 'printers']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('printers') !== -1" [routerLink]="['/', 'printers']">
|
||||
<h3 class="item-name">Printers</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('users') !== -1" [routerLink]="['/', 'roles']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('users') !== -1" [routerLink]="['/', 'roles']">
|
||||
<h3 class="item-name">Roles</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user.perms.indexOf('users') !== -1" [routerLink]="['/', 'users']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.user && auth.user.perms.indexOf('users') !== -1" [routerLink]="['/', 'users']">
|
||||
<h3 class="item-name">Users</h3>
|
||||
</mat-card>
|
||||
</div>
|
||||
|
||||
@ -13,6 +13,7 @@ const httpOptions = {
|
||||
const url = '/api/voucher';
|
||||
const urlMoveTable = '/api/move-table';
|
||||
const urlMoveKot = '/api/move-kot';
|
||||
const urlSplitBill = '/api/split-bill';
|
||||
const serviceName = 'VoucherService';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@ -140,11 +141,10 @@ export class VoucherService {
|
||||
}
|
||||
|
||||
splitBill(id: string, inventoriesToMove: string[], table: Table) {
|
||||
const options = {params: new HttpParams().set('split-bill', '').set('u', 'true')};
|
||||
return <Observable<boolean>>this.http.post<boolean>(`${url}/${id}`, {
|
||||
voucher: {id: id},
|
||||
const options = {params: new HttpParams().set('u', 'true')};
|
||||
return <Observable<boolean>>this.http.post<boolean>(`${urlSplitBill}/${id}`, {
|
||||
inventories: inventoriesToMove,
|
||||
table: {id: table.id}
|
||||
tableId: table.id
|
||||
}, options).pipe(
|
||||
catchError(this.log.handleError(serviceName, 'splitBill'))
|
||||
);
|
||||
|
||||
@ -39,7 +39,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
}
|
||||
|
||||
printKotAllowed(): boolean {
|
||||
if (this.auth.user.perms.indexOf('print-kot') === -1) {
|
||||
if (this.auth.user && this.auth.user.perms.indexOf('print-kot') === -1) {
|
||||
return false;
|
||||
}
|
||||
if (!this.bs.bill.id) {
|
||||
@ -69,7 +69,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
}
|
||||
|
||||
discountAllowed(): boolean {
|
||||
return this.auth.user.perms.indexOf('discount') !== -1;
|
||||
return this.auth.user && this.auth.user.perms.indexOf('discount') !== -1;
|
||||
}
|
||||
|
||||
showDiscount(): Observable<boolean | { id: string, name: string, discount: number }[]> {
|
||||
@ -120,7 +120,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
}
|
||||
|
||||
printBillAllowed(): boolean {
|
||||
if (this.auth.user.perms.indexOf('print-bill') === -1) {
|
||||
if (this.auth.user && this.auth.user.perms.indexOf('print-bill') === -1) {
|
||||
return false;
|
||||
}
|
||||
if (!this.bs.bill.id) {
|
||||
@ -143,7 +143,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
if (this.route.snapshot.queryParamMap.has('guest')) {
|
||||
guestBookId = this.route.snapshot.queryParamMap.get('guest');
|
||||
}
|
||||
let discountObservable: Observable<any> = (this.discountAllowed()) ? this.showDiscount() : observableOf('');
|
||||
const discountObservable: Observable<any> = (this.discountAllowed()) ? this.showDiscount() : observableOf('');
|
||||
|
||||
discountObservable.pipe(
|
||||
tap((result: boolean | { id: string, name: string, discount: number }[]) => {
|
||||
@ -169,7 +169,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
}
|
||||
|
||||
receivePaymentAllowed(): boolean {
|
||||
if (this.auth.user.perms.indexOf('settle-bill') === -1) {
|
||||
if (this.auth.user && this.auth.user.perms.indexOf('settle-bill') === -1) {
|
||||
return false;
|
||||
}
|
||||
if (!this.bs.bill.id) {
|
||||
@ -184,7 +184,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
return true;
|
||||
}
|
||||
|
||||
receivePaymentWithReason(type:string, amount: number): Observable<boolean> {
|
||||
receivePaymentWithReason(type: string, amount: number): Observable<boolean> {
|
||||
const types = {
|
||||
NO_CHARGE: [
|
||||
{
|
||||
@ -203,13 +203,13 @@ export class SalesHomeComponent implements OnInit {
|
||||
};
|
||||
return this.dialog.open(ReasonComponent, {
|
||||
// width: '750px'
|
||||
data: {title: (type === "NO_CHARGE") ? "NC for whom" : "Staff name"}
|
||||
data: {title: (type === 'NO_CHARGE') ? 'NC for whom' : 'Staff name'}
|
||||
}).afterClosed().pipe(
|
||||
switchMap((value: boolean | string) => {
|
||||
if (!!value) {
|
||||
return this.bs.receivePayment(types[type], value as string)
|
||||
return this.bs.receivePayment(types[type], value as string);
|
||||
} else {
|
||||
return throwError("Cancelled");
|
||||
return throwError('Cancelled');
|
||||
}
|
||||
})
|
||||
);
|
||||
@ -227,7 +227,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
if (!!value) {
|
||||
return this.bs.receivePayment(value as { id: number, name: string, amount: number }[], '')
|
||||
} else {
|
||||
return throwError("Cancelled");
|
||||
return throwError('Cancelled');
|
||||
}
|
||||
})
|
||||
);
|
||||
@ -252,7 +252,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
|
||||
moveTableAllowed(): boolean {
|
||||
// TODO: Check if this condition should be "and" or "or"
|
||||
if (this.auth.user.perms.indexOf('move-table') === -1 && this.auth.user.perms.indexOf('merge-tables') === -1) {
|
||||
if (this.auth.user && this.auth.user.perms.indexOf('move-table') === -1 && this.auth.user.perms.indexOf('merge-tables') === -1) {
|
||||
return false;
|
||||
}
|
||||
if (!this.bs.bill.id) {
|
||||
@ -300,7 +300,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
}
|
||||
|
||||
voidBillAllowed(): boolean {
|
||||
if (this.auth.user.perms.indexOf('void-bill') === -1) {
|
||||
if (this.auth.user && this.auth.user.perms.indexOf('void-bill') === -1) {
|
||||
return false;
|
||||
}
|
||||
if (!this.bs.bill.id) {
|
||||
@ -352,7 +352,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
}
|
||||
|
||||
splitBillAllowed(): boolean {
|
||||
if (this.auth.user.perms.indexOf('split-bill') === -1) {
|
||||
if (this.auth.user && this.auth.user.perms.indexOf('split-bill') === -1) {
|
||||
return false;
|
||||
}
|
||||
if (!this.bs.bill.id) {
|
||||
|
||||
Reference in New Issue
Block a user