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
This commit is contained in:
Amritanshu Agrawal 2023-03-19 22:44:38 +05:30
parent f9fc6dba0d
commit 22f61427b0
2 changed files with 7 additions and 8 deletions

View File

@ -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(

View File

@ -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)