Files
eamco_office_api/app/classes/customer.py
Edwin Eames 6d5f44db55 feat: 5-tier pricing, market ticker integration, and delivery stats
Major update spanning pricing, market data, and analytics:

- Pricing: Replace single-price service fees with 5-tier pricing for
  same-day, prime, and emergency deliveries across create/edit/finalize
- Market: Add Ticker_Price and CompanyPrice models with endpoints for
  live commodity prices (HO, CL, RB) and competitor price tracking
- Stats: Add daily/weekly/monthly gallons endpoints with multi-year
  comparison and YoY totals for the stats dashboard
- Delivery: Add map and history endpoints, fix finalize null-driver crash
- Schema: Change fill_location from INTEGER to VARCHAR(250), add
  pre_load normalization for customer updates, fix admin auth check

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 17:54:30 -05:00

185 lines
5.6 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(5, 2))
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