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>
109 lines
3.4 KiB
Python
Executable File
109 lines
3.4 KiB
Python
Executable File
|
|
from app import db, ma
|
|
from datetime import datetime
|
|
|
|
class Auto_Update(db.Model):
|
|
__tablename__ = 'auto_update'
|
|
|
|
id = db.Column(db.Integer,
|
|
primary_key=True,
|
|
autoincrement=True,
|
|
unique=False)
|
|
|
|
last_updated = db.Column(db.DATE())
|
|
|
|
|
|
|
|
class Auto_Temp(db.Model):
|
|
__tablename__ = 'auto_temp'
|
|
__table_args__ = {"schema": "public"}
|
|
|
|
id = db.Column(db.Integer,
|
|
primary_key=True,
|
|
autoincrement=True,
|
|
unique=False)
|
|
todays_date = db.Column(db.DATE())
|
|
temp = db.Column(db.DECIMAL(6, 2))
|
|
temp_max = db.Column(db.DECIMAL(6, 2))
|
|
temp_min = db.Column(db.DECIMAL(6, 2))
|
|
temp_avg = db.Column(db.DECIMAL(6, 2))
|
|
degree_day = db.Column(db.INTEGER())
|
|
|
|
class Auto_Temp_schema(ma.SQLAlchemyAutoSchema):
|
|
class Meta:
|
|
model = Auto_Temp
|
|
|
|
|
|
|
|
class Auto_Delivery(db.Model):
|
|
__tablename__ = 'auto_delivery'
|
|
__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))
|
|
hot_water_summer = db.Column(db.Integer)
|
|
#0 = waiting
|
|
#1 = waiting for delivery
|
|
auto_status = db.Column(db.INTEGER())
|
|
open_ticket_id = db.Column(db.Integer)
|
|
confidence_score = db.Column(db.Integer, default=20)
|
|
k_factor_source = db.Column(db.VARCHAR(20), default='default')
|
|
|
|
|
|
class Auto_Delivery_schema(ma.SQLAlchemyAutoSchema):
|
|
class Meta:
|
|
model = Auto_Delivery
|
|
|
|
|
|
class Tickets_Auto_Delivery(db.Model):
|
|
__tablename__ = 'auto_tickets'
|
|
__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))
|
|
fill_date = db.Column(db.DATE())
|
|
oil_prices_id = db.Column(db.INTEGER())
|
|
|
|
gallons_delivered = db.Column(db.DECIMAL(6, 2))
|
|
price_per_gallon = db.Column(db.DECIMAL(6, 2))
|
|
|
|
total_amount_customer = db.Column(db.DECIMAL(6, 2))
|
|
|
|
|
|
payment_type = db.Column(db.INTEGER, nullable=True)
|
|
payment_card_id = db.Column(db.INTEGER, nullable=True)
|
|
payment_status = db.Column(db.INTEGER, nullable=True)
|
|
is_budget_fill = db.Column(db.Boolean, default=False)
|
|
|
|
|
|
class Tickets_Auto_Delivery_schema(ma.SQLAlchemyAutoSchema):
|
|
class Meta:
|
|
model = Tickets_Auto_Delivery
|