feat: extract billing module with routes (Phase 3)

Create app/modules/billing/ directory structure with:
- definition.py: Module definition with features and menu items
- routes/admin.py: Admin billing routes with module access control
- routes/vendor.py: Vendor billing routes with module access control

Key changes:
- Billing module uses require_module_access("billing") dependency
- Admin router now includes billing module router instead of legacy
- Module registry imports billing_module from extracted location
- Routes have identical functionality but are now module-gated

Module structure pattern for future extractions:
  app/modules/{module}/
  ├── __init__.py
  ├── definition.py (ModuleDefinition + router getters)
  └── routes/
      ├── __init__.py
      ├── admin.py (require_module_access dependency)
      └── vendor.py (require_module_access dependency)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-25 21:54:42 +01:00
parent cd65a5992d
commit c614b7d74c
7 changed files with 699 additions and 26 deletions

View File

@@ -7,11 +7,21 @@ enabled/disabled per platform. Core modules cannot be disabled.
Module Granularity (Medium - ~12 modules):
Matches menu sections for intuitive mapping between modules and UI.
Module Structure:
- Inline modules: Defined directly in this file (core, platform-admin, etc.)
- Extracted modules: Imported from app/modules/{module}/ (billing, etc.)
As modules are extracted to their own directories, they are imported
here and their inline definitions are replaced.
"""
from app.modules.base import ModuleDefinition
from models.database.admin_menu_config import FrontendType
# Import extracted modules
from app.modules.billing.definition import billing_module
# =============================================================================
# Module Definitions
@@ -72,28 +82,8 @@ MODULES: dict[str, ModuleDefinition] = {
# =========================================================================
# Optional Modules
# =========================================================================
"billing": ModuleDefinition(
code="billing",
name="Billing & Subscriptions",
description="Subscription tiers, billing history, and payment processing.",
features=[
"subscription_management",
"billing_history",
"stripe_integration",
"invoice_generation",
],
menu_items={
FrontendType.ADMIN: [
"subscription-tiers",
"subscriptions",
"billing-history",
],
FrontendType.VENDOR: [
"billing",
"invoices",
],
},
),
# Billing module - imported from app/modules/billing/
"billing": billing_module,
"inventory": ModuleDefinition(
code="inventory",
name="Inventory Management",