Fix: Could not open bill with bill number or voucher id
This commit is contained in:
@ -59,7 +59,8 @@ def from_id(
|
|||||||
ProductVersion.valid_till >= Voucher.date,
|
ProductVersion.valid_till >= Voucher.date,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
item: Voucher = db.execute(
|
item: Voucher = (
|
||||||
|
db.execute(
|
||||||
select(Voucher)
|
select(Voucher)
|
||||||
.join(Voucher.food_table)
|
.join(Voucher.food_table)
|
||||||
.join(Voucher.customer, isouter=True)
|
.join(Voucher.customer, isouter=True)
|
||||||
@ -77,7 +78,10 @@ def from_id(
|
|||||||
.contains_eager(Inventory.product)
|
.contains_eager(Inventory.product)
|
||||||
.contains_eager(Product.versions),
|
.contains_eager(Product.versions),
|
||||||
)
|
)
|
||||||
).scalar_one()
|
)
|
||||||
|
.unique()
|
||||||
|
.scalar_one()
|
||||||
|
)
|
||||||
return voucher_info(item, db)
|
return voucher_info(item, db)
|
||||||
|
|
||||||
|
|
||||||
@ -104,7 +108,8 @@ 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: Voucher | None = db.execute(
|
item: Voucher | None = (
|
||||||
|
db.execute(
|
||||||
select(Voucher)
|
select(Voucher)
|
||||||
.join(Voucher.bills)
|
.join(Voucher.bills)
|
||||||
.join(Bill.regime)
|
.join(Bill.regime)
|
||||||
@ -125,7 +130,10 @@ def from_bill(
|
|||||||
.contains_eager(Product.versions),
|
.contains_eager(Product.versions),
|
||||||
contains_eager(Voucher.bills).contains_eager(Bill.regime),
|
contains_eager(Voucher.bills).contains_eager(Bill.regime),
|
||||||
)
|
)
|
||||||
).scalar_one_or_none()
|
)
|
||||||
|
.unique()
|
||||||
|
.scalar_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,
|
||||||
@ -192,8 +200,7 @@ def from_table(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.unique()
|
.unique()
|
||||||
.scalars()
|
.scalar_one()
|
||||||
.one()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if guest is not None:
|
if guest is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user