diff --git a/barker/views/voucher/__init__.py b/barker/views/voucher/__init__.py index 9bef5db..79f4bab 100644 --- a/barker/views/voucher/__init__.py +++ b/barker/views/voucher/__init__.py @@ -19,11 +19,14 @@ def get_tax(tax, voucher_type): def get_bill_id(voucher_type, dbsession): if voucher_type == VoucherType.KOT: return None - return ( + bill_id = ( dbsession.query(func.coalesce(func.max(Voucher.bill_id), 0) + 1) .filter(Voucher.voucher_type == voucher_type.value) .scalar() ) + if voucher_type == VoucherType.REGULAR_BILL and bill_id % 10000 == 0: + bill_id += 1 + return bill_id def do_update_table(item, guest_book, dbsession): diff --git a/barker/views/voucher/show.py b/barker/views/voucher/show.py index 488f865..c9e3caa 100644 --- a/barker/views/voucher/show.py +++ b/barker/views/voucher/show.py @@ -4,7 +4,7 @@ import uuid from pyramid.view import view_config from barker.exceptions import ValidationFailure -from barker.models import Voucher, Overview, FoodTable, GuestBook +from barker.models import Voucher, Overview, FoodTable, GuestBook, VoucherType @view_config( @@ -85,12 +85,15 @@ def show_for_table(request): def voucher_info(item): return { "id": item.id, - "date": item.date.strftime("%d-%b-%Y %H:%M:%S"), + "date": item.date.strftime("%H:%M"), + "dateTip": item.date.strftime("%d-%b-%Y %H:%M:%S"), "pax": item.pax, "user": {"id": item.user_id, "name": item.user.name}, - "creationDate": item.creation_date.strftime("%d-%b-%Y %H:%M:%S"), - "lastEditDate": item.last_edit_date.strftime("%d-%b-%Y %H:%M:%S"), - "billId": item.bill_id, + "creationDate": item.creation_date.strftime("%H:%M"), + "creationDateTip": item.creation_date.strftime("%d-%b-%Y %H:%M:%S"), + "lastEditDate": item.last_edit_date.strftime("%H:%M"), + "lastEditDateTip": item.last_edit_date.strftime("%d-%b-%Y %H:%M:%S"), + "billId": item.full_bill_id, "table": {"id": item.food_table_id, "name": item.food_table.name}, "customer": {"id": item.customer_id, "name": item.customer.name} if item.customer is not None else {}, "settlements": [], @@ -154,6 +157,7 @@ def voucher_blank(table, guest): return { "pax": table.seats if guest is None else guest.pax, "table": {"id": table.id, "name": table.name}, + "voucherType": VoucherType.KOT.name, "customer": {"id": guest.customer_id, "name": guest.customer.name} if guest is not None else {}, "kots": [] } diff --git a/bookie/src/app/sales/bill.service.ts b/bookie/src/app/sales/bill.service.ts index 53ca279..17c3d27 100644 --- a/bookie/src/app/sales/bill.service.ts +++ b/bookie/src/app/sales/bill.service.ts @@ -17,7 +17,7 @@ import { SelectionModel } from "@angular/cdk/collections"; export class BillService { public dataObs; public data: any[]; - private bill; + public bill; public netAmount: BehaviorSubject; public discountAmount: BehaviorSubject; public taxAmount: BehaviorSubject; diff --git a/bookie/src/app/sales/bills/bills.component.css b/bookie/src/app/sales/bills/bills.component.css index 1461baa..e143ad9 100644 --- a/bookie/src/app/sales/bills/bills.component.css +++ b/bookie/src/app/sales/bills/bills.component.css @@ -20,6 +20,7 @@ table { .grey900 { background-color: #1b5e20; color: #ffffff; + font-size: 1.2em; } .grey700 { @@ -51,3 +52,18 @@ table { background-color: #ffcdd2; color: #000000; } + +.deep-purple-50 { + background-color: #ede7f6; + color: #000000; +} + +.deep-purple-100 { + background-color: #d1c4e9; + color: #000000; +} + +.deep-purple-200 { + background-color: #b39ddb; + color: #000000; +} diff --git a/bookie/src/app/sales/bills/bills.component.html b/bookie/src/app/sales/bills/bills.component.html index d7efb51..d0134e7 100644 --- a/bookie/src/app/sales/bills/bills.component.html +++ b/bookie/src/app/sales/bills/bills.component.html @@ -8,22 +8,46 @@ - - - - - - - - - Amount - + + Bill / KOT number + + + {{ bs.bill.billId }} / + K-{{ bs.bill.kotId }} + + + Time / Start Time / Last Edit Time + + + + {{ bs.bill.date }} / {{ bs.bill.creationDate}} / {{ bs.bill.lastEditDate }} + + + Table / Pax / Customer + + + {{ bs.bill.table.name }} + / {{ bs.bill.pax }} / {{ bs.bill.customer.name }} + + + + + + + + + + + @@ -34,7 +58,6 @@
  • {{m.name}}
  • -
    @@ -59,33 +82,46 @@ open_in_new - {{ bs.amount | async | currency: 'INR' }} Net - {{ bs.netAmount | async | currency: 'INR' }} + {{ bs.netAmount | async | currency: 'INR' }} Discount - {{ bs.discountAmount | async | currency: 'INR' }} + {{ bs.discountAmount | async | currency: 'INR' }} Tax - {{ bs.taxAmount | async | currency: 'INR' }} + {{ bs.taxAmount | async | currency: 'INR' }} + + + Amount + + + {{ bs.amount | async | currency: 'INR' }} - + + + - +
    diff --git a/bookie/src/app/sales/home/sales-home.component.css b/bookie/src/app/sales/home/sales-home.component.css index fb099a5..1a83bcd 100644 --- a/bookie/src/app/sales/home/sales-home.component.css +++ b/bookie/src/app/sales/home/sales-home.component.css @@ -18,3 +18,7 @@ .warn { background-color: red; } + +.disabled { + background-color: #dddddd; +} diff --git a/bookie/src/app/sales/home/sales-home.component.html b/bookie/src/app/sales/home/sales-home.component.html index 07b26ab..f3c0a72 100644 --- a/bookie/src/app/sales/home/sales-home.component.html +++ b/bookie/src/app/sales/home/sales-home.component.html @@ -3,19 +3,23 @@ queryParamsHandling="preserve">

    Add Product

    - +

    Discount

    - +

    Print KOT

    - +

    Print Bill

    Back to Tables

    - +

    Receive Payment

    diff --git a/bookie/src/app/sales/home/sales-home.component.ts b/bookie/src/app/sales/home/sales-home.component.ts index b3bdeff..9ae4490 100644 --- a/bookie/src/app/sales/home/sales-home.component.ts +++ b/bookie/src/app/sales/home/sales-home.component.ts @@ -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 { @@ -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; + } } diff --git a/bookie/src/app/sales/sales.module.ts b/bookie/src/app/sales/sales.module.ts index 679fd52..8b2a329 100644 --- a/bookie/src/app/sales/sales.module.ts +++ b/bookie/src/app/sales/sales.module.ts @@ -11,7 +11,7 @@ import { MatDialogModule } from '@angular/material/dialog'; import { MatDividerModule } from '@angular/material/divider'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; -import { MatRippleModule } from '@angular/material'; +import { MatRippleModule, MatTooltipModule } from '@angular/material'; import { MatTableModule } from '@angular/material/table'; import { MatTabsModule } from '@angular/material/tabs'; import { FlexLayoutModule } from '@angular/flex-layout'; @@ -67,6 +67,7 @@ import { VoidReasonComponent } from './void-reason/void-reason.component'; MatRippleModule, MatTableModule, MatTabsModule, + MatTooltipModule, SharedModule, SalesRoutingModule ],