Change: The cashier report will now split the summary and details.
This commit is contained in:
@ -19,7 +19,8 @@ from . import currency_format
|
|||||||
|
|
||||||
def print_cashier_report(report: CashierReport, device_id: uuid.UUID, db: Session) -> None:
|
def print_cashier_report(report: CashierReport, device_id: uuid.UUID, db: Session) -> None:
|
||||||
locale.setlocale(locale.LC_MONETARY, "en_IN")
|
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()
|
section_id = db.execute(select(Device.section_id).where(Device.id == device_id)).scalar_one()
|
||||||
printer = db.execute(
|
printer = db.execute(
|
||||||
select(Printer)
|
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))
|
redis: ArqRedis = loop.run_until_complete(create_pool(redis_settings))
|
||||||
loop.run_until_complete(
|
loop.run_until_complete(
|
||||||
redis.enqueue_job(
|
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()
|
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)
|
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 = f"{report.cashier.name} Checkout By {report.user.name} @ {now:%d-%b-%Y %H:%M}".center(42)
|
||||||
s += "\n\r" + "-" * 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 += f"\n\r{item.name: <21} : {currency_format(item.amount): >16}"
|
||||||
s += "\n\r" + "=" * 42
|
s += "\n\r" + "=" * 42
|
||||||
s += f"\n\rActive Cashiers : {report.cashiers}"
|
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():
|
for so, it in report.info.items():
|
||||||
s += f"\n\r--- {so} ".ljust(42, "-")
|
s += f"\n\r--- {so} ".ljust(42, "-")
|
||||||
for i in it:
|
for i in it:
|
||||||
|
|||||||
Reference in New Issue
Block a user