Fix: Editing printed bill will also print the new kot (if any)

This commit is contained in:
Amritanshu Agrawal 2021-04-24 00:45:14 +05:30
parent e144175fe0
commit 74e67a98e6

View File

@ -17,6 +17,7 @@ from ...models.settle_option import SettleOption
from ...models.voucher import Voucher
from ...models.voucher_type import VoucherType
from ...printing.bill import print_bill
from ...printing.kot import print_kot
from ...routers.voucher import do_update_settlements, get_guest_book
from ...schemas.receive_payment import ReceivePaymentItem as SettleSchema
from ...schemas.user_token import UserToken
@ -49,11 +50,15 @@ def change(
)
!= 0
)
new_kot: bool = len([k for k in data.kots if k.id_ is None and len(k.inventories) > 0]) > 0
if bill_changed:
id_ = void_and_issue_new_bill(data, u, g, old, db, user)
else:
reprint_bill(id_, user.id_, db)
db.commit()
with SessionFuture() as db:
if bill_changed and new_kot:
print_kot(id_, db)
print_bill(id_, db)
except SQLAlchemyError as e:
raise HTTPException(