bug auto finalize
This commit is contained in:
@@ -34,9 +34,9 @@ async def update_auto(autoid: int, request: Request):
|
|||||||
if auto_customer.open_ticket_id is None:
|
if auto_customer.open_ticket_id is None:
|
||||||
raise HTTPException(status_code=400, detail="No open ticket found for this auto-delivery. Cannot confirm delivery.")
|
raise HTTPException(status_code=400, detail="No open ticket found for this auto-delivery. Cannot confirm delivery.")
|
||||||
|
|
||||||
|
|
||||||
ticket = session.query(Tickets_Auto_Delivery).filter(Tickets_Auto_Delivery.id == auto_customer.open_ticket_id).first()
|
ticket = session.query(Tickets_Auto_Delivery).filter(Tickets_Auto_Delivery.id == auto_customer.open_ticket_id).first()
|
||||||
if not ticket:
|
|
||||||
raise HTTPException(status_code=404, detail=f"Open ticket with ID {auto_customer.open_ticket_id} not found.")
|
|
||||||
|
|
||||||
ticket.gallons_delivered = gallons_delivered
|
ticket.gallons_delivered = gallons_delivered
|
||||||
ticket.total_amount_customer = ticket.price_per_gallon * gallons_delivered
|
ticket.total_amount_customer = ticket.price_per_gallon * gallons_delivered
|
||||||
@@ -52,6 +52,7 @@ async def update_auto(autoid: int, request: Request):
|
|||||||
return {"ok": True, "message": "Delivery confirmed and customer factor refined successfully."}
|
return {"ok": True, "message": "Delivery confirmed and customer factor refined successfully."}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(str(e))
|
||||||
session.rollback()
|
session.rollback()
|
||||||
raise HTTPException(status_code=500, detail=f"An internal error occurred: {str(e)}")
|
raise HTTPException(status_code=500, detail=f"An internal error occurred: {str(e)}")
|
||||||
|
|
||||||
@@ -176,6 +177,10 @@ async def create_auto_ticket_no_preauth(autoid: int, request: Request):
|
|||||||
payment_status=payment_status,
|
payment_status=payment_status,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
estimator = FuelEstimator(session=session)
|
||||||
|
estimator.refine_factor_after_delivery(ticket=create_new_ticket)
|
||||||
|
|
||||||
|
|
||||||
session.add(create_new_ticket)
|
session.add(create_new_ticket)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user