refactor: remove all backward compatibility code across 70 files
Some checks failed
CI / ruff (push) Successful in 11s
CI / validate (push) Has been cancelled
CI / dependency-scanning (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / deploy (push) Has been cancelled
CI / pytest (push) Has started running

Clean up 28 backward compatibility instances identified in the codebase.
The app is not live, so all shims are replaced with the target architecture:

- Remove legacy Inventory.location column (use bin_location exclusively)
- Remove dashboard _extract_metric_value helper (use flat metrics dict)
- Remove legacy stat field duplicates (total_stores, total_imports, etc.)
- Remove 13 re-export shims and class aliases across modules
- Remove module-enabling JSON fallback (use PlatformModule junction table)
- Remove menu_to_legacy_format() conversion (return dataclasses directly)
- Remove title/description from MarketplaceProductBase schema
- Clean billing convenience method docstrings
- Clean test fixtures and backward-compat comments
- Add PlatformModule seeding to init_production.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 13:20:29 +01:00
parent b0db8133a0
commit aad18c27ab
70 changed files with 501 additions and 841 deletions

View File

@@ -176,7 +176,6 @@ class InventoryImportService:
store_id=store_id,
warehouse=warehouse,
bin_location=bin_loc,
location=bin_loc, # Legacy field
quantity=quantity,
gtin=ean,
)

View File

@@ -81,7 +81,7 @@ class InventoryMetricsProvider:
# Unique locations
unique_locations = (
db.query(func.count(func.distinct(Inventory.location)))
db.query(func.count(func.distinct(Inventory.bin_location)))
.filter(Inventory.store_id == store_id)
.scalar()
or 0

View File

@@ -86,8 +86,7 @@ class InventoryService:
product_id=inventory_data.product_id,
store_id=store_id,
warehouse="strassen", # Default warehouse
bin_location=location, # Use location as bin location
location=location, # Keep for backward compatibility
bin_location=location,
quantity=inventory_data.quantity,
gtin=product.marketplace_product.gtin, # Optional reference
)
@@ -154,8 +153,7 @@ class InventoryService:
product_id=inventory_data.product_id,
store_id=store_id,
warehouse="strassen", # Default warehouse
bin_location=location, # Use location as bin location
location=location, # Keep for backward compatibility
bin_location=location,
quantity=inventory_data.quantity,
gtin=product.marketplace_product.gtin,
)
@@ -445,7 +443,7 @@ class InventoryService:
locations = [
InventoryLocationResponse(
location=inv.location,
location=inv.bin_location,
quantity=inv.quantity,
reserved_quantity=inv.reserved_quantity,
available_quantity=inv.available_quantity,
@@ -500,7 +498,7 @@ class InventoryService:
query = db.query(Inventory).filter(Inventory.store_id == store_id)
if location:
query = query.filter(Inventory.location.ilike(f"%{location}%"))
query = query.filter(Inventory.bin_location.ilike(f"%{location}%"))
if low_stock_threshold is not None:
query = query.filter(Inventory.quantity <= low_stock_threshold)
@@ -541,7 +539,7 @@ class InventoryService:
inventory.reserved_quantity = inventory_update.reserved_quantity
if inventory_update.location:
inventory.location = self._validate_location(inventory_update.location)
inventory.bin_location = self._validate_location(inventory_update.location)
inventory.updated_at = datetime.now(UTC)
db.flush()
@@ -624,7 +622,7 @@ class InventoryService:
query = query.filter(Inventory.store_id == store_id)
if location:
query = query.filter(Inventory.location.ilike(f"%{location}%"))
query = query.filter(Inventory.bin_location.ilike(f"%{location}%"))
if low_stock is not None:
query = query.filter(Inventory.quantity <= low_stock)
@@ -668,7 +666,7 @@ class InventoryService:
store_code=store.store_code if store else None,
product_title=title,
product_sku=product.store_sku if product else None,
location=inv.location,
location=inv.bin_location,
quantity=inv.quantity,
reserved_quantity=inv.reserved_quantity,
available_quantity=inv.available_quantity,
@@ -717,7 +715,7 @@ class InventoryService:
# Unique locations
unique_locations = (
db.query(func.count(func.distinct(Inventory.location))).scalar() or 0
db.query(func.count(func.distinct(Inventory.bin_location))).scalar() or 0
)
return AdminInventoryStats(
@@ -768,7 +766,7 @@ class InventoryService:
store_id=inv.store_id,
store_name=store.name if store else None,
product_title=title,
location=inv.location,
location=inv.bin_location,
quantity=inv.quantity,
reserved_quantity=inv.reserved_quantity,
available_quantity=inv.available_quantity,
@@ -808,7 +806,7 @@ class InventoryService:
self, db: Session, store_id: int | None = None
) -> AdminInventoryLocationsResponse:
"""Get list of unique inventory locations (admin only)."""
query = db.query(func.distinct(Inventory.location))
query = db.query(func.distinct(Inventory.bin_location))
if store_id is not None:
query = query.filter(Inventory.store_id == store_id)
@@ -859,7 +857,7 @@ class InventoryService:
store_code=store.store_code,
product_title=title,
product_sku=product.store_sku if product else None,
location=inv.location,
location=inv.bin_location,
quantity=inv.quantity,
reserved_quantity=inv.reserved_quantity,
available_quantity=inv.available_quantity,
@@ -874,7 +872,7 @@ class InventoryService:
Inventory.store_id == store_id
)
if location:
total_query = total_query.filter(Inventory.location.ilike(f"%{location}%"))
total_query = total_query.filter(Inventory.bin_location.ilike(f"%{location}%"))
if low_stock is not None:
total_query = total_query.filter(Inventory.quantity <= low_stock)
total = total_query.scalar() or 0
@@ -940,7 +938,7 @@ class InventoryService:
"""Get inventory entry by product and location."""
return (
db.query(Inventory)
.filter(Inventory.product_id == product_id, Inventory.location == location)
.filter(Inventory.product_id == product_id, Inventory.bin_location == location)
.first()
)