From a174f6b847e272946303270a893b5ddbe7e9593b Mon Sep 17 00:00:00 2001 From: tanshu Date: Wed, 29 Dec 2021 07:49:23 +0530 Subject: [PATCH] Fix: Product sale report would mix different product versions as it was checking the product id and not version id Feature: Cannot add na product to bill --- barker/barker/models/sale_category.py | 4 ++++ barker/barker/routers/modifier_category.py | 6 ++---- barker/barker/routers/reports/product_sale_report.py | 4 ++-- bookie/src/app/sales/products/products.component.ts | 3 +++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/barker/barker/models/sale_category.py b/barker/barker/models/sale_category.py index a7869c8..f3b14cb 100644 --- a/barker/barker/models/sale_category.py +++ b/barker/barker/models/sale_category.py @@ -22,3 +22,7 @@ class SaleCategory(Base): self.discount_limit = discount_limit if discount_limit is not None else 1 self.tax_id = tax_id self.id = id_ + + @classmethod + def cash_charges(cls): + return uuid.UUID("f3d6441a-7018-4454-9704-6b99db9333c7") diff --git a/barker/barker/routers/modifier_category.py b/barker/barker/routers/modifier_category.py index c03517b..2219203 100644 --- a/barker/barker/routers/modifier_category.py +++ b/barker/barker/routers/modifier_category.py @@ -179,13 +179,11 @@ def for_product( "maximum": item.maximum, "isActive": item.is_active, "modifiers": [ - {"id": m.id, "name": m.name, "price": m.price} - for m in item.modifiers - if m.is_active == True # noqa: E712 + {"id": m.id, "name": m.name, "price": m.price} for m in item.modifiers if m.is_active is True ], } for item in product.modifier_categories - if item.is_active == True + if item.is_active is True ] diff --git a/barker/barker/routers/reports/product_sale_report.py b/barker/barker/routers/reports/product_sale_report.py index ca79190..d0e455e 100644 --- a/barker/barker/routers/reports/product_sale_report.py +++ b/barker/barker/routers/reports/product_sale_report.py @@ -51,7 +51,7 @@ def product_sale_report(s: date, f: date, db: Session): day = func.date_trunc("day", Voucher.date - timedelta(minutes=settings.NEW_DAY_OFFSET_MINUTES)).label("day") list_ = db.execute( select( - ProductVersion.product_id, + ProductVersion.id, ProductVersion.full_name, Voucher.voucher_type, Inventory.is_happy_hour, @@ -77,7 +77,7 @@ def product_sale_report(s: date, f: date, db: Session): .group_by( SaleCategory.name, MenuCategory.name, - ProductVersion.product_id, + ProductVersion.id, ProductVersion.full_name, Voucher.voucher_type, Inventory.is_happy_hour, diff --git a/bookie/src/app/sales/products/products.component.ts b/bookie/src/app/sales/products/products.component.ts index b54b4cd..d6adfdb 100644 --- a/bookie/src/app/sales/products/products.component.ts +++ b/bookie/src/app/sales/products/products.component.ts @@ -22,6 +22,9 @@ export class ProductsComponent implements OnInit { } addProduct(product: Product): void { + if (product.isNotAvailable) { + return; + } this.bs.addProduct(product, 1, 0); } }