Fix: Bill when printed was mangling up the taxes and amounts massively.
This was when we would make a dictionary of inventories and update quantities.
This commit is contained in:
parent
2612da063b
commit
12f63cec73
|
@ -40,13 +40,15 @@ def print_bill(voucher_id: uuid.UUID, db: Session):
|
||||||
key = (
|
key = (
|
||||||
i.product_id,
|
i.product_id,
|
||||||
i.is_happy_hour,
|
i.is_happy_hour,
|
||||||
tuple(m.modifier_id for m in i.modifiers if m.modifier.show_in_bill),
|
frozenset(m.modifier_id for m in i.modifiers if m.modifier.show_in_bill),
|
||||||
)
|
)
|
||||||
if key in items_dict:
|
if key in items_dict:
|
||||||
items_dict[key].quantity += i.quantity
|
items_dict[key].quantity += i.quantity
|
||||||
|
i.quantity = 0
|
||||||
else:
|
else:
|
||||||
items_dict[key] = i
|
items_dict[key] = i
|
||||||
|
|
||||||
|
for i in [it for it in items_dict.values() if it.quantity != 0]:
|
||||||
get_tax_item(i.tax.id, i.tax.name, i.tax_amount, tax)
|
get_tax_item(i.tax.id, i.tax.name, i.tax_amount, tax)
|
||||||
data = design_bill(voucher, items_dict.values(), tax.values(), db)
|
data = design_bill(voucher, items_dict.values(), tax.values(), db)
|
||||||
redis: ArqRedis = asyncio.run(create_pool(redis_settings))
|
redis: ArqRedis = asyncio.run(create_pool(redis_settings))
|
||||||
|
|
|
@ -69,12 +69,12 @@ def delete_route(
|
||||||
with SessionFuture() as db:
|
with SessionFuture() as db:
|
||||||
if db.execute(select(count(user_roles.c.id)).where(user_roles.c.role_id == id_)).scalar_one() > 0:
|
if db.execute(select(count(user_roles.c.id)).where(user_roles.c.role_id == id_)).scalar_one() > 0:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_501_NOT_IMPLEMENTED,
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||||
detail="This Role has been assigned to users and cannot be deleted.",
|
detail="This Role has been assigned to users and cannot be deleted.",
|
||||||
)
|
)
|
||||||
if db.execute(select(count(role_permissions.c.id)).where(role_permissions.c.role_id == id_)).scalar_one() > 0:
|
if db.execute(select(count(role_permissions.c.id)).where(role_permissions.c.role_id == id_)).scalar_one() > 0:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_501_NOT_IMPLEMENTED,
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||||
detail="This Role has permissions and cannot be deleted.",
|
detail="This Role has permissions and cannot be deleted.",
|
||||||
)
|
)
|
||||||
item: Role = db.execute(select(Role).where(Role.id == id_)).scalar_one()
|
item: Role = db.execute(select(Role).where(Role.id == id_)).scalar_one()
|
||||||
|
|
|
@ -55,9 +55,11 @@ def save(
|
||||||
if update_table:
|
if update_table:
|
||||||
do_update_table(item, guest_book, db)
|
do_update_table(item, guest_book, db)
|
||||||
db.commit()
|
db.commit()
|
||||||
print_kot(item.id, db)
|
voucher_id = item.id
|
||||||
|
with SessionFuture() as db:
|
||||||
|
print_kot(voucher_id, db)
|
||||||
if item.voucher_type != VoucherType.KOT:
|
if item.voucher_type != VoucherType.KOT:
|
||||||
print_bill(item.id, db)
|
print_bill(voucher_id, db)
|
||||||
except SQLAlchemyError as e:
|
except SQLAlchemyError as e:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||||
|
|
|
@ -169,10 +169,12 @@ def update_route(
|
||||||
if update_table:
|
if update_table:
|
||||||
do_update_table(item, guest_book, db)
|
do_update_table(item, guest_book, db)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
voucher_id = item.id
|
||||||
|
with SessionFuture() as db:
|
||||||
if need_to_print_kot:
|
if need_to_print_kot:
|
||||||
print_kot(item.id, db)
|
print_kot(voucher_id, db)
|
||||||
if item.voucher_type != VoucherType.KOT:
|
if item.voucher_type != VoucherType.KOT:
|
||||||
print_bill(item.id, db)
|
print_bill(voucher_id, db)
|
||||||
except SQLAlchemyError as e:
|
except SQLAlchemyError as e:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||||
|
|
Loading…
Reference in New Issue