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>
This commit is contained in:
2026-02-08 17:54:30 -05:00
parent 43a14eba2c
commit 6d5f44db55
18 changed files with 995 additions and 57 deletions

View File

@@ -1,4 +1,4 @@
from marshmallow import Schema, fields, validate, EXCLUDE
from marshmallow import Schema, fields, validate, EXCLUDE, pre_load
class CreateCustomerSchema(Schema):
@@ -67,6 +67,18 @@ class UpdateCustomerSchema(Schema):
class Meta:
unknown = EXCLUDE
@pre_load
def normalize_data(self, data, **kwargs):
# Convert empty strings to None for email
if 'customer_email' in data and data['customer_email'] == "":
data['customer_email'] = None
# Convert boolean to int for customer_automatic
if 'customer_automatic' in data:
if isinstance(data['customer_automatic'], bool):
data['customer_automatic'] = 1 if data['customer_automatic'] else 0
return data
customer_last_name = fields.Str(
validate=validate.Length(min=1, max=250)
)
@@ -106,9 +118,9 @@ class UpdateCustomerSchema(Schema):
allow_none=True,
validate=validate.Length(max=2000)
)
customer_fill_location = fields.Int(
customer_fill_location = fields.Str(
allow_none=True,
validate=validate.Range(min=0, max=10)
validate=validate.Length(max=250)
)

View File

@@ -33,6 +33,7 @@ def validate_request(schema_class):
# Attach validated data to request object for easy access
request.validated_data = validated_data
except ValidationError as err:
print(f"DEBUG: Validation Failed: {err.messages}")
return error_response("Validation failed", 400, details=str(err.messages))
return f(*args, **kwargs)