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:
2020-09-29 10:50:55 +05:30
parent f8778fee74
commit 046504e097
8 changed files with 204 additions and 132 deletions

View File

@ -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 }[]);