Fix: get_bill_id now skips the 10000th number so that it displays properly in our system

Bill now shows the bill details on the top

Started adding checks for disabled features during sales.
This commit is contained in:
Amritanshu
2019-08-18 22:05:33 +05:30
parent e697631cd4
commit 55ec2f8763
9 changed files with 167 additions and 37 deletions

View File

@ -39,6 +39,9 @@ export class SalesHomeComponent implements OnInit {
}
printKot() {
if (!this.printKotAllowed()) {
return;
}
let guestBookId = null;
if (this.route.snapshot.queryParamMap.has('guest')) {
guestBookId = this.route.snapshot.queryParamMap.get('guest');
@ -50,9 +53,10 @@ export class SalesHomeComponent implements OnInit {
}
discount(): void {
if (this.auth.hasPermission('Discount')) {
this.showDiscount().subscribe();
if (!this.discountAllowed()) {
return;
}
this.showDiscount().subscribe();
}
showDiscount(): Observable<boolean | { id: string, name: string, discount: number }[]> {
@ -106,6 +110,9 @@ export class SalesHomeComponent implements OnInit {
}
printBill() {
if (!this.printBillAllowed()) {
return;
}
const canGiveDiscount = this.auth.hasPermission('Discount');
let guestBookId = null;
if (this.route.snapshot.queryParamMap.has('guest')) {
@ -130,6 +137,9 @@ export class SalesHomeComponent implements OnInit {
}
receivePayment() {
if (!this.receivePaymentAllowed()) {
return;
}
const amount = this.bs.amountVal();
const type = this.bs.type();
const dialogRef = this.dialog.open(ReceivePaymentComponent, {
@ -241,4 +251,56 @@ export class SalesHomeComponent implements OnInit {
this.toaster.show('Error', x);
});
}
discountAllowed(): boolean {
return this.auth.hasPermission('Discount');
}
printKotAllowed(): boolean {
if (!this.auth.hasPermission('Print Kot')) {
return false;
}
if (!this.bs.bill.id) {
return true;
}
if (this.bs.bill.voucherType !== PrintType.Kot) {
return false;
}
if (this.bs.bill.isVoid) {
return false;
}
return true;
}
printBillAllowed(): boolean {
if (!this.auth.hasPermission('Print Bill')) {
return false;
}
if (!this.bs.bill.id) {
return true;
}
if (this.bs.bill.voucherType !== PrintType.Kot && !this.auth.hasPermission('Edit Printed Bill')) {
return false;
}
if (this.bs.bill.isVoid) {
return false;
}
return true;
}
receivePaymentAllowed(): boolean {
if (!this.auth.hasPermission('Settle Bill')) {
return false;
}
if (!this.bs.bill.id) {
return false;
}
if (this.bs.bill.voucherType === PrintType.Kot) {
return false
}
if (this.bs.bill.isVoid) {
return false;
}
return true;
}
}