From 5402d229f84ca9b7fefc8edab1360bc18732ec87 Mon Sep 17 00:00:00 2001 From: tanshu Date: Sat, 7 Aug 2021 17:03:16 +0530 Subject: [PATCH] Fix: Product Sale Report would overwrite old value instead of adding to it in case the product had been updated and contained multiple product versions. --- barker/barker/routers/reports/product_sale_report.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/barker/barker/routers/reports/product_sale_report.py b/barker/barker/routers/reports/product_sale_report.py index facc981..e183274 100644 --- a/barker/barker/routers/reports/product_sale_report.py +++ b/barker/barker/routers/reports/product_sale_report.py @@ -89,7 +89,9 @@ def product_sale_report(s: date, f: date, db: Session): type_ = to_camel(VoucherType(type_).name) old = [i for i in info if i["id"] == id_ and i["isHappyHour"] == hh] if len(old): - old[0][type_] = quantity + if type_ not in old[0]: + old[0][type_] = 0 + old[0][type_] += quantity else: info.append( {