Fix: Merge table did not delete the old bills and fucked up.
Fix: Bill settlement report was not in order
This commit is contained in:
parent
7da9212cf7
commit
4fffdd85d6
@ -48,7 +48,7 @@ def settlements(s: date, f: date, db: Session) -> list[BillSettlementItem]:
|
||||
.join(Voucher.settlements)
|
||||
.join(Settlement.settle_option)
|
||||
.where(Voucher.date >= start_date, Voucher.date <= finish_date)
|
||||
.order_by(Voucher.voucher_type)
|
||||
.order_by(Voucher.voucher_type, Voucher.date)
|
||||
)
|
||||
.unique()
|
||||
.scalars()
|
||||
|
@ -1,3 +1,4 @@
|
||||
import traceback
|
||||
import uuid
|
||||
|
||||
from datetime import datetime
|
||||
@ -11,6 +12,7 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from ...core.security import get_current_active_user as get_user
|
||||
from ...db.session import SessionFuture
|
||||
from ...models.bill import Bill
|
||||
from ...models.kot import Kot
|
||||
from ...models.overview import Overview
|
||||
from ...models.settlement import Settlement
|
||||
@ -127,12 +129,14 @@ def merge_table(
|
||||
check_if_voucher_is_unprinted(data.voucher_id, db)
|
||||
check_if_voucher_is_unprinted(data.new_voucher_id, db)
|
||||
db.execute(update(Kot).where(Kot.voucher_id == data.voucher_id).values(voucher_id=data.new_voucher_id))
|
||||
db.execute(delete(Bill).where(Bill.voucher_id == data.voucher_id))
|
||||
db.execute(delete(Overview).where(Overview.voucher_id == data.voucher_id))
|
||||
db.execute(delete(Settlement).where(Settlement.voucher_id == data.voucher_id))
|
||||
db.execute(delete(Voucher).where(Voucher.id == data.voucher_id))
|
||||
update_settlements([data.new_voucher_id], db)
|
||||
db.commit()
|
||||
except SQLAlchemyError as e:
|
||||
traceback.print_exc()
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=str(e),
|
||||
|
Loading…
Reference in New Issue
Block a user