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

@ -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):

View File

@ -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": []
}