60f9eee202
Updated DECIMAL(5,2) to DECIMAL(7,4) to match the DB column (now altered to NUMERIC(7,4)) and the auto.py model — prevents calibrated K-factors from being silently truncated to 2 decimal places on read/write. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
202 lines
6.2 KiB
Python
Executable File
202 lines
6.2 KiB
Python
Executable File
#
|
|
from app import db, ma
|
|
|
|
|
|
|
|
class Customer_Customer(db.Model):
|
|
__tablename__ = 'customer_customer'
|
|
__table_args__ = {"schema": "public"}
|
|
|
|
id = db.Column(db.Integer,
|
|
primary_key=True,
|
|
autoincrement=True,
|
|
unique=False)
|
|
auth_net_profile_id = db.Column(db.String, unique=True, index=True, nullable=True)
|
|
account_number = db.Column(db.VARCHAR(25))
|
|
customer_last_name = db.Column(db.VARCHAR(250))
|
|
customer_first_name = db.Column(db.VARCHAR(250))
|
|
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())
|
|
customer_email = db.Column(db.VARCHAR(500))
|
|
customer_automatic = db.Column(db.INTEGER)
|
|
customer_phone_number = db.Column(db.VARCHAR(25))
|
|
customer_home_type = db.Column(db.INTEGER)
|
|
customer_apt = db.Column(db.VARCHAR(140))
|
|
customer_address = db.Column(db.VARCHAR(1000))
|
|
company_id = db.Column(db.INTEGER)
|
|
customer_latitude = db.Column(db.VARCHAR(250))
|
|
customer_longitude = db.Column(db.VARCHAR(250))
|
|
correct_address = db.Column(db.BOOLEAN)
|
|
|
|
class Customer_Customer_schema(ma.SQLAlchemyAutoSchema):
|
|
class Meta:
|
|
model = Customer_Customer
|
|
|
|
|
|
class Customer_Property(db.Model):
|
|
__tablename__ = 'customer_property'
|
|
__table_args__ = {"schema": "public"}
|
|
|
|
id = db.Column(db.Integer,
|
|
primary_key=True,
|
|
autoincrement=True,
|
|
unique=False)
|
|
|
|
customer_id = db.Column(db.INTEGER)
|
|
|
|
# residential = 0
|
|
# condo = 1
|
|
# apartment = 2
|
|
# commercial = 3
|
|
# business = 4
|
|
# vehicle = 4
|
|
customer_property_type = db.Column(db.INTEGER)
|
|
|
|
|
|
class Customer_Property_schema(ma.SQLAlchemyAutoSchema):
|
|
class Meta:
|
|
model = Customer_Property
|
|
|
|
|
|
class Customer_Payment_Credit(db.Model):
|
|
__tablename__ = 'customer_payment'
|
|
__table_args__ = {"schema": "public"}
|
|
|
|
id = db.Column(db.Integer,
|
|
primary_key=True,
|
|
autoincrement=True,
|
|
unique=False)
|
|
|
|
customer_id = db.Column(db.INTEGER)
|
|
|
|
credit_card_type = db.Column(db.INTEGER)
|
|
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())
|
|
|
|
|
|
class Customer_Payment_Credit_schema(ma.SQLAlchemyAutoSchema):
|
|
class Meta:
|
|
model = Customer_Payment_Credit
|
|
|
|
|
|
|
|
class Customer_Description(db.Model):
|
|
__tablename__ = 'customer_description'
|
|
__table_args__ = {"schema": "public"}
|
|
|
|
id = db.Column(db.Integer,
|
|
primary_key=True,
|
|
autoincrement=True,
|
|
unique=False)
|
|
customer_id = db.Column(db.INTEGER)
|
|
account_number = db.Column(db.VARCHAR(25))
|
|
company_id = db.Column(db.INTEGER)
|
|
fill_location = db.Column(db.VARCHAR(250))
|
|
description = db.Column(db.VARCHAR(2000))
|
|
|
|
|
|
class Customer_Description_schema(ma.SQLAlchemyAutoSchema):
|
|
class Meta:
|
|
model = Customer_Description
|
|
|
|
|
|
class Customer_Property_schema(ma.SQLAlchemyAutoSchema):
|
|
class Meta:
|
|
model = Customer_Property
|
|
|
|
|
|
class Customer_Tank_Inspection(db.Model):
|
|
__tablename__ = 'customer_tank'
|
|
__table_args__ = {"schema": "public"}
|
|
|
|
id = db.Column(db.Integer,
|
|
primary_key=True,
|
|
autoincrement=True,
|
|
unique=False)
|
|
|
|
customer_id = db.Column(db.INTEGER)
|
|
last_tank_inspection = db.Column(db.DATE())
|
|
tank_status = db.Column(db.BOOLEAN)
|
|
outside_or_inside = db.Column(db.BOOLEAN)
|
|
tank_size = db.Column(db.INTEGER)
|
|
tank_images = db.Column(db.Integer, default=0) # 0 = false, 1 = true
|
|
tank_image_upload_dates = db.Column(db.JSON, default=list) # List of upload dates for each set
|
|
|
|
|
|
|
|
class Customer_Tank_Inspection_schema(ma.SQLAlchemyAutoSchema):
|
|
class Meta:
|
|
model = Customer_Tank_Inspection
|
|
|
|
|
|
class Customer_estimate_gallons(db.Model):
|
|
__tablename__ = 'customer_estimate'
|
|
__table_args__ = {"schema": "public"}
|
|
|
|
id = db.Column(db.Integer,
|
|
primary_key=True,
|
|
autoincrement=True,
|
|
unique=False)
|
|
|
|
customer_id = db.Column(db.INTEGER)
|
|
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.DATE)
|
|
days_since_last_fill = db.Column(db.INTEGER)
|
|
last_updated = db.Column(db.DATE)
|
|
estimated_gallons_left = db.Column(db.DECIMAL(6, 2))
|
|
estimated_gallons_left_prev_day = db.Column(db.DECIMAL(6, 2))
|
|
tank_height = db.Column(db.VARCHAR(25))
|
|
tank_size = db.Column(db.VARCHAR(25))
|
|
house_factor = db.Column(db.DECIMAL(7, 4))
|
|
auto_status = db.Column(db.INTEGER)
|
|
open_ticket_id = db.Column(db.Integer, nullable=True)
|
|
hot_water_summer = db.Column(db.INTEGER)
|
|
|
|
|
|
class Customer_estimate_gallons_schema(ma.SQLAlchemyAutoSchema):
|
|
class Meta:
|
|
model = Customer_estimate_gallons
|
|
|
|
|
|
class Customer_Update(db.Model):
|
|
__tablename__ = 'customer_update'
|
|
__table_args__ = {"schema": "public"}
|
|
|
|
id = db.Column(db.Integer,
|
|
primary_key=True,
|
|
autoincrement=True,
|
|
unique=False)
|
|
|
|
last_updated = db.Column(db.DATE)
|
|
|
|
|
|
class Customer_Update_schema(ma.SQLAlchemyAutoSchema):
|
|
class Meta:
|
|
model = Customer_Update
|
|
|
|
|
|
class Customer_Alert(db.Model):
|
|
__tablename__ = 'customer_alert'
|
|
__table_args__ = {"schema": "public"}
|
|
|
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
|
customer_id = db.Column(db.INTEGER, nullable=False)
|
|
# 0 = info, 1 = notice, 2 = critical
|
|
severity = db.Column(db.INTEGER, nullable=False)
|
|
message = db.Column(db.VARCHAR(2000), nullable=False)
|
|
created_at = db.Column(db.TIMESTAMP())
|
|
|
|
|
|
class Customer_Alert_schema(ma.SQLAlchemyAutoSchema):
|
|
class Meta:
|
|
model = Customer_Alert
|