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

@@ -23,7 +23,6 @@ def upgrade() -> None:
sa.Column("store_id", sa.Integer(), sa.ForeignKey("stores.id"), nullable=False, index=True),
sa.Column("warehouse", sa.String(), nullable=False, server_default="strassen", index=True),
sa.Column("bin_location", sa.String(), nullable=False, index=True),
sa.Column("location", sa.String(), nullable=True, index=True),
sa.Column("quantity", sa.Integer(), nullable=False, server_default="0"),
sa.Column("reserved_quantity", sa.Integer(), nullable=True, server_default="0"),
sa.Column("gtin", sa.String(), nullable=True, index=True),

View File

@@ -30,9 +30,6 @@ class Inventory(Base, TimestampMixin):
warehouse = Column(String, nullable=False, default="strassen", index=True)
bin_location = Column(String, nullable=False, index=True) # e.g., "SA-10-02"
# Legacy field - kept for backward compatibility, will be removed
location = Column(String, index=True)
quantity = Column(Integer, nullable=False, default=0)
reserved_quantity = Column(Integer, default=0)
@@ -53,7 +50,7 @@ class Inventory(Base, TimestampMixin):
)
def __repr__(self):
return f"<Inventory(product_id={self.product_id}, location='{self.location}', quantity={self.quantity})>"
return f"<Inventory(product_id={self.product_id}, warehouse='{self.warehouse}', bin='{self.bin_location}', quantity={self.quantity})>"
@property
def available_quantity(self):

View File

@@ -283,7 +283,7 @@ def delete_inventory(
inventory = inventory_service.get_inventory_by_id_admin(db, inventory_id)
store_id = inventory.store_id
product_id = inventory.product_id
location = inventory.location
location = inventory.bin_location
inventory_service.delete_inventory(
db=db,

View File

@@ -45,7 +45,7 @@ class InventoryResponse(BaseModel):
id: int
product_id: int
store_id: int
location: str
bin_location: str
quantity: int
reserved_quantity: int
gtin: str | None

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()
)

View File

@@ -19,7 +19,6 @@ class TestInventoryModel:
store_id=test_store.id,
warehouse="strassen",
bin_location="SA-10-01",
location="WAREHOUSE_A",
quantity=150,
reserved_quantity=10,
gtin=test_product.marketplace_product.gtin,
@@ -32,7 +31,6 @@ class TestInventoryModel:
assert inventory.id is not None
assert inventory.product_id == test_product.id
assert inventory.store_id == test_store.id
assert inventory.location == "WAREHOUSE_A"
assert inventory.bin_location == "SA-10-01"
assert inventory.quantity == 150
assert inventory.reserved_quantity == 10
@@ -45,7 +43,6 @@ class TestInventoryModel:
store_id=test_store.id,
warehouse="strassen",
bin_location="SA-10-01",
location="WAREHOUSE_A",
quantity=100,
)
db.add(inventory1)
@@ -58,7 +55,6 @@ class TestInventoryModel:
store_id=test_store.id,
warehouse="strassen",
bin_location="SA-10-01",
location="WAREHOUSE_A",
quantity=50,
)
db.add(inventory2)
@@ -73,7 +69,6 @@ class TestInventoryModel:
store_id=test_store.id,
warehouse="strassen",
bin_location="SA-10-01",
location="WAREHOUSE_A",
quantity=100,
)
db.add(inventory1)
@@ -85,7 +80,6 @@ class TestInventoryModel:
store_id=test_store.id,
warehouse="strassen",
bin_location="SA-10-02",
location="WAREHOUSE_B",
quantity=50,
)
db.add(inventory2)
@@ -102,7 +96,6 @@ class TestInventoryModel:
store_id=test_store.id,
warehouse="strassen",
bin_location="DEF-01-01",
location="DEFAULT_LOC",
quantity=100,
)
db.add(inventory)
@@ -119,7 +112,6 @@ class TestInventoryModel:
store_id=test_store.id,
warehouse="strassen",
bin_location="PROP-01-01",
location="PROP_TEST",
quantity=200,
reserved_quantity=50,
)
@@ -136,7 +128,6 @@ class TestInventoryModel:
store_id=test_store.id,
warehouse="strassen",
bin_location="REL-01-01",
location="REL_TEST",
quantity=100,
)
db.add(inventory)
@@ -155,7 +146,6 @@ class TestInventoryModel:
store_id=test_store.id,
warehouse="strassen",
bin_location="NOGTIN-01-01",
location="NO_GTIN",
quantity=100,
)
db.add(inventory)

View File

@@ -183,7 +183,7 @@ class TestInventoryResponseSchema:
"id": 1,
"product_id": 1,
"store_id": 1,
"location": "Warehouse A",
"bin_location": "Warehouse A",
"quantity": 100,
"reserved_quantity": 20,
"gtin": "1234567890123",
@@ -203,7 +203,7 @@ class TestInventoryResponseSchema:
"id": 1,
"product_id": 1,
"store_id": 1,
"location": "Warehouse A",
"bin_location": "Warehouse A",
"quantity": 100,
"reserved_quantity": 30,
"gtin": None,
@@ -221,7 +221,7 @@ class TestInventoryResponseSchema:
"id": 1,
"product_id": 1,
"store_id": 1,
"location": "Warehouse A",
"bin_location": "Warehouse A",
"quantity": 10,
"reserved_quantity": 50, # Over-reserved
"gtin": None,