Files
orion/app/modules/inventory/services/inventory_features.py
Samir Boulahtit f20266167d
Some checks failed
CI / ruff (push) Failing after 7s
CI / pytest (push) Failing after 1s
CI / architecture (push) Failing after 9s
CI / dependency-scanning (push) Successful in 27s
CI / audit (push) Successful in 8s
CI / docs (push) Has been skipped
fix(lint): auto-fix ruff violations and tune lint rules
- Auto-fixed 4,496 lint issues (import sorting, modern syntax, etc.)
- Added ignore rules for patterns intentional in this codebase:
  E402 (late imports), E712 (SQLAlchemy filters), B904 (raise from),
  SIM108/SIM105/SIM117 (readability preferences)
- Added per-file ignores for tests and scripts
- Excluded broken scripts/rename_terminology.py (has curly quotes)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 23:10:42 +01:00

108 lines
3.4 KiB
Python

# app/modules/inventory/services/inventory_features.py
"""
Inventory feature provider for the billing feature system.
Declares inventory-related billable features (basic inventory, locations,
purchase orders, low stock alerts) for feature gating.
"""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
from app.modules.contracts.features import (
FeatureDeclaration,
FeatureScope,
FeatureType,
FeatureUsage,
)
if TYPE_CHECKING:
from sqlalchemy.orm import Session
logger = logging.getLogger(__name__)
class InventoryFeatureProvider:
"""Feature provider for the inventory module.
Declares:
- inventory_basic: binary merchant-level feature for basic inventory management
- inventory_locations: binary merchant-level feature for multi-location inventory
- inventory_purchase_orders: binary merchant-level feature for purchase orders
- low_stock_alerts: binary merchant-level feature for low stock alert notifications
"""
@property
def feature_category(self) -> str:
return "inventory"
def get_feature_declarations(self) -> list[FeatureDeclaration]:
return [
FeatureDeclaration(
code="inventory_basic",
name_key="inventory.features.inventory_basic.name",
description_key="inventory.features.inventory_basic.description",
category="inventory",
feature_type=FeatureType.BINARY,
scope=FeatureScope.MERCHANT,
ui_icon="box",
display_order=10,
),
FeatureDeclaration(
code="inventory_locations",
name_key="inventory.features.inventory_locations.name",
description_key="inventory.features.inventory_locations.description",
category="inventory",
feature_type=FeatureType.BINARY,
scope=FeatureScope.MERCHANT,
ui_icon="map-pin",
display_order=20,
),
FeatureDeclaration(
code="inventory_purchase_orders",
name_key="inventory.features.inventory_purchase_orders.name",
description_key="inventory.features.inventory_purchase_orders.description",
category="inventory",
feature_type=FeatureType.BINARY,
scope=FeatureScope.MERCHANT,
ui_icon="file-plus",
display_order=30,
),
FeatureDeclaration(
code="low_stock_alerts",
name_key="inventory.features.low_stock_alerts.name",
description_key="inventory.features.low_stock_alerts.description",
category="inventory",
feature_type=FeatureType.BINARY,
scope=FeatureScope.MERCHANT,
ui_icon="alert-triangle",
display_order=40,
),
]
def get_store_usage(
self,
db: Session,
store_id: int,
) -> list[FeatureUsage]:
return []
def get_merchant_usage(
self,
db: Session,
merchant_id: int,
platform_id: int,
) -> list[FeatureUsage]:
return []
# Singleton instance for module registration
inventory_feature_provider = InventoryFeatureProvider()
__all__ = [
"InventoryFeatureProvider",
"inventory_feature_provider",
]