added hot water
This commit is contained in:
@@ -12,6 +12,7 @@ from app.classes.customer import \
|
||||
Customer_Description_schema,\
|
||||
Customer_Tank_Inspection_schema,\
|
||||
Customer_Tank_Inspection
|
||||
from app.classes.service import Service_Parts
|
||||
from app.classes.admin import Admin_Company
|
||||
from app.classes.auto import Auto_Delivery
|
||||
from app.classes.stats_customer import Stats_Customer
|
||||
@@ -454,18 +455,33 @@ def customer_automatic_status(customer_id):
|
||||
.query(Customer_Customer)
|
||||
.filter(Customer_Customer.id == customer_id)
|
||||
.first())
|
||||
|
||||
|
||||
if get_customer.customer_automatic == 1:
|
||||
status = 1
|
||||
|
||||
|
||||
if get_customer.customer_automatic == 0:
|
||||
status = 0
|
||||
|
||||
|
||||
|
||||
|
||||
return jsonify({
|
||||
"ok": True,
|
||||
'status': status
|
||||
'status': status
|
||||
}), 200
|
||||
|
||||
|
||||
@customer.route("/automatic/deliveries", methods=["GET"])
|
||||
@login_required
|
||||
def get_all_automatic_deliveries():
|
||||
"""
|
||||
Get all automatic deliveries for the table.
|
||||
"""
|
||||
from app.classes.auto import Auto_Delivery, Auto_Delivery_schema
|
||||
try:
|
||||
deliveries = Auto_Delivery.query.all()
|
||||
schema = Auto_Delivery_schema(many=True)
|
||||
return jsonify(schema.dump(deliveries)), 200
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
|
||||
@@ -494,7 +510,12 @@ def customer_automatic_assignment(customer_id):
|
||||
.query(Customer_Tank_Inspection)
|
||||
.filter(Customer_Tank_Inspection.customer_id == customer_id)
|
||||
.first())
|
||||
|
||||
|
||||
get_service_parts = (db.session
|
||||
.query(Service_Parts)
|
||||
.filter(Service_Parts.customer_id == customer_id)
|
||||
.first())
|
||||
|
||||
if get_customer.customer_automatic == 1:
|
||||
# customer becomes will call
|
||||
get_customer.customer_automatic = 0
|
||||
@@ -505,34 +526,36 @@ def customer_automatic_assignment(customer_id):
|
||||
|
||||
status = 3
|
||||
else:
|
||||
|
||||
|
||||
if get_main_credit_card is None:
|
||||
status = 2
|
||||
return jsonify({
|
||||
"ok": True,
|
||||
'status': status
|
||||
}), 200
|
||||
|
||||
# customer becames an automatic
|
||||
|
||||
# customer becomes an automatic
|
||||
if get_auto is None:
|
||||
hot_water_value = get_service_parts.hot_water_tank if get_service_parts and get_service_parts.hot_water_tank is not None else 0
|
||||
create_auto = Auto_Delivery(customer_id=customer_id,
|
||||
customer_full_name =get_customer.customer_first_name + ' ' + get_customer.customer_last_name,
|
||||
customer_full_name=get_customer.customer_first_name + ' ' + get_customer.customer_last_name,
|
||||
account_number=get_customer.account_number,
|
||||
customer_town=get_customer.customer_town,
|
||||
customer_state=get_customer.customer_state,
|
||||
customer_zip=get_customer.customer_zip,
|
||||
customer_address=get_customer.customer_address,
|
||||
last_fill = None,
|
||||
last_updated = None,
|
||||
estimated_gallons_left = 0,
|
||||
estimated_gallons_left_prev_day = 0,
|
||||
tank_height = 0,
|
||||
tank_size = get_customer_tank.tank_size,
|
||||
house_factor = 1,
|
||||
last_fill=None,
|
||||
last_updated=None,
|
||||
estimated_gallons_left=0,
|
||||
estimated_gallons_left_prev_day=0,
|
||||
tank_height=0,
|
||||
tank_size=get_customer_tank.tank_size,
|
||||
house_factor=1,
|
||||
auto_status=1,
|
||||
days_since_last_fill=0
|
||||
days_since_last_fill=0,
|
||||
hot_water_summer=hot_water_value
|
||||
)
|
||||
|
||||
|
||||
db.session.add(create_auto)
|
||||
|
||||
|
||||
@@ -600,4 +623,4 @@ def edit_customer_tank(customer_id):
|
||||
|
||||
db.session.commit()
|
||||
|
||||
return jsonify({"ok": True}), 200
|
||||
return jsonify({"ok": True}), 200
|
||||
|
||||
Reference in New Issue
Block a user