Updated auto
This commit is contained in:
@@ -35,14 +35,14 @@ class Auto_Delivery(db.Model):
|
||||
autoincrement=True,
|
||||
unique=False)
|
||||
customer_id = db.Column(db.INTEGER())
|
||||
customer_full_name = db.Column(db.DECIMAL(50, 2))
|
||||
customer_full_name = db.Column(db.DECIMAL(5, 2))
|
||||
last_fill = db.Column(db.TIMESTAMP())
|
||||
last_updated = db.Column(db.TIMESTAMP())
|
||||
estimated_gallons_left = db.Column(db.INTEGER())
|
||||
estimated_gallons_left_prev_day = db.Column(db.INTEGER())
|
||||
tank_height = db.Column(db.VARCHAR(25))
|
||||
tank_size = db.Column(db.VARCHAR(25))
|
||||
k_factor = db.Column(db.DECIMAL(50, 2))
|
||||
house_factor = db.Column(db.DECIMAL(5, 2))
|
||||
|
||||
class Auto_Delivery_schema(ma.SQLAlchemyAutoSchema):
|
||||
class Meta:
|
||||
|
||||
@@ -18,7 +18,7 @@ class Customer_Customer(db.Model):
|
||||
customer_town = db.Column(db.VARCHAR(140))
|
||||
customer_state = db.Column(db.INTEGER)
|
||||
customer_zip = db.Column(db.VARCHAR(25))
|
||||
customer_first_call = db.Column(db.TIMESTAMP(), default=datetime.utcnow())
|
||||
customer_first_call = db.Column(db.TIMESTAMP())
|
||||
customer_email = db.Column(db.VARCHAR(500))
|
||||
customer_automatic = db.Column(db.INTEGER)
|
||||
customer_phone_number = db.Column(db.VARCHAR(25))
|
||||
@@ -75,9 +75,12 @@ class Customer_Payment_Credit(db.Model):
|
||||
credit_card_name = db.Column(db.VARCHAR(240))
|
||||
credit_card_number = db.Column(db.VARCHAR(140))
|
||||
credit_card_security = db.Column(db.VARCHAR(140))
|
||||
customer_card_expiration = db.Column(db.TIMESTAMP(), default=datetime.utcnow())
|
||||
customer_card_expiration = db.Column(db.TIMESTAMP())
|
||||
|
||||
|
||||
class Customer_Payment_Credit_schema(ma.SQLAlchemyAutoSchema):
|
||||
class Meta:
|
||||
model = Customer_Payment_Credit
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ from app.classes.customer import \
|
||||
Customer_Customer, \
|
||||
Customer_Customer_schema
|
||||
from app.classes.admin import Admin_Company
|
||||
from app.classes.auto import Auto_Delivery
|
||||
import string
|
||||
import random
|
||||
|
||||
@@ -38,6 +39,7 @@ def all_customers(page):
|
||||
|
||||
customer_list = db.session \
|
||||
.query(Customer_Customer) \
|
||||
.order_by(Customer_Customer.id.desc()) \
|
||||
.limit(per_page_amount).offset(offset_limit)
|
||||
|
||||
customer_schema = Customer_Customer_schema(many=True)
|
||||
@@ -110,6 +112,22 @@ def create_customer():
|
||||
)
|
||||
|
||||
db.session.add(new_customer)
|
||||
db.session.flush()
|
||||
|
||||
new_auto = Auto_Delivery(
|
||||
customer_id = new_customer.id,
|
||||
account_number = made_account_number,
|
||||
customer_full_name = new_customer.response_customer_last_name + " " + new_customer.response_customer_first_name,
|
||||
last_fill = None,
|
||||
last_updated = None,
|
||||
estimated_gallons_left = None,
|
||||
estimated_gallons_left_prev_day = None,
|
||||
tank_height = None,
|
||||
tank_size = None,
|
||||
house_factor = 1,
|
||||
)
|
||||
|
||||
db.session.add(new_auto)
|
||||
db.session.commit()
|
||||
|
||||
return jsonify({
|
||||
@@ -195,3 +213,18 @@ def delete_customer(customer_id):
|
||||
}), 200
|
||||
|
||||
|
||||
@customer.route("/count", methods=["GET"])
|
||||
@login_required
|
||||
def customer_count():
|
||||
"""
|
||||
"""
|
||||
get_customer = (db.session
|
||||
.query(Customer_Customer)
|
||||
.count())
|
||||
|
||||
return jsonify({
|
||||
"ok": True,
|
||||
'count': get_customer
|
||||
}), 200
|
||||
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@ from flask_login import current_user
|
||||
from datetime import date, datetime, timedelta
|
||||
from app.delivery import delivery
|
||||
from app import db
|
||||
from app.classes.customer import (Customer_Customer,
|
||||
Customer_Customer_schema)
|
||||
from app.classes.customer import (Customer_Customer)
|
||||
from app.classes.delivery import (Delivery_Delivery,
|
||||
Delivery_Delivery_schema,
|
||||
Delivery_Notes_Driver,
|
||||
@@ -47,13 +46,25 @@ def get_a_delivery(delivery_id):
|
||||
},
|
||||
}), 200
|
||||
|
||||
@delivery.route("/past/<int:customer_id>", methods=["GET"])
|
||||
def get_customer_past_delivery(customer_id):
|
||||
@delivery.route("/past1/<int:customer_id>", methods=["GET"])
|
||||
def get_customer_past_delivery1(customer_id):
|
||||
|
||||
get_customer_past_delivery = (db.session
|
||||
.query(Delivery_Delivery)
|
||||
.filter(Delivery_Delivery.customer_id == customer_id)
|
||||
.limit(10))
|
||||
.limit(5))
|
||||
|
||||
delivery_schema = Delivery_Delivery_schema(many=True)
|
||||
return jsonify(delivery_schema.dump(get_customer_past_delivery))
|
||||
|
||||
@delivery.route("/past2/<int:customer_id>", methods=["GET"])
|
||||
def get_customer_past_delivery2(customer_id):
|
||||
|
||||
get_customer_past_delivery = (db.session
|
||||
.query(Delivery_Delivery)
|
||||
.filter(Delivery_Delivery.customer_id == customer_id)
|
||||
.offset(5)
|
||||
.limit(5))
|
||||
|
||||
delivery_schema = Delivery_Delivery_schema(many=True)
|
||||
return jsonify(delivery_schema.dump(get_customer_past_delivery))
|
||||
|
||||
Reference in New Issue
Block a user