From 8b2d15b9e1813b11cb5e4141a8f62db948cd03e8 Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Thu, 20 Jul 2023 07:00:20 +0530 Subject: [PATCH] Fix: Guestbook would not let you seat anyone who has any old bill. Fix: Only create a new temporal product when there is some change in the data. --- barker/barker/routers/product.py | 17 +++++++++++++++++ .../guest-book-list.component.html | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/barker/barker/routers/product.py b/barker/barker/routers/product.py index 0d145b3..d30ea4b 100644 --- a/barker/barker/routers/product.py +++ b/barker/barker/routers/product.py @@ -172,12 +172,28 @@ def update_route( ) ) ).scalar_one() + if ( + item.name == data.name + and item.units == data.units + and item.menu_category_id == data.menu_category.id_ + and item.sale_category_id == data.sale_category.id_ + and item.price == data.price + and item.has_happy_hour == data.has_happy_hour + and item.is_not_available == data.is_not_available + ): + if item.quantity != data.quantity or item.sort_order != data.sort_order: + item.quantity = data.quantity + item.sort_order = data.sort_order + db.commit() + # The product is identical. No need for a new one + return None if item.valid_till is not None: # Allow adding a product here splitting the valid from and to, but not implemented right now raise HTTPException( status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail="Product has been invalidated", ) + if item.valid_from == date_: # Update the product as valid from the the same item.name = data.name item.units = data.units @@ -187,6 +203,7 @@ def update_route( item.has_happy_hour = data.has_happy_hour item.is_not_available = data.is_not_available item.quantity = data.quantity + item.sort_order = data.sort_order db.commit() return None else: # Create a new version of the product from the new details diff --git a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.html b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.html index aa15d7e..d4189fe 100644 --- a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.html +++ b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.html @@ -58,7 +58,7 @@ mat-icon-button [routerLink]="['/sales']" [queryParams]="{ guest: row.id }" - *ngIf="!row.tableId && !row.voucherId" + *ngIf="row.status === 'old' || (!row.tableId && !row.voucherId)" > chair