updated dynamic auto
This commit is contained in:
@@ -271,31 +271,40 @@ def customer_automatic_assignment(customer_id):
|
||||
.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 = 1,
|
||||
|
||||
)
|
||||
db.session.add(create_auto)
|
||||
|
||||
if get_customer.customer_automatic == 1:
|
||||
# customer becomes will call
|
||||
get_customer.customer_automatic = 0
|
||||
|
||||
db.session.add(get_customer)
|
||||
if get_auto is not None:
|
||||
db.session.delete(get_auto)
|
||||
|
||||
status = 0
|
||||
db.session.add(get_customer)
|
||||
else:
|
||||
else:
|
||||
# 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,
|
||||
|
||||
)
|
||||
db.session.add(create_auto)
|
||||
get_customer.customer_automatic = 1
|
||||
status = 1
|
||||
db.session.add(get_customer)
|
||||
|
||||
status = 1
|
||||
|
||||
db.session.commit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user