added hot water
This commit is contained in:
@@ -58,7 +58,7 @@ class Auto_Delivery(db.Model):
|
|||||||
tank_height = db.Column(db.VARCHAR(25))
|
tank_height = db.Column(db.VARCHAR(25))
|
||||||
tank_size = db.Column(db.VARCHAR(25))
|
tank_size = db.Column(db.VARCHAR(25))
|
||||||
house_factor = db.Column(db.DECIMAL(5, 2))
|
house_factor = db.Column(db.DECIMAL(5, 2))
|
||||||
|
hot_water_summer = db.Column(db.Integer)
|
||||||
#0 = waiting
|
#0 = waiting
|
||||||
#1 = waiting for delivery
|
#1 = waiting for delivery
|
||||||
auto_status = db.Column(db.INTEGER())
|
auto_status = db.Column(db.INTEGER())
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class Service_Parts(db.Model):
|
|||||||
oil_filter_2 = db.Column(db.VARCHAR(100))
|
oil_filter_2 = db.Column(db.VARCHAR(100))
|
||||||
oil_nozzle = db.Column(db.VARCHAR(10))
|
oil_nozzle = db.Column(db.VARCHAR(10))
|
||||||
oil_nozzle_2 = db.Column(db.VARCHAR(10))
|
oil_nozzle_2 = db.Column(db.VARCHAR(10))
|
||||||
|
hot_water_tank = db.Column(db.INTEGER)
|
||||||
|
|
||||||
|
|
||||||
class Service_Parts_schema(ma.SQLAlchemyAutoSchema):
|
class Service_Parts_schema(ma.SQLAlchemyAutoSchema):
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from app.classes.customer import \
|
|||||||
Customer_Description_schema,\
|
Customer_Description_schema,\
|
||||||
Customer_Tank_Inspection_schema,\
|
Customer_Tank_Inspection_schema,\
|
||||||
Customer_Tank_Inspection
|
Customer_Tank_Inspection
|
||||||
|
from app.classes.service import Service_Parts
|
||||||
from app.classes.admin import Admin_Company
|
from app.classes.admin import Admin_Company
|
||||||
from app.classes.auto import Auto_Delivery
|
from app.classes.auto import Auto_Delivery
|
||||||
from app.classes.stats_customer import Stats_Customer
|
from app.classes.stats_customer import Stats_Customer
|
||||||
@@ -454,18 +455,33 @@ def customer_automatic_status(customer_id):
|
|||||||
.query(Customer_Customer)
|
.query(Customer_Customer)
|
||||||
.filter(Customer_Customer.id == customer_id)
|
.filter(Customer_Customer.id == customer_id)
|
||||||
.first())
|
.first())
|
||||||
|
|
||||||
if get_customer.customer_automatic == 1:
|
if get_customer.customer_automatic == 1:
|
||||||
status = 1
|
status = 1
|
||||||
|
|
||||||
if get_customer.customer_automatic == 0:
|
if get_customer.customer_automatic == 0:
|
||||||
status = 0
|
status = 0
|
||||||
|
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"ok": True,
|
"ok": True,
|
||||||
'status': status
|
'status': status
|
||||||
}), 200
|
}), 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)
|
.query(Customer_Tank_Inspection)
|
||||||
.filter(Customer_Tank_Inspection.customer_id == customer_id)
|
.filter(Customer_Tank_Inspection.customer_id == customer_id)
|
||||||
.first())
|
.first())
|
||||||
|
|
||||||
|
get_service_parts = (db.session
|
||||||
|
.query(Service_Parts)
|
||||||
|
.filter(Service_Parts.customer_id == customer_id)
|
||||||
|
.first())
|
||||||
|
|
||||||
if get_customer.customer_automatic == 1:
|
if get_customer.customer_automatic == 1:
|
||||||
# customer becomes will call
|
# customer becomes will call
|
||||||
get_customer.customer_automatic = 0
|
get_customer.customer_automatic = 0
|
||||||
@@ -505,34 +526,36 @@ def customer_automatic_assignment(customer_id):
|
|||||||
|
|
||||||
status = 3
|
status = 3
|
||||||
else:
|
else:
|
||||||
|
|
||||||
if get_main_credit_card is None:
|
if get_main_credit_card is None:
|
||||||
status = 2
|
status = 2
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"ok": True,
|
"ok": True,
|
||||||
'status': status
|
'status': status
|
||||||
}), 200
|
}), 200
|
||||||
|
|
||||||
# customer becames an automatic
|
# customer becomes an automatic
|
||||||
if get_auto is None:
|
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,
|
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,
|
account_number=get_customer.account_number,
|
||||||
customer_town=get_customer.customer_town,
|
customer_town=get_customer.customer_town,
|
||||||
customer_state=get_customer.customer_state,
|
customer_state=get_customer.customer_state,
|
||||||
customer_zip=get_customer.customer_zip,
|
customer_zip=get_customer.customer_zip,
|
||||||
customer_address=get_customer.customer_address,
|
customer_address=get_customer.customer_address,
|
||||||
last_fill = None,
|
last_fill=None,
|
||||||
last_updated = None,
|
last_updated=None,
|
||||||
estimated_gallons_left = 0,
|
estimated_gallons_left=0,
|
||||||
estimated_gallons_left_prev_day = 0,
|
estimated_gallons_left_prev_day=0,
|
||||||
tank_height = 0,
|
tank_height=0,
|
||||||
tank_size = get_customer_tank.tank_size,
|
tank_size=get_customer_tank.tank_size,
|
||||||
house_factor = 1,
|
house_factor=1,
|
||||||
auto_status=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)
|
db.session.add(create_auto)
|
||||||
|
|
||||||
|
|
||||||
@@ -600,4 +623,4 @@ def edit_customer_tank(customer_id):
|
|||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
return jsonify({"ok": True}), 200
|
return jsonify({"ok": True}), 200
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from app.classes.service import (Service_Service,
|
|||||||
Service_Service_schema, Service_Parts, Service_Parts_schema,
|
Service_Service_schema, Service_Parts, Service_Parts_schema,
|
||||||
Service_Plans, Service_Plans_schema
|
Service_Plans, Service_Plans_schema
|
||||||
)
|
)
|
||||||
|
from app.classes.auto import Auto_Delivery
|
||||||
|
|
||||||
@service.route("/all", methods=["GET"])
|
@service.route("/all", methods=["GET"])
|
||||||
def get_all_service_calls():
|
def get_all_service_calls():
|
||||||
@@ -359,23 +359,35 @@ def get_service_parts(customer_id):
|
|||||||
else:
|
else:
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"customer_id": customer_id, "oil_filter": "", "oil_filter_2": "",
|
"customer_id": customer_id, "oil_filter": "", "oil_filter_2": "",
|
||||||
"oil_nozzle": "", "oil_nozzle_2": ""
|
"oil_nozzle": "", "oil_nozzle_2": "", "hot_water_tank": 0
|
||||||
}), 200
|
}), 200
|
||||||
|
|
||||||
@service.route("/parts/update/<int:customer_id>", methods=["POST"])
|
@service.route("/parts/update/<int:customer_id>", methods=["POST"])
|
||||||
def update_service_parts(customer_id):
|
def update_service_parts(customer_id):
|
||||||
data = request.get_json()
|
|
||||||
if not data:
|
|
||||||
return jsonify({"error": "No data provided"}), 400
|
|
||||||
parts = Service_Parts.query.filter_by(customer_id=customer_id).first()
|
|
||||||
if not parts:
|
|
||||||
parts = Service_Parts(customer_id=customer_id)
|
|
||||||
db.session.add(parts)
|
|
||||||
parts.oil_filter = data.get('oil_filter', parts.oil_filter)
|
|
||||||
parts.oil_filter_2 = data.get('oil_filter_2', parts.oil_filter_2)
|
|
||||||
parts.oil_nozzle = data.get('oil_nozzle', parts.oil_nozzle)
|
|
||||||
parts.oil_nozzle_2 = data.get('oil_nozzle_2', parts.oil_nozzle_2)
|
|
||||||
try:
|
try:
|
||||||
|
data = request.get_json()
|
||||||
|
|
||||||
|
if not data:
|
||||||
|
return jsonify({"error": "No data provided"}), 400
|
||||||
|
|
||||||
|
get_customer = db.session.query(Customer_Customer).filter(Customer_Customer.id == customer_id).first()
|
||||||
|
parts = Service_Parts.query.filter_by(customer_id=customer_id).first()
|
||||||
|
if not parts:
|
||||||
|
parts = Service_Parts(customer_id=customer_id)
|
||||||
|
db.session.add(parts)
|
||||||
|
parts.oil_filter = data.get('oil_filter', parts.oil_filter)
|
||||||
|
parts.oil_filter_2 = data.get('oil_filter_2', parts.oil_filter_2)
|
||||||
|
parts.oil_nozzle = data.get('oil_nozzle', parts.oil_nozzle)
|
||||||
|
parts.oil_nozzle_2 = data.get('oil_nozzle_2', parts.oil_nozzle_2)
|
||||||
|
parts.hot_water_tank = data.get('hot_water_tank', parts.hot_water_tank if parts.hot_water_tank is not None else 0)
|
||||||
|
|
||||||
|
# Sync to Auto_Delivery if customer is automatic
|
||||||
|
if get_customer and get_customer.customer_automatic == 1:
|
||||||
|
get_auto = db.session.query(Auto_Delivery).filter(Auto_Delivery.customer_id == customer_id).first()
|
||||||
|
if get_auto:
|
||||||
|
get_auto.hot_water_summer = parts.hot_water_tank
|
||||||
|
db.session.add(get_auto)
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return jsonify({"ok": True, "message": "Service parts updated successfully"}), 200
|
return jsonify({"ok": True, "message": "Service parts updated successfully"}), 200
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -383,6 +395,7 @@ def update_service_parts(customer_id):
|
|||||||
return jsonify({"error": str(e)}), 500
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@service.route("/payment/<int:service_id>/<int:payment_type>", methods=["PUT"])
|
@service.route("/payment/<int:service_id>/<int:payment_type>", methods=["PUT"])
|
||||||
def process_service_payment(service_id, payment_type):
|
def process_service_payment(service_id, payment_type):
|
||||||
service = db.session.query(Service_Service).filter(Service_Service.id == service_id).first()
|
service = db.session.query(Service_Service).filter(Service_Service.id == service_id).first()
|
||||||
|
|||||||
Reference in New Issue
Block a user