Feature: Cancelled bills are now separate from void bills.
Void bills are automatically generated when printed bills are changed. Manually cancelled bills are called cancelled bills.
This commit is contained in:
@ -271,8 +271,8 @@ export class BillService {
|
||||
return this.ser.mergeKotWithOldBill(this.bill.id as string, kotId, table);
|
||||
}
|
||||
|
||||
voidBill(reason: string): Observable<boolean> {
|
||||
return this.ser.voidBill(this.bill.id as string, reason, this.updateTable);
|
||||
cancelBill(reason: string): Observable<boolean> {
|
||||
return this.ser.cancelBill(this.bill.id as string, reason, this.updateTable);
|
||||
}
|
||||
|
||||
updateAmounts() {
|
||||
|
||||
@ -123,13 +123,13 @@ export class VoucherService {
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'receivePayment'))) as Observable<boolean>;
|
||||
}
|
||||
|
||||
voidBill(id: string, reason: string, updateTable: boolean): Observable<boolean> {
|
||||
cancelBill(id: string, reason: string, updateTable: boolean): Observable<boolean> {
|
||||
const options = {
|
||||
params: new HttpParams().set('reason', reason).set('u', updateTable.toString()),
|
||||
};
|
||||
return this.http
|
||||
.post<boolean>(`${url}/void-bill/${id}`, {}, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'voidBill'))) as Observable<boolean>;
|
||||
.post<boolean>(`${url}/cancel-bill/${id}`, {}, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'cancelBill'))) as Observable<boolean>;
|
||||
}
|
||||
|
||||
moveTable(id: string, table: Table): Observable<boolean> {
|
||||
|
||||
@ -58,11 +58,11 @@
|
||||
<mat-card
|
||||
class="flex flex-col square-button mr-5, mb-5"
|
||||
matRipple
|
||||
(click)="voidBill()"
|
||||
[class.disabled]="!voidBillAllowed()"
|
||||
[class.face]="voidBillAllowed()"
|
||||
(click)="cancelBill()"
|
||||
[class.disabled]="!cancelBillAllowed()"
|
||||
[class.face]="cancelBillAllowed()"
|
||||
>
|
||||
<h3 class="item-name">Void Bill</h3>
|
||||
<h3 class="item-name">Cancel Bill</h3>
|
||||
</mat-card>
|
||||
<mat-card
|
||||
class="flex flex-col square-button mr-5, mb-5"
|
||||
|
||||
@ -112,11 +112,11 @@ export class SalesHomeComponent {
|
||||
.pipe(map((x: boolean) => (x ? table : x)));
|
||||
}
|
||||
|
||||
confirmVoidDialog(reason: string): Observable<string | boolean> {
|
||||
confirmCancelDialog(reason: string): Observable<string | boolean> {
|
||||
return this.dialog
|
||||
.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: { title: 'Void Bill?', content: 'Are you sure?' },
|
||||
data: { title: 'Cancel Bill?', content: 'Are you sure?' },
|
||||
})
|
||||
.afterClosed()
|
||||
.pipe(map((x: boolean) => (x ? reason : x)));
|
||||
@ -267,7 +267,7 @@ export class SalesHomeComponent {
|
||||
);
|
||||
}
|
||||
|
||||
voidBillAllowed(): boolean {
|
||||
cancelBillAllowed(): boolean {
|
||||
if (!this.auth.allowed('void-bill')) {
|
||||
return false;
|
||||
}
|
||||
@ -277,15 +277,15 @@ export class SalesHomeComponent {
|
||||
return true;
|
||||
}
|
||||
|
||||
voidBill() {
|
||||
if (!this.voidBillAllowed()) {
|
||||
cancelBill() {
|
||||
if (!this.cancelBillAllowed()) {
|
||||
return;
|
||||
}
|
||||
this.dialog
|
||||
.open(ReasonComponent, {
|
||||
// width: '750px'
|
||||
data: {
|
||||
title: 'Void Reason',
|
||||
title: 'Cancel Reason',
|
||||
reasons: [
|
||||
'Discount',
|
||||
'Printing fault',
|
||||
@ -301,15 +301,15 @@ export class SalesHomeComponent {
|
||||
.pipe(
|
||||
switchMap((x: boolean | string) => {
|
||||
if (x) {
|
||||
return this.confirmVoidDialog(x as string);
|
||||
return this.confirmCancelDialog(x as string);
|
||||
}
|
||||
throw new Error('Please choose a reason to void the bill');
|
||||
throw new Error('Please choose a reason to cancel the bill');
|
||||
}),
|
||||
switchMap((x: boolean | string) => {
|
||||
if (x) {
|
||||
return this.bs.voidBill(x as string);
|
||||
return this.bs.cancelBill(x as string);
|
||||
}
|
||||
throw new Error('You chose not to void the bill');
|
||||
throw new Error('You chose not to cancel the bill');
|
||||
}),
|
||||
)
|
||||
.subscribe(
|
||||
|
||||
Reference in New Issue
Block a user