updated forms
This commit is contained in:
@@ -138,8 +138,14 @@ def create_customer():
|
||||
"""
|
||||
"""
|
||||
now = datetime.utcnow()
|
||||
get_company = db.session.query(Admin_Company).filter(Admin_Company.id == 1).first()
|
||||
last_customer = (db.session.query(Customer_Customer).order_by(Customer_Customer.id.desc()).first())
|
||||
get_company = (db.session
|
||||
.query(Admin_Company)
|
||||
.filter(Admin_Company.id == 1)
|
||||
.first())
|
||||
last_customer = (db.session
|
||||
.query(Customer_Customer)
|
||||
.order_by(Customer_Customer.id.desc())
|
||||
.first())
|
||||
new_customer_id = last_customer.id + 1
|
||||
if len(str(new_customer_id)) == 2:
|
||||
new_customer_id = '000' + str(new_customer_id)
|
||||
@@ -161,17 +167,13 @@ def create_customer():
|
||||
response_customer_state = request.json["customer_state"]
|
||||
response_customer_zip = request.json["customer_zip"]
|
||||
response_customer_email = request.json["customer_email"]
|
||||
response_customer_automatic = request.json["customer_automatic"]
|
||||
response_customer_home_type = request.json["customer_home_type"]
|
||||
customer_phone_number = request.json["customer_phone_number"]
|
||||
customer_address = request.json["customer_address"]
|
||||
customer_apt = request.json["customer_apt"]
|
||||
customer_description_msg = request.json["customer_description"]
|
||||
|
||||
if response_customer_automatic is True:
|
||||
auto_customer = 1
|
||||
else:
|
||||
auto_customer = 0
|
||||
|
||||
|
||||
int_customer_home_type = int(response_customer_home_type)
|
||||
response_customer_zip = str(response_customer_zip)
|
||||
@@ -186,7 +188,7 @@ def create_customer():
|
||||
customer_zip=response_customer_zip,
|
||||
customer_first_call=now,
|
||||
customer_email=response_customer_email,
|
||||
customer_automatic=auto_customer,
|
||||
customer_automatic=0,
|
||||
customer_home_type=int_customer_home_type,
|
||||
customer_phone_number=customer_phone_number,
|
||||
customer_address=customer_address,
|
||||
@@ -336,44 +338,12 @@ def edit_customer(customer_id):
|
||||
response_customer_email = request.json["customer_email"]
|
||||
response_customer_home_type = request.json["customer_home_type"]
|
||||
response_customer_address = request.json["customer_address"]
|
||||
response_customer_automatic = request.json["customer_automatic"]
|
||||
|
||||
response_customer_description = request.json["customer_description"]
|
||||
|
||||
response_customer_fill_location = request.json["customer_fill_location"]
|
||||
|
||||
|
||||
|
||||
|
||||
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
|
||||
if get_customer_description is not None:
|
||||
get_customer_description.description = response_customer_description
|
||||
get_customer_description.fill_location = response_customer_fill_location
|
||||
@@ -389,7 +359,6 @@ 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()
|
||||
|
||||
Reference in New Issue
Block a user