updated auto

This commit is contained in:
2025-10-12 12:11:32 -04:00
parent e6e13b7559
commit c69d48dd74
3 changed files with 77 additions and 10 deletions

View File

@@ -163,3 +163,59 @@ async def delete_ticket(ticket_id: int):
session.commit()
return {"ok": True}, 200
@router.post("/auto/create/nopreauth/{autoid}")
async def create_auto_ticket_no_preauth(autoid: int, request: Request):
request_body = await request.json()
gallons_delivered = request_body['gallons_delivered']
gallons_delivered = Decimal(gallons_delivered)
payment_type = 1
payment_card_id = 0
payment_status = 3
get_auto_delivery = (session
.query(Auto_Delivery)
.filter(Auto_Delivery.id == autoid)
.first())
get_todays_price = (session.query(Pricing_Oil_Oil)
.order_by(Pricing_Oil_Oil.id.desc())
.first())
gallons_put_in_home = Decimal(gallons_delivered)
todays_price = Decimal(get_todays_price.price_for_customer)
total_amount = gallons_put_in_home * todays_price
create_new_ticket = Tickets_Auto_Delivery(
customer_id = get_auto_delivery.customer_id,
account_number = get_auto_delivery.account_number,
customer_town = get_auto_delivery.customer_town,
customer_state = get_auto_delivery.customer_state,
customer_address = get_auto_delivery.customer_address,
customer_zip =get_auto_delivery.customer_zip,
customer_full_name = get_auto_delivery.customer_full_name,
oil_prices_id = get_todays_price.id,
gallons_delivered = gallons_delivered,
price_per_gallon = get_todays_price.price_for_customer,
total_amount_customer = total_amount,
fill_date = date.today(),
payment_type = payment_type,
payment_card_id = payment_card_id,
payment_status = payment_status,
)
session.add(create_new_ticket)
session.commit() # Commit all changes in one transaction
return ({
"ok": True,
"auto_ticket_id":create_new_ticket.id
}), 200