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 @@
|
||||
"""
|
||||
Orders Module - Order processing and fulfillment.
|
||||
|
||||
This module provides:
|
||||
This is a self-contained module providing:
|
||||
- Order management and tracking
|
||||
- Order fulfillment workflow
|
||||
- Order item exceptions handling
|
||||
- Bulk order operations
|
||||
- Order export and reporting
|
||||
- Invoice generation
|
||||
- Customer checkout
|
||||
|
||||
Routes:
|
||||
- Admin: /api/v1/admin/orders/*, /api/v1/admin/order-item-exceptions/*
|
||||
- Vendor: /api/v1/vendor/orders/*, /api/v1/vendor/order-item-exceptions/*
|
||||
|
||||
Menu Items:
|
||||
- Admin: orders
|
||||
- Vendor: orders
|
||||
Module Structure:
|
||||
- models/ - Database models (Order, OrderItem, Invoice, etc.)
|
||||
- services/ - Business logic (OrderService, InvoiceService)
|
||||
- schemas/ - Pydantic DTOs
|
||||
- routes/ - API routes
|
||||
- exceptions.py - Module-specific exceptions
|
||||
"""
|
||||
|
||||
from app.modules.orders.definition import orders_module
|
||||
# Use lazy imports to avoid circular import issues
|
||||
|
||||
__all__ = ["orders_module"]
|
||||
|
||||
def __getattr__(name: str):
|
||||
"""Lazy import module components to avoid circular imports."""
|
||||
if name == "orders_module":
|
||||
from app.modules.orders.definition import orders_module
|
||||
|
||||
return orders_module
|
||||
elif name == "get_orders_module_with_routers":
|
||||
from app.modules.orders.definition import get_orders_module_with_routers
|
||||
|
||||
return get_orders_module_with_routers
|
||||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
||||
|
||||
|
||||
__all__ = ["orders_module", "get_orders_module_with_routers"]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Orders module definition.
|
||||
|
||||
Defines the orders module including its features, menu items,
|
||||
and route configurations.
|
||||
route configurations, and self-contained module settings.
|
||||
"""
|
||||
|
||||
from app.modules.base import ModuleDefinition
|
||||
@@ -30,7 +30,7 @@ orders_module = ModuleDefinition(
|
||||
name="Order Management",
|
||||
description=(
|
||||
"Order processing, fulfillment tracking, customer checkout, "
|
||||
"and bulk order operations. Uses the payments module for checkout."
|
||||
"invoicing, and bulk order operations. Uses the payments module for checkout."
|
||||
),
|
||||
version="1.0.0",
|
||||
requires=["payments"], # Depends on payments module for checkout
|
||||
@@ -43,6 +43,8 @@ orders_module = ModuleDefinition(
|
||||
"shipping_management", # Carrier integration
|
||||
"order_exceptions", # Order item exception handling
|
||||
"customer_checkout", # Customer checkout flow
|
||||
"invoice_generation", # Invoice creation
|
||||
"invoice_pdf", # PDF invoice generation
|
||||
],
|
||||
menu_items={
|
||||
FrontendType.ADMIN: [
|
||||
@@ -53,6 +55,14 @@ orders_module = ModuleDefinition(
|
||||
],
|
||||
},
|
||||
is_core=False,
|
||||
# =========================================================================
|
||||
# Self-Contained Module Configuration
|
||||
# =========================================================================
|
||||
is_self_contained=True,
|
||||
services_path="app.modules.orders.services",
|
||||
models_path="app.modules.orders.models",
|
||||
schemas_path="app.modules.orders.schemas",
|
||||
exceptions_path="app.modules.orders.exceptions",
|
||||
)
|
||||
|
||||
|
||||
|
||||
53
app/modules/orders/exceptions.py
Normal file
53
app/modules/orders/exceptions.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# app/modules/orders/exceptions.py
|
||||
"""
|
||||
Orders module exceptions.
|
||||
|
||||
Re-exports order-related exceptions from their source locations.
|
||||
"""
|
||||
|
||||
from app.exceptions.order import (
|
||||
OrderNotFoundException,
|
||||
OrderAlreadyExistsException,
|
||||
OrderValidationException,
|
||||
InvalidOrderStatusException,
|
||||
OrderCannotBeCancelledException,
|
||||
)
|
||||
|
||||
from app.exceptions.order_item_exception import (
|
||||
OrderItemExceptionNotFoundException,
|
||||
OrderHasUnresolvedExceptionsException,
|
||||
ExceptionAlreadyResolvedException,
|
||||
InvalidProductForExceptionException,
|
||||
)
|
||||
|
||||
from app.exceptions.invoice import (
|
||||
InvoiceNotFoundException,
|
||||
InvoiceSettingsNotFoundException,
|
||||
InvoiceSettingsAlreadyExistException,
|
||||
InvoiceValidationException,
|
||||
InvoicePDFGenerationException,
|
||||
InvoicePDFNotFoundException,
|
||||
InvalidInvoiceStatusTransitionException,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
# Order exceptions
|
||||
"OrderNotFoundException",
|
||||
"OrderAlreadyExistsException",
|
||||
"OrderValidationException",
|
||||
"InvalidOrderStatusException",
|
||||
"OrderCannotBeCancelledException",
|
||||
# Order item exception exceptions
|
||||
"OrderItemExceptionNotFoundException",
|
||||
"OrderHasUnresolvedExceptionsException",
|
||||
"ExceptionAlreadyResolvedException",
|
||||
"InvalidProductForExceptionException",
|
||||
# Invoice exceptions
|
||||
"InvoiceNotFoundException",
|
||||
"InvoiceSettingsNotFoundException",
|
||||
"InvoiceSettingsAlreadyExistException",
|
||||
"InvoiceValidationException",
|
||||
"InvoicePDFGenerationException",
|
||||
"InvoicePDFNotFoundException",
|
||||
"InvalidInvoiceStatusTransitionException",
|
||||
]
|
||||
28
app/modules/orders/models/__init__.py
Normal file
28
app/modules/orders/models/__init__.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# app/modules/orders/models/__init__.py
|
||||
"""
|
||||
Orders module database models.
|
||||
|
||||
Re-exports order-related models from their source locations.
|
||||
"""
|
||||
|
||||
from models.database.order import (
|
||||
Order,
|
||||
OrderItem,
|
||||
)
|
||||
from models.database.order_item_exception import OrderItemException
|
||||
from models.database.invoice import (
|
||||
Invoice,
|
||||
InvoiceStatus,
|
||||
VATRegime,
|
||||
VendorInvoiceSettings,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"Order",
|
||||
"OrderItem",
|
||||
"OrderItemException",
|
||||
"Invoice",
|
||||
"InvoiceStatus",
|
||||
"VATRegime",
|
||||
"VendorInvoiceSettings",
|
||||
]
|
||||
36
app/modules/orders/schemas/__init__.py
Normal file
36
app/modules/orders/schemas/__init__.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# app/modules/orders/schemas/__init__.py
|
||||
"""
|
||||
Orders module Pydantic schemas.
|
||||
|
||||
Re-exports order-related schemas from their source locations.
|
||||
"""
|
||||
|
||||
from models.schema.order import (
|
||||
OrderCreate,
|
||||
OrderItemCreate,
|
||||
OrderResponse,
|
||||
OrderItemResponse,
|
||||
OrderListResponse,
|
||||
AddressSnapshot,
|
||||
CustomerSnapshot,
|
||||
)
|
||||
from models.schema.invoice import (
|
||||
InvoiceResponse,
|
||||
InvoiceSettingsCreate,
|
||||
InvoiceSettingsUpdate,
|
||||
InvoiceSettingsResponse,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"OrderCreate",
|
||||
"OrderItemCreate",
|
||||
"OrderResponse",
|
||||
"OrderItemResponse",
|
||||
"OrderListResponse",
|
||||
"AddressSnapshot",
|
||||
"CustomerSnapshot",
|
||||
"InvoiceResponse",
|
||||
"InvoiceSettingsCreate",
|
||||
"InvoiceSettingsUpdate",
|
||||
"InvoiceSettingsResponse",
|
||||
]
|
||||
40
app/modules/orders/services/__init__.py
Normal file
40
app/modules/orders/services/__init__.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# app/modules/orders/services/__init__.py
|
||||
"""
|
||||
Orders module services.
|
||||
|
||||
Re-exports order-related services from their source locations.
|
||||
"""
|
||||
|
||||
from app.services.order_service import (
|
||||
order_service,
|
||||
OrderService,
|
||||
)
|
||||
from app.services.order_inventory_service import (
|
||||
order_inventory_service,
|
||||
OrderInventoryService,
|
||||
)
|
||||
from app.services.order_item_exception_service import (
|
||||
order_item_exception_service,
|
||||
OrderItemExceptionService,
|
||||
)
|
||||
from app.services.invoice_service import (
|
||||
invoice_service,
|
||||
InvoiceService,
|
||||
)
|
||||
from app.services.invoice_pdf_service import (
|
||||
invoice_pdf_service,
|
||||
InvoicePDFService,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"order_service",
|
||||
"OrderService",
|
||||
"order_inventory_service",
|
||||
"OrderInventoryService",
|
||||
"order_item_exception_service",
|
||||
"OrderItemExceptionService",
|
||||
"invoice_service",
|
||||
"InvoiceService",
|
||||
"invoice_pdf_service",
|
||||
"InvoicePDFService",
|
||||
]
|
||||
Reference in New Issue
Block a user