Updated auto
This commit is contained in:
@@ -35,7 +35,12 @@ class Auto_Delivery(db.Model):
|
|||||||
autoincrement=True,
|
autoincrement=True,
|
||||||
unique=False)
|
unique=False)
|
||||||
customer_id = db.Column(db.INTEGER())
|
customer_id = db.Column(db.INTEGER())
|
||||||
customer_full_name = db.Column(db.DECIMAL(5, 2))
|
account_number = db.Column(db.VARCHAR(25))
|
||||||
|
customer_town = db.Column(db.VARCHAR(140))
|
||||||
|
customer_state = db.Column(db.Integer)
|
||||||
|
customer_address = db.Column(db.VARCHAR(1000))
|
||||||
|
customer_zip = db.Column(db.VARCHAR(25))
|
||||||
|
customer_full_name = db.Column(db.VARCHAR(250))
|
||||||
last_fill = db.Column(db.TIMESTAMP())
|
last_fill = db.Column(db.TIMESTAMP())
|
||||||
last_updated = db.Column(db.TIMESTAMP())
|
last_updated = db.Column(db.TIMESTAMP())
|
||||||
estimated_gallons_left = db.Column(db.INTEGER())
|
estimated_gallons_left = db.Column(db.INTEGER())
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
|
#
|
||||||
from app import db, ma, login_manager
|
from app import db, ma, login_manager
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ def create_customer():
|
|||||||
customer_address=customer_address,
|
customer_address=customer_address,
|
||||||
customer_apt=customer_apt,
|
customer_apt=customer_apt,
|
||||||
company_id=1,
|
company_id=1,
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
db.session.add(new_customer)
|
db.session.add(new_customer)
|
||||||
@@ -117,7 +118,7 @@ def create_customer():
|
|||||||
new_auto = Auto_Delivery(
|
new_auto = Auto_Delivery(
|
||||||
customer_id = new_customer.id,
|
customer_id = new_customer.id,
|
||||||
account_number = made_account_number,
|
account_number = made_account_number,
|
||||||
customer_full_name = new_customer.response_customer_last_name + " " + new_customer.response_customer_first_name,
|
customer_full_name = new_customer.customer_last_name + " " + new_customer.customer_first_name,
|
||||||
last_fill = None,
|
last_fill = None,
|
||||||
last_updated = None,
|
last_updated = None,
|
||||||
estimated_gallons_left = None,
|
estimated_gallons_left = None,
|
||||||
@@ -125,6 +126,9 @@ def create_customer():
|
|||||||
tank_height = None,
|
tank_height = None,
|
||||||
tank_size = None,
|
tank_size = None,
|
||||||
house_factor = 1,
|
house_factor = 1,
|
||||||
|
customer_town = new_customer.customer_town,
|
||||||
|
customer_state = new_customer.customer_state,
|
||||||
|
customer_zip = new_customer.customer_zip,
|
||||||
)
|
)
|
||||||
|
|
||||||
db.session.add(new_auto)
|
db.session.add(new_auto)
|
||||||
@@ -149,6 +153,8 @@ def edit_customer(customer_id):
|
|||||||
.query(Customer_Customer)
|
.query(Customer_Customer)
|
||||||
.filter(Customer_Customer.id == customer_id)
|
.filter(Customer_Customer.id == customer_id)
|
||||||
.first())
|
.first())
|
||||||
|
|
||||||
|
|
||||||
response_customer_last_name = request.json["customer_last_name"]
|
response_customer_last_name = request.json["customer_last_name"]
|
||||||
response_customer_first_name = request.json["customer_first_name"]
|
response_customer_first_name = request.json["customer_first_name"]
|
||||||
response_customer_town = request.json["customer_town"]
|
response_customer_town = request.json["customer_town"]
|
||||||
@@ -228,3 +234,75 @@ def customer_count():
|
|||||||
}), 200
|
}), 200
|
||||||
|
|
||||||
|
|
||||||
|
@customer.route("/automatic/status/<int:customer_id>", methods=["GET"])
|
||||||
|
@login_required
|
||||||
|
def customer_automatic_status(customer_id):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
get_customer = (db.session
|
||||||
|
.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
|
||||||
|
}), 200
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@customer.route("/automatic/assign/<int:customer_id>", methods=["GET"])
|
||||||
|
@login_required
|
||||||
|
def customer_automatic_assignment(customer_id):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
get_customer = (db.session
|
||||||
|
.query(Customer_Customer)
|
||||||
|
.filter(Customer_Customer.id == customer_id)
|
||||||
|
.first())
|
||||||
|
get_auto = (db.session
|
||||||
|
.query(Auto_Delivery)
|
||||||
|
.filter(Auto_Delivery.customer_id == customer_id)
|
||||||
|
.first())
|
||||||
|
if get_auto is None:
|
||||||
|
create_auto = Auto_Delivery(customer_id = customer_id,
|
||||||
|
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,
|
||||||
|
last_fill = datetime.utcnow(),
|
||||||
|
last_updated = None,
|
||||||
|
estimated_gallons_left = 0,
|
||||||
|
estimated_gallons_left_prev_day = None,
|
||||||
|
tank_height = None,
|
||||||
|
tank_size =None,
|
||||||
|
house_factor = None,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
db.session.add(create_auto)
|
||||||
|
if get_customer.customer_automatic == 1:
|
||||||
|
get_customer.customer_automatic = 0
|
||||||
|
status = 0
|
||||||
|
db.session.add(get_customer)
|
||||||
|
else:
|
||||||
|
get_customer.customer_automatic = 1
|
||||||
|
status = 1
|
||||||
|
db.session.add(get_customer)
|
||||||
|
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
return jsonify({
|
||||||
|
"ok": True,
|
||||||
|
'status': status
|
||||||
|
}), 200
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ def get_a_delivery(delivery_id):
|
|||||||
},
|
},
|
||||||
}), 200
|
}), 200
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@delivery.route("/past1/<int:customer_id>", methods=["GET"])
|
@delivery.route("/past1/<int:customer_id>", methods=["GET"])
|
||||||
def get_customer_past_delivery1(customer_id):
|
def get_customer_past_delivery1(customer_id):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user