Fix: Kots were not sorted in show voucher.
This commit is contained in:
@ -68,6 +68,7 @@ def from_id(
|
|||||||
.join(Inventory.product)
|
.join(Inventory.product)
|
||||||
.join(ProductVersion, onclause=product_version_onclause)
|
.join(ProductVersion, onclause=product_version_onclause)
|
||||||
.where(Voucher.id == id_)
|
.where(Voucher.id == id_)
|
||||||
|
.order_by(Kot.code)
|
||||||
.options(
|
.options(
|
||||||
contains_eager(Voucher.food_table),
|
contains_eager(Voucher.food_table),
|
||||||
contains_eager(Voucher.customer),
|
contains_eager(Voucher.customer),
|
||||||
@ -103,31 +104,28 @@ def from_bill(
|
|||||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||||
detail="Bill Number is invalid",
|
detail="Bill Number is invalid",
|
||||||
)
|
)
|
||||||
item = (
|
item: Voucher | None = db.execute(
|
||||||
db.execute(
|
select(Voucher)
|
||||||
select(Voucher)
|
.join(Voucher.bills)
|
||||||
.join(Voucher.bills)
|
.join(Bill.regime)
|
||||||
.join(Bill.regime)
|
.join(Voucher.food_table)
|
||||||
.join(Voucher.food_table)
|
.join(Voucher.customer, isouter=True)
|
||||||
.join(Voucher.customer, isouter=True)
|
.join(Voucher.kots)
|
||||||
.join(Voucher.kots)
|
.join(Kot.inventories)
|
||||||
.join(Kot.inventories)
|
.join(Inventory.product)
|
||||||
.join(Inventory.product)
|
.join(ProductVersion, onclause=product_version_onclause)
|
||||||
.join(ProductVersion, onclause=product_version_onclause)
|
.where(Regime.prefix == match.group(1), Bill.bill_number == int(match.group(2)))
|
||||||
.where(Regime.prefix == match.group(1), Bill.bill_number == int(match.group(2)))
|
.order_by(Kot.code)
|
||||||
.options(
|
.options(
|
||||||
contains_eager(Voucher.food_table),
|
contains_eager(Voucher.food_table),
|
||||||
contains_eager(Voucher.customer),
|
contains_eager(Voucher.customer),
|
||||||
contains_eager(Voucher.kots)
|
contains_eager(Voucher.kots)
|
||||||
.contains_eager(Kot.inventories)
|
.contains_eager(Kot.inventories)
|
||||||
.contains_eager(Inventory.product)
|
.contains_eager(Inventory.product)
|
||||||
.contains_eager(Product.versions),
|
.contains_eager(Product.versions),
|
||||||
contains_eager(Voucher.bills).contains_eager(Bill.regime),
|
contains_eager(Voucher.bills).contains_eager(Bill.regime),
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.scalars()
|
).scalar_one_or_none()
|
||||||
.one_or_none()
|
|
||||||
)
|
|
||||||
if item is None:
|
if item is None:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_404_NOT_FOUND,
|
status_code=status.HTTP_404_NOT_FOUND,
|
||||||
@ -183,6 +181,7 @@ def from_table(
|
|||||||
.join(Inventory.product)
|
.join(Inventory.product)
|
||||||
.join(ProductVersion, onclause=product_version_onclause)
|
.join(ProductVersion, onclause=product_version_onclause)
|
||||||
.where(Voucher.id == v)
|
.where(Voucher.id == v)
|
||||||
|
.order_by(Kot.code)
|
||||||
.options(
|
.options(
|
||||||
contains_eager(Voucher.food_table),
|
contains_eager(Voucher.food_table),
|
||||||
contains_eager(Voucher.customer),
|
contains_eager(Voucher.customer),
|
||||||
|
|||||||
Reference in New Issue
Block a user