feat: add self-contained structure to remaining modules
Add exceptions, models, schemas, services directories to modules: customers: - exceptions.py, models/, schemas/, services/ inventory: - exceptions.py, models/, schemas/, services/ messaging: - exceptions.py, models/, schemas/, services/ monitoring: - exceptions.py, models/, schemas/, services/ orders: - exceptions.py, models/, schemas/, services/ payments: - Updated __init__.py All modules now have the standard self-contained directory structure ready for future migration of business logic. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,22 +2,35 @@
|
||||
"""
|
||||
Inventory Module - Stock and product management.
|
||||
|
||||
This module provides:
|
||||
This is a self-contained module providing:
|
||||
- Inventory tracking across locations
|
||||
- Stock level management
|
||||
- Low stock alerts
|
||||
- Inventory transactions and history
|
||||
- Product catalog management
|
||||
- Bulk inventory imports
|
||||
|
||||
Routes:
|
||||
- Admin: /api/v1/admin/inventory/*
|
||||
- Vendor: /api/v1/vendor/inventory/*
|
||||
|
||||
Menu Items:
|
||||
- Admin: inventory, vendor-products
|
||||
- Vendor: products, inventory
|
||||
Module Structure:
|
||||
- models/ - Database models (Inventory, InventoryTransaction)
|
||||
- services/ - Business logic (InventoryService, InventoryTransactionService)
|
||||
- schemas/ - Pydantic DTOs
|
||||
- routes/ - API routes
|
||||
- exceptions.py - Module-specific exceptions
|
||||
"""
|
||||
|
||||
from app.modules.inventory.definition import inventory_module
|
||||
# Use lazy imports to avoid circular import issues
|
||||
|
||||
__all__ = ["inventory_module"]
|
||||
|
||||
def __getattr__(name: str):
|
||||
"""Lazy import module components to avoid circular imports."""
|
||||
if name == "inventory_module":
|
||||
from app.modules.inventory.definition import inventory_module
|
||||
|
||||
return inventory_module
|
||||
elif name == "get_inventory_module_with_routers":
|
||||
from app.modules.inventory.definition import get_inventory_module_with_routers
|
||||
|
||||
return get_inventory_module_with_routers
|
||||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
||||
|
||||
|
||||
__all__ = ["inventory_module", "get_inventory_module_with_routers"]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Inventory module definition.
|
||||
|
||||
Defines the inventory module including its features, menu items,
|
||||
and route configurations.
|
||||
route configurations, and self-contained module settings.
|
||||
"""
|
||||
|
||||
from app.modules.base import ModuleDefinition
|
||||
@@ -30,8 +30,9 @@ inventory_module = ModuleDefinition(
|
||||
name="Inventory Management",
|
||||
description=(
|
||||
"Stock level tracking, inventory locations, low stock alerts, "
|
||||
"and product catalog management."
|
||||
"transaction history, and bulk imports."
|
||||
),
|
||||
version="1.0.0",
|
||||
features=[
|
||||
"inventory_basic", # Basic stock tracking
|
||||
"inventory_locations", # Multiple warehouse locations
|
||||
@@ -52,6 +53,14 @@ inventory_module = ModuleDefinition(
|
||||
],
|
||||
},
|
||||
is_core=False,
|
||||
# =========================================================================
|
||||
# Self-Contained Module Configuration
|
||||
# =========================================================================
|
||||
is_self_contained=True,
|
||||
services_path="app.modules.inventory.services",
|
||||
models_path="app.modules.inventory.models",
|
||||
schemas_path="app.modules.inventory.schemas",
|
||||
exceptions_path="app.modules.inventory.exceptions",
|
||||
)
|
||||
|
||||
|
||||
|
||||
26
app/modules/inventory/exceptions.py
Normal file
26
app/modules/inventory/exceptions.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# app/modules/inventory/exceptions.py
|
||||
"""
|
||||
Inventory module exceptions.
|
||||
|
||||
Re-exports inventory-related exceptions from their source locations.
|
||||
"""
|
||||
|
||||
from app.exceptions.inventory import (
|
||||
InventoryNotFoundException,
|
||||
InsufficientInventoryException,
|
||||
InvalidInventoryOperationException,
|
||||
InventoryValidationException,
|
||||
NegativeInventoryException,
|
||||
InvalidQuantityException,
|
||||
LocationNotFoundException,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"InventoryNotFoundException",
|
||||
"InsufficientInventoryException",
|
||||
"InvalidInventoryOperationException",
|
||||
"InventoryValidationException",
|
||||
"NegativeInventoryException",
|
||||
"InvalidQuantityException",
|
||||
"LocationNotFoundException",
|
||||
]
|
||||
18
app/modules/inventory/models/__init__.py
Normal file
18
app/modules/inventory/models/__init__.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# app/modules/inventory/models/__init__.py
|
||||
"""
|
||||
Inventory module database models.
|
||||
|
||||
Re-exports inventory-related models from their source locations.
|
||||
"""
|
||||
|
||||
from models.database.inventory import Inventory
|
||||
from models.database.inventory_transaction import (
|
||||
InventoryTransaction,
|
||||
TransactionType,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"Inventory",
|
||||
"InventoryTransaction",
|
||||
"TransactionType",
|
||||
]
|
||||
28
app/modules/inventory/schemas/__init__.py
Normal file
28
app/modules/inventory/schemas/__init__.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# app/modules/inventory/schemas/__init__.py
|
||||
"""
|
||||
Inventory module Pydantic schemas.
|
||||
|
||||
Re-exports inventory-related schemas from their source locations.
|
||||
"""
|
||||
|
||||
from models.schema.inventory import (
|
||||
InventoryCreate,
|
||||
InventoryAdjust,
|
||||
InventoryReserve,
|
||||
InventoryResponse,
|
||||
InventoryListResponse,
|
||||
InventoryTransactionResponse,
|
||||
AdminInventoryItem,
|
||||
AdminLowStockItem,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"InventoryCreate",
|
||||
"InventoryAdjust",
|
||||
"InventoryReserve",
|
||||
"InventoryResponse",
|
||||
"InventoryListResponse",
|
||||
"InventoryTransactionResponse",
|
||||
"AdminInventoryItem",
|
||||
"AdminLowStockItem",
|
||||
]
|
||||
28
app/modules/inventory/services/__init__.py
Normal file
28
app/modules/inventory/services/__init__.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# app/modules/inventory/services/__init__.py
|
||||
"""
|
||||
Inventory module services.
|
||||
|
||||
Re-exports inventory-related services from their source locations.
|
||||
"""
|
||||
|
||||
from app.services.inventory_service import (
|
||||
inventory_service,
|
||||
InventoryService,
|
||||
)
|
||||
from app.services.inventory_transaction_service import (
|
||||
inventory_transaction_service,
|
||||
InventoryTransactionService,
|
||||
)
|
||||
from app.services.inventory_import_service import (
|
||||
inventory_import_service,
|
||||
InventoryImportService,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"inventory_service",
|
||||
"InventoryService",
|
||||
"inventory_transaction_service",
|
||||
"InventoryTransactionService",
|
||||
"inventory_import_service",
|
||||
"InventoryImportService",
|
||||
]
|
||||
Reference in New Issue
Block a user