feat(price): detect quantity discounts via baseprice, show Disc. badge
GoMag sends baseprice (catalog price) alongside price (discounted). When baseprice > price, the item is volume-discounted — skip ROA price comparison and show amber "Disc." badge instead of false mismatch. Strikethrough baseprice in price column for transparency. Pipeline: parse baseprice → store in SQLite → skip in validation → pass flag to frontend → render badge (desktop + mobile pill badge with aria-label, opacity 0.6 for dark mode). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -169,6 +169,7 @@ CREATE TABLE IF NOT EXISTS order_items (
|
||||
product_name TEXT,
|
||||
quantity REAL,
|
||||
price REAL,
|
||||
baseprice REAL,
|
||||
vat REAL,
|
||||
mapping_status TEXT,
|
||||
codmat TEXT,
|
||||
@@ -357,6 +358,14 @@ def init_sqlite():
|
||||
conn.execute(f"ALTER TABLE orders ADD COLUMN {col} {typedef}")
|
||||
logger.info(f"Migrated orders: added column {col}")
|
||||
|
||||
# Migrate order_items: add baseprice column
|
||||
cursor = conn.execute("PRAGMA table_info(order_items)")
|
||||
oi_cols = {row[1] for row in cursor.fetchall()}
|
||||
if "baseprice" not in oi_cols:
|
||||
conn.execute("ALTER TABLE order_items ADD COLUMN baseprice REAL")
|
||||
conn.execute("UPDATE orders SET price_match = NULL WHERE price_match = 0")
|
||||
logger.info("Migrated order_items: added baseprice; reset price_match for re-check")
|
||||
|
||||
conn.commit()
|
||||
|
||||
# Backfill address_mismatch from stored address JSON
|
||||
|
||||
Reference in New Issue
Block a user