Renamed void_reason to reason so that we can store the employee name in case of Staff and NC reason in case of NC bills.
Settling NC and Staff bills now asks for Staff name / NC reason
This commit is contained in:
@ -15,7 +15,7 @@ import { TableService } from '../../tables/table.service';
|
||||
import { Table } from '../../core/table';
|
||||
import { TablesDialogComponent } from '../tables-dialog/tables-dialog.component';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { VoidReasonComponent } from '../void-reason/void-reason.component';
|
||||
import { ReasonComponent } from '../reason/reason.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sales-home',
|
||||
@ -184,28 +184,71 @@ export class SalesHomeComponent implements OnInit {
|
||||
return true;
|
||||
}
|
||||
|
||||
receivePaymentWithReason(type:string, amount: number): Observable<boolean> {
|
||||
const types = {
|
||||
NO_CHARGE: [
|
||||
{
|
||||
id: 4,
|
||||
name: 'No Charge',
|
||||
amount: amount
|
||||
}
|
||||
],
|
||||
STAFF: [
|
||||
{
|
||||
id: 10,
|
||||
name: 'Staff Account',
|
||||
amount: amount
|
||||
}
|
||||
]
|
||||
};
|
||||
return this.dialog.open(ReasonComponent, {
|
||||
// width: '750px'
|
||||
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)
|
||||
} else {
|
||||
return throwError("Cancelled");
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
receiveRegularPayment (type: string, amount: number): Observable<boolean> {
|
||||
return this.dialog.open(ReceivePaymentComponent, {
|
||||
// width: '750px',
|
||||
data: {
|
||||
type: type,
|
||||
amount: amount
|
||||
}
|
||||
}).afterClosed().pipe(
|
||||
switchMap((value: boolean | {id: number, name: string, amount: number}[]) => {
|
||||
if (!!value) {
|
||||
return this.bs.receivePayment(value as { id: number, name: string, amount: number }[], '')
|
||||
} else {
|
||||
return throwError("Cancelled");
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
receivePayment() {
|
||||
if (!this.receivePaymentAllowed()) {
|
||||
return;
|
||||
}
|
||||
const amount = this.bs.amountVal();
|
||||
const type = this.bs.type();
|
||||
const dialogRef = this.dialog.open(ReceivePaymentComponent, {
|
||||
// width: '750px',
|
||||
data: {
|
||||
type: type,
|
||||
amount: amount
|
||||
}
|
||||
});
|
||||
dialogRef.afterClosed().subscribe((result: boolean | { id: string, name: string, amount: number }[]) => {
|
||||
if (!!result) {
|
||||
this.bs.receivePayment(result as { id: string, name: string, amount: number }[]).subscribe(() => {
|
||||
let obs: any;
|
||||
if (type === 'NO_CHARGE' || type === 'STAFF') {
|
||||
obs = this.receivePaymentWithReason(type, amount);
|
||||
} else {
|
||||
obs = this.receiveRegularPayment(type, amount);
|
||||
}
|
||||
obs.subscribe(() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/sales']);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
moveTableAllowed(): boolean {
|
||||
if (!this.auth.hasPermission('Move Table') && !this.auth.hasPermission('Merge Tables')) {
|
||||
@ -269,8 +312,20 @@ export class SalesHomeComponent implements OnInit {
|
||||
if (!this.voidBillAllowed()) {
|
||||
return;
|
||||
}
|
||||
this.dialog.open(VoidReasonComponent, {
|
||||
this.dialog.open(ReasonComponent, {
|
||||
// width: '750px'
|
||||
data: {
|
||||
title: 'Void Reason',
|
||||
reasons: [
|
||||
'Discount',
|
||||
'Printing fault',
|
||||
'Item changed',
|
||||
'Quantity reduced',
|
||||
'Costing bill for party',
|
||||
'Cashier mistake',
|
||||
'Management free sale',
|
||||
]
|
||||
}
|
||||
}).afterClosed().pipe(
|
||||
switchMap((x: boolean | string) => {
|
||||
if (!!x) {
|
||||
|
||||
Reference in New Issue
Block a user