Added automatic stuff
This commit is contained in:
@@ -129,6 +129,7 @@ def create_customer():
|
||||
customer_town = new_customer.customer_town,
|
||||
customer_state = new_customer.customer_state,
|
||||
customer_zip = new_customer.customer_zip,
|
||||
auto_status=0
|
||||
)
|
||||
|
||||
db.session.add(new_auto)
|
||||
@@ -162,13 +163,44 @@ def edit_customer(customer_id):
|
||||
response_customer_zip = request.json["customer_zip"]
|
||||
response_customer_phone_number = request.json["customer_phone_number"]
|
||||
response_customer_email = request.json["customer_email"]
|
||||
response_customer_automatic = request.json["customer_automatic"]
|
||||
response_customer_home_type = request.json["customer_home_type"]
|
||||
response_customer_address = request.json["customer_address"]
|
||||
response_customer_automatic = request.json["customer_automatic"]
|
||||
|
||||
|
||||
if response_customer_automatic is True:
|
||||
get_auto = (db.session
|
||||
.query(Auto_Delivery)
|
||||
.filter(Auto_Delivery.customer_id == customer_id)
|
||||
.first())
|
||||
|
||||
auto = 1
|
||||
# customer becames an automatic
|
||||
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,
|
||||
customer_address=get_customer.customer_address,
|
||||
last_fill = datetime.utcnow(),
|
||||
last_updated = None,
|
||||
estimated_gallons_left = 0,
|
||||
estimated_gallons_left_prev_day = 0,
|
||||
tank_height = 0,
|
||||
tank_size =275,
|
||||
house_factor = 1,
|
||||
auto_status=0
|
||||
)
|
||||
db.session.add(create_auto)
|
||||
|
||||
else:
|
||||
auto = 0
|
||||
|
||||
|
||||
get_customer.customer_address = response_customer_address
|
||||
get_customer.customer_home_type = response_customer_home_type
|
||||
get_customer.customer_automatic = response_customer_automatic
|
||||
get_customer.customer_phone_number = response_customer_phone_number
|
||||
get_customer.customer_last_name = response_customer_last_name
|
||||
get_customer.customer_first_name = response_customer_first_name
|
||||
@@ -176,6 +208,7 @@ def edit_customer(customer_id):
|
||||
get_customer.customer_state = response_customer_state
|
||||
get_customer.customer_zip = response_customer_zip
|
||||
get_customer.customer_email = response_customer_email
|
||||
get_customer.customer_automatic = auto
|
||||
|
||||
db.session.add(get_customer)
|
||||
db.session.commit()
|
||||
@@ -298,6 +331,7 @@ def customer_automatic_assignment(customer_id):
|
||||
tank_height = 0,
|
||||
tank_size =275,
|
||||
house_factor = 1,
|
||||
auto_status=0
|
||||
|
||||
)
|
||||
db.session.add(create_auto)
|
||||
|
||||
Reference in New Issue
Block a user