Feature: Open bill using bill number
This commit is contained in:
@ -12,9 +12,16 @@ export class BillResolver implements Resolve<Bill> {
|
||||
constructor(private ser: VoucherService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<Bill> {
|
||||
const tableId = route.queryParamMap.get('table') as string;
|
||||
const tableId = route.queryParamMap.get('table');
|
||||
const guestId = route.queryParamMap.get('guest');
|
||||
const voucherId = route.queryParamMap.get('voucher');
|
||||
return this.ser.getFromTable(tableId, voucherId, guestId);
|
||||
const billId = route.queryParamMap.get('bill');
|
||||
if (billId !== null) {
|
||||
return this.ser.getFromBill(billId);
|
||||
}
|
||||
if (tableId !== null) {
|
||||
return this.ser.getFromTable(tableId as string, voucherId, guestId);
|
||||
}
|
||||
throw new Error('Unable to get bill');
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,8 +44,8 @@ export class BillsComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { item: Bill };
|
||||
this.bs.loadData(data.item);
|
||||
const data = value as { item: Bill; updateTable: boolean };
|
||||
this.bs.loadData(data.item, data.updateTable);
|
||||
});
|
||||
this.getPax();
|
||||
this.dataSource = new BillsDataSource(this.bs.dataObs);
|
||||
|
||||
14
bookie/src/app/sales/bills/update-table-resolver.service.ts
Normal file
14
bookie/src/app/sales/bills/update-table-resolver.service.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UpdateTableResolver implements Resolve<boolean> {
|
||||
constructor() {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<boolean> {
|
||||
return route.queryParamMap.get('bill') !== null ? observableOf(false) : observableOf(true);
|
||||
}
|
||||
}
|
||||
@ -50,6 +50,14 @@ export class VoucherService {
|
||||
) as Observable<Bill>;
|
||||
}
|
||||
|
||||
getFromBill(billId: string): Observable<Bill> {
|
||||
return this.http
|
||||
.get<Bill>(`${url}/from-bill/${billId}`)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `getFromBill billId=${billId}`)),
|
||||
) as Observable<Bill>;
|
||||
}
|
||||
|
||||
save(
|
||||
voucher: Bill,
|
||||
voucherType: VoucherType,
|
||||
@ -179,8 +187,8 @@ export class VoucherService {
|
||||
) as Observable<boolean>;
|
||||
}
|
||||
|
||||
splitBill(id: string, inventoriesToMove: string[], table: Table) {
|
||||
const options = { params: new HttpParams().set('u', 'true') };
|
||||
splitBill(id: string, inventoriesToMove: string[], table: Table, updateTable: boolean) {
|
||||
const options = { params: new HttpParams().set('u', updateTable.toString()) };
|
||||
return this.http
|
||||
.post<boolean>(
|
||||
`${urlSplitBill}/${id}`,
|
||||
|
||||
Reference in New Issue
Block a user