From 6caeb34e8d321fd47f8c73ddf73bcfecae56390b Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Tue, 9 Sep 2025 07:14:48 +0530 Subject: [PATCH] Change: The cashier report will now split the summary and details. --- barker/barker/printing/cashier_report.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/barker/barker/printing/cashier_report.py b/barker/barker/printing/cashier_report.py index a5a1b3f..4060da5 100644 --- a/barker/barker/printing/cashier_report.py +++ b/barker/barker/printing/cashier_report.py @@ -19,7 +19,8 @@ from . import currency_format def print_cashier_report(report: CashierReport, device_id: uuid.UUID, db: Session) -> None: locale.setlocale(locale.LC_MONETARY, "en_IN") - data = design_cashier_report(report) + summary = design_cashier_report_summary(report) + details = design_cashier_report_details(report) section_id = db.execute(select(Device.section_id).where(Device.id == device_id)).scalar_one() printer = db.execute( select(Printer) @@ -32,13 +33,18 @@ def print_cashier_report(report: CashierReport, device_id: uuid.UUID, db: Sessio redis: ArqRedis = loop.run_until_complete(create_pool(redis_settings)) loop.run_until_complete( redis.enqueue_job( - "sent_to_printer", data, printer.address, printer.cut_code, _queue_name=f"barker:print:{printer.name}" + "sent_to_printer", summary, printer.address, printer.cut_code, _queue_name=f"barker:print:{printer.name}" + ) + ) + loop.run_until_complete( + redis.enqueue_job( + "sent_to_printer", details, printer.address, printer.cut_code, _queue_name=f"barker:print:{printer.name}" ) ) loop.close() -def design_cashier_report(report: CashierReport) -> str: +def design_cashier_report_summary(report: CashierReport) -> str: now = datetime.now() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES) s = f"{report.cashier.name} Checkout By {report.user.name} @ {now:%d-%b-%Y %H:%M}".center(42) s += "\n\r" + "-" * 42 @@ -48,6 +54,11 @@ def design_cashier_report(report: CashierReport) -> str: s += f"\n\r{item.name: <21} : {currency_format(item.amount): >16}" s += "\n\r" + "=" * 42 s += f"\n\rActive Cashiers : {report.cashiers}" + return s + + +def design_cashier_report_details(report: CashierReport) -> str: + s = "" for so, it in report.info.items(): s += f"\n\r--- {so} ".ljust(42, "-") for i in it: