From 22f61427b05074b4385a6659dd2568ef7892bd47 Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Sun, 19 Mar 2023 22:44:38 +0530 Subject: [PATCH] Fix: Cashier report was only showing the last amount of aggregate items. When it was not added to info, the amount also got reset to 0 Feature: Disabled total slip for single bills --- barker/barker/printing/bill.py | 11 ++++++----- barker/barker/routers/reports/cashier_report.py | 4 +--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/barker/barker/printing/bill.py b/barker/barker/printing/bill.py index bad6928..db54d6b 100644 --- a/barker/barker/printing/bill.py +++ b/barker/barker/printing/bill.py @@ -47,12 +47,13 @@ def print_bill(voucher_id: uuid.UUID, db: Session): loop = asyncio.new_event_loop() redis: ArqRedis = loop.run_until_complete(create_pool(redis_settings)) - total = design_total(voucher, regimes, db) - loop.run_until_complete( - redis.enqueue_job( - "sent_to_printer", total, printer.address, printer.cut_code, _queue_name=f"barker:print:{printer.name}" + if len(bills > 1): + total = design_total(voucher, regimes, db) + loop.run_until_complete( + redis.enqueue_job( + "sent_to_printer", total, printer.address, printer.cut_code, _queue_name=f"barker:print:{printer.name}" + ) ) - ) for bill in bills: loop.run_until_complete( redis.enqueue_job( diff --git a/barker/barker/routers/reports/cashier_report.py b/barker/barker/routers/reports/cashier_report.py index 81072e0..901563f 100644 --- a/barker/barker/routers/reports/cashier_report.py +++ b/barker/barker/routers/reports/cashier_report.py @@ -85,8 +85,6 @@ def get_id(id_: uuid.UUID, start_date: date, finish_date: date, user: UserLink, vouchers = ( db.execute( select(Voucher) - .join(Voucher.settlements) - .join(Settlement.settle_option) .options( joinedload(Voucher.settlements, innerjoin=True).joinedload(Settlement.settle_option, innerjoin=True) ) @@ -106,7 +104,7 @@ def get_id(id_: uuid.UUID, start_date: date, finish_date: date, user: UserLink, amounts = {} for item in vouchers: for so in (so for so in item.settlements if so.settle_option.reporting_level >= ReportingLevel.Aggregate): - if so.settle_option.name not in info: + if so.settle_option.name not in amounts: if so.settle_option.reporting_level == ReportingLevel.Detailed: info[so.settle_option.name] = [] amounts[so.settle_option.name] = Decimal(0)