Ported:
Change (Reprint bill) Chore: Refactored save voucher so that the save function can be reused in change voucher route Fix: Show voucher sent modifiers in a wrong format Inventory schema used rate instead of price
This commit is contained in:
@ -69,11 +69,24 @@ export class VoucherService {
|
||||
);
|
||||
}
|
||||
|
||||
change(voucher: Bill, printType: PrintType, guest_book_id: string, updateTable: boolean): Observable<boolean> {
|
||||
const options = {params: new HttpParams().set('u', updateTable.toString())};
|
||||
if (guest_book_id !== null) {
|
||||
options.params = options.params.set('g', guest_book_id);
|
||||
}
|
||||
return <Observable<boolean>>this.http.put<boolean>(`${url}/change/${voucher.id}`, voucher, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'change'))
|
||||
);
|
||||
}
|
||||
|
||||
saveOrUpdate(voucher: Bill, printType: PrintType, guest_book_id: string, updateTable: boolean): Observable<boolean> {
|
||||
if (!voucher.id) {
|
||||
return this.save(voucher, printType, guest_book_id, updateTable);
|
||||
} else {
|
||||
} else if (voucher.voucherType === PrintType.Kot) {
|
||||
return this.update(voucher, printType, guest_book_id, updateTable);
|
||||
} else {
|
||||
return this.change(voucher, printType, guest_book_id, updateTable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -73,17 +73,18 @@ export class SalesHomeComponent implements OnInit {
|
||||
}
|
||||
|
||||
showDiscount(): Observable<boolean | { id: string, name: string, discount: number }[]> {
|
||||
const dialogRef = this.dialog.open(DiscountComponent, {
|
||||
// width: '750px',
|
||||
data: this.mcSer.listForDiscount()
|
||||
});
|
||||
return dialogRef.afterClosed();
|
||||
if (this.discountAllowed()) {
|
||||
const dialogRef = this.dialog.open(DiscountComponent, {
|
||||
// width: '750px',
|
||||
data: this.mcSer.listForDiscount()
|
||||
});
|
||||
return dialogRef.afterClosed();
|
||||
} else {
|
||||
return observableOf(false);
|
||||
}
|
||||
}
|
||||
|
||||
discount(): void {
|
||||
if (!this.discountAllowed()) {
|
||||
return;
|
||||
}
|
||||
this.showDiscount().subscribe((result: boolean | { id: string, name: string, discount: number }[]) => {
|
||||
if (!!result) {
|
||||
this.bs.discount(result as { id: string, name: string, discount: number }[]);
|
||||
@ -92,13 +93,18 @@ export class SalesHomeComponent implements OnInit {
|
||||
}
|
||||
|
||||
billTypeDialog() {
|
||||
return this.dialog.open(BillTypeComponent).afterClosed().pipe(
|
||||
tap(x => {
|
||||
if (!x) {
|
||||
throwError ('No Bill Type Chosen');
|
||||
}
|
||||
})
|
||||
);
|
||||
if (this.bs.bill.voucherType !== PrintType.Kot) {
|
||||
return observableOf(this.bs.bill.voucherType);
|
||||
} else {
|
||||
return this.dialog.open(BillTypeComponent).afterClosed().pipe(
|
||||
tap(x => {
|
||||
if (!x) {
|
||||
throwError('No Bill Type Chosen');
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
confirmTableDialog(table: Table): Observable<{table: Table, confirmed: boolean}> {
|
||||
@ -143,9 +149,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
if (this.route.snapshot.queryParamMap.has('guest')) {
|
||||
guestBookId = this.route.snapshot.queryParamMap.get('guest');
|
||||
}
|
||||
const discountObservable: Observable<any> = (this.discountAllowed()) ? this.showDiscount() : observableOf('');
|
||||
|
||||
discountObservable.pipe(
|
||||
this.showDiscount().pipe(
|
||||
tap((result: boolean | { id: string, name: string, discount: number }[]) => {
|
||||
if (!!result) {
|
||||
this.bs.discount(result as { id: string, name: string, discount: number }[]);
|
||||
|
||||
Reference in New Issue
Block a user