From 47afb7e29cbc2cdd9944e27202ca86ecdc6dcd97 Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Fri, 24 Mar 2023 08:44:36 +0530 Subject: [PATCH] Always ensure that a "KOT" Bill Number was generated even if the bill was straight printed. --- barker/barker/routers/voucher/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/barker/barker/routers/voucher/__init__.py b/barker/barker/routers/voucher/__init__.py index cd11008..572036b 100644 --- a/barker/barker/routers/voucher/__init__.py +++ b/barker/barker/routers/voucher/__init__.py @@ -14,6 +14,7 @@ from sqlalchemy.sql import expression from ...models.guest_book import GuestBook from ...models.overview import Overview +from ...models.regime import Regime from ...models.settle_option import SettleOption from ...models.settlement import Settlement from ...models.voucher import Voucher @@ -136,7 +137,8 @@ def do_update_bill_numbers(voucher: Voucher, db: Session) -> bool: .where(Bill.voucher_id == voucher.id, Bill.regime_id.in_(old_regimes - regimes)) .values(is_valid=False) ) - + if Regime.KOT() not in old_regimes | regimes: + regimes.add(Regime.KOT()) for r in regimes - old_regimes: bill_id = db.execute( expression.select(func.coalesce(func.max(Bill.bill_number), 0) + 1).where(Bill.regime_id == r)