bug fixes. added auto table

This commit is contained in:
2024-12-28 15:53:59 -05:00
parent 4a2ec2418c
commit 8ad7329f78
4 changed files with 27 additions and 14 deletions

View File

@@ -79,7 +79,7 @@ class Tickets_Auto_Delivery(Base):
customer_zip = Column(VARCHAR(25))
oil_prices_id = Column(INTEGER())
fill_date = Column(DATE())
gallons_delivered = Column(DECIMAL(6, 2))
price_per_gallon = Column(DECIMAL(6, 2))

View File

@@ -39,7 +39,7 @@ async def update_auto(autoid: int, request: Request):
new_home_factor = calc_home_factor(gallons_put_in_home = gallons_put_in_home,
current_house_factor=customer_home_factor)
gallons_left_buffer = get_auto_delivery.tank_size - 30
gallons_left_buffer = int(get_auto_delivery.tank_size) - 30
get_auto_delivery.house_factor = new_home_factor
@@ -80,7 +80,6 @@ async def create_auto_ticket(autoid: int, request: Request):
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,
@@ -92,6 +91,7 @@ async def create_auto_ticket(autoid: int, request: Request):
gallons_delivered = gallons_delivered,
price_per_gallon = get_todays_price.price_for_customer,
total_amount_customer = total_amount,
fill_date = date.today(),
)

View File

@@ -68,3 +68,14 @@ def get_delivery(delivery_id_order):
return JSONResponse(content=jsonable_encoder(get_delivery), status_code=200)
@router.get("/all/profile/{customer_id}", status_code=200)
def get_autos_customers(customer_id):
get_delivery = (
session.query(Tickets_Auto_Delivery)
.filter(Tickets_Auto_Delivery.customer_id == customer_id)
.order_by(Tickets_Auto_Delivery.id.asc())
.all()
)
return JSONResponse(content=jsonable_encoder(get_delivery), status_code=200)

View File

@@ -46,6 +46,7 @@ def update_auto_customers():
# get all automatic customers
auto_customers = (session
.query(Auto_Delivery)
.filter(Auto_Delivery.last_fill != None)
.order_by(Auto_Delivery.last_updated.desc())
.limit(25))
@@ -53,6 +54,7 @@ def update_auto_customers():
# figure out days since last fill
d1 = date.today()
d0 = f.last_fill
delta = d1 - d0