added auto info to ticket
This commit is contained in:
@@ -237,84 +237,72 @@ def create_customer():
|
|||||||
user_long = None
|
user_long = None
|
||||||
cor_ad = False
|
cor_ad = False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
see_if_customer_exists = (db.session
|
new_customer = Customer_Customer(
|
||||||
.query(Customer_Customer)
|
account_number=made_account_number,
|
||||||
.filter(Customer_Customer.response_customer_last_name)
|
customer_last_name=response_customer_last_name,
|
||||||
.filter(Customer_Customer.response_customer_first_name)
|
customer_first_name=response_customer_first_name,
|
||||||
.filter(Customer_Customer.customer_phone_number)
|
customer_town=response_customer_town,
|
||||||
.first())
|
customer_state=response_customer_state,
|
||||||
if see_if_customer_exists is not None:
|
customer_zip=response_customer_zip,
|
||||||
return jsonify({
|
customer_first_call=now,
|
||||||
"ok": False,
|
customer_email=response_customer_email,
|
||||||
'customer': see_if_customer_exists.id
|
customer_automatic=0,
|
||||||
}), 200
|
customer_home_type=int_customer_home_type,
|
||||||
else:
|
customer_phone_number=customer_phone_number,
|
||||||
|
customer_address=customer_address,
|
||||||
|
customer_apt=customer_apt,
|
||||||
|
company_id=1,
|
||||||
|
customer_latitude=user_lat,
|
||||||
|
customer_longitude=user_long,
|
||||||
|
correct_address=cor_ad
|
||||||
|
)
|
||||||
|
db.session.add(new_customer)
|
||||||
|
db.session.flush()
|
||||||
|
|
||||||
|
create_stats_customer = Stats_Customer(
|
||||||
|
customer_id = new_customer.id,
|
||||||
|
total_calls = 0,
|
||||||
|
service_calls_total = 0,
|
||||||
|
service_calls_total_spent = 0,
|
||||||
|
service_calls_total_profit = 0,
|
||||||
|
oil_deliveries = 0,
|
||||||
|
oil_total_gallons = 0,
|
||||||
|
oil_total_spent = 0,
|
||||||
|
oil_total_profit = 0,
|
||||||
|
)
|
||||||
|
db.session.add(create_stats_customer)
|
||||||
|
|
||||||
new_customer = Customer_Customer(
|
new_description = Customer_Description(
|
||||||
account_number=made_account_number,
|
customer_id = new_customer.id,
|
||||||
customer_last_name=response_customer_last_name,
|
account_number = made_account_number,
|
||||||
customer_first_name=response_customer_first_name,
|
description = customer_description_msg,
|
||||||
customer_town=response_customer_town,
|
fill_location=None,
|
||||||
customer_state=response_customer_state,
|
company_id=1,
|
||||||
customer_zip=response_customer_zip,
|
)
|
||||||
customer_first_call=now,
|
db.session.add(new_description)
|
||||||
customer_email=response_customer_email,
|
|
||||||
customer_automatic=0,
|
|
||||||
customer_home_type=int_customer_home_type,
|
|
||||||
customer_phone_number=customer_phone_number,
|
|
||||||
customer_address=customer_address,
|
|
||||||
customer_apt=customer_apt,
|
|
||||||
company_id=1,
|
|
||||||
customer_latitude=user_lat,
|
|
||||||
customer_longitude=user_long,
|
|
||||||
correct_address=cor_ad
|
|
||||||
)
|
|
||||||
db.session.add(new_customer)
|
|
||||||
db.session.flush()
|
|
||||||
|
|
||||||
create_stats_customer = Stats_Customer(
|
new_tank = Customer_Tank_Inspection(
|
||||||
customer_id = new_customer.id,
|
customer_id = new_customer.id,
|
||||||
total_calls = 0,
|
last_tank_inspection=None,
|
||||||
service_calls_total = 0,
|
tank_status = False,
|
||||||
service_calls_total_spent = 0,
|
outside_or_inside = True,
|
||||||
service_calls_total_profit = 0,
|
tank_size=275,
|
||||||
oil_deliveries = 0,
|
)
|
||||||
oil_total_gallons = 0,
|
db.session.add(new_tank)
|
||||||
oil_total_spent = 0,
|
|
||||||
oil_total_profit = 0,
|
|
||||||
)
|
|
||||||
db.session.add(create_stats_customer)
|
|
||||||
|
|
||||||
new_description = Customer_Description(
|
|
||||||
customer_id = new_customer.id,
|
|
||||||
account_number = made_account_number,
|
|
||||||
description = customer_description_msg,
|
|
||||||
fill_location=None,
|
|
||||||
company_id=1,
|
|
||||||
)
|
|
||||||
db.session.add(new_description)
|
|
||||||
|
|
||||||
new_tank = Customer_Tank_Inspection(
|
|
||||||
customer_id = new_customer.id,
|
|
||||||
last_tank_inspection=None,
|
|
||||||
tank_status = False,
|
|
||||||
outside_or_inside = True,
|
|
||||||
tank_size=275,
|
|
||||||
)
|
|
||||||
db.session.add(new_tank)
|
|
||||||
|
|
||||||
|
db.session.commit()
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"ok": True,
|
"ok": True,
|
||||||
'user': {
|
'user': {
|
||||||
'user_id': new_customer.id,
|
'user_id': new_customer.id,
|
||||||
'user_name': new_customer.customer_last_name,
|
'user_name': new_customer.customer_last_name,
|
||||||
'user_email': new_customer.customer_email,
|
'user_email': new_customer.customer_email,
|
||||||
},
|
},
|
||||||
}), 200
|
}), 200
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -563,11 +551,6 @@ def edit_customer_tank(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_auto_info = (db.session
|
|
||||||
.query(Auto_Delivery)
|
|
||||||
.filter(Auto_Delivery.customer_id == customer_id)
|
|
||||||
.first())
|
|
||||||
|
|
||||||
|
|
||||||
response_tank_status = request.json["tank_status"]
|
response_tank_status = request.json["tank_status"]
|
||||||
|
|
||||||
@@ -596,11 +579,19 @@ def edit_customer_tank(customer_id):
|
|||||||
|
|
||||||
get_customer_tank.last_tank_inspection = response_last_tank_inspection
|
get_customer_tank.last_tank_inspection = response_last_tank_inspection
|
||||||
get_customer_tank.tank_size = response_tank_size
|
get_customer_tank.tank_size = response_tank_size
|
||||||
get_auto_info.tank_size = response_tank_size
|
|
||||||
|
|
||||||
get_customer_description.fill_location = response_customer_fill_location
|
get_customer_description.fill_location = response_customer_fill_location
|
||||||
|
if get_customer.customer_automatic == 1:
|
||||||
|
get_auto_info = (db.session
|
||||||
|
.query(Auto_Delivery)
|
||||||
|
.filter(Auto_Delivery.customer_id == customer_id)
|
||||||
|
.first())
|
||||||
|
|
||||||
|
get_auto_info.tank_size = response_tank_size
|
||||||
|
db.session.add(get_auto_info)
|
||||||
|
|
||||||
|
|
||||||
db.session.add(get_customer_description)
|
db.session.add(get_customer_description)
|
||||||
|
|
||||||
db.session.add(get_customer)
|
db.session.add(get_customer)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ from app.classes.pricing import Pricing_Oil_Oil
|
|||||||
from app.classes.auth import Auth_User
|
from app.classes.auth import Auth_User
|
||||||
from app.classes.promo import Promo_Promo
|
from app.classes.promo import Promo_Promo
|
||||||
from app.classes.stats_customer import Stats_Customer
|
from app.classes.stats_customer import Stats_Customer
|
||||||
|
from app.classes.auto import Tickets_Auto_Delivery, Tickets_Auto_Delivery_schema
|
||||||
|
|
||||||
@delivery.route("/updatestatus", methods=["GET"])
|
@delivery.route("/updatestatus", methods=["GET"])
|
||||||
def move_deliveries():
|
def move_deliveries():
|
||||||
@@ -154,6 +154,16 @@ def get_customer_past_delivery2(customer_id):
|
|||||||
delivery_schema = Delivery_Delivery_schema(many=True)
|
delivery_schema = Delivery_Delivery_schema(many=True)
|
||||||
return jsonify(delivery_schema.dump(get_customer_past_delivery))
|
return jsonify(delivery_schema.dump(get_customer_past_delivery))
|
||||||
|
|
||||||
|
@delivery.route("/auto/<int:customer_id>", methods=["GET"])
|
||||||
|
def get_customer_auto_delivery(customer_id):
|
||||||
|
get_customer_past_delivery = (db.session
|
||||||
|
.query(Tickets_Auto_Delivery)
|
||||||
|
.filter(Tickets_Auto_Delivery.customer_id == customer_id)
|
||||||
|
.limit(5))
|
||||||
|
|
||||||
|
delivery_schema = Tickets_Auto_Delivery_schema(many=True)
|
||||||
|
return jsonify(delivery_schema.dump(get_customer_past_delivery))
|
||||||
|
|
||||||
|
|
||||||
@delivery.route("/order/<int:delivery_id>", methods=["GET"])
|
@delivery.route("/order/<int:delivery_id>", methods=["GET"])
|
||||||
def get_a_specific_delivery(delivery_id):
|
def get_a_specific_delivery(delivery_id):
|
||||||
|
|||||||
Reference in New Issue
Block a user