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:
@@ -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)
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user