refactor: move letzshop endpoints to marketplace module and add vendor service tests

Move letzshop-related functionality from tenancy to marketplace module:
- Move admin letzshop routes to marketplace/routes/api/admin_letzshop.py
- Move letzshop schemas to marketplace/schemas/letzshop.py
- Remove letzshop code from tenancy module (admin_vendors, vendor_service)
- Update model exports and imports

Add comprehensive unit tests for vendor services:
- test_company_service.py: Company management operations
- test_platform_service.py: Platform management operations
- test_vendor_domain_service.py: Vendor domain operations
- test_vendor_team_service.py: Vendor team management

Update module definitions:
- billing, messaging, payments: Minor definition updates

Add architecture proposals documentation:
- Module dependency redesign session notes
- Decouple modules implementation plan
- Module decoupling proposal

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-04 19:25:00 +01:00
parent 37942ae02b
commit 0583dd2cc4
29 changed files with 3643 additions and 650 deletions

View File

@@ -14,12 +14,12 @@ This is the canonical location for tenancy module models including:
# These imports are NOT re-exported, just ensure models are registered with SQLAlchemy
# before the tenancy models are loaded.
#
# Relationship chain being resolved:
# Relationship being resolved:
# - Platform.admin_menu_configs -> "AdminMenuConfig" (in core module)
# - User.marketplace_import_jobs -> "MarketplaceImportJob" (in marketplace module)
# - Vendor.marketplace_import_jobs -> "MarketplaceImportJob" (in marketplace module)
#
# NOTE: MarketplaceImportJob relationships have been moved to the marketplace module.
# Optional modules own their relationships to core models, not vice versa.
from app.modules.core.models import AdminMenuConfig # noqa: F401
from app.modules.marketplace.models.marketplace_import_job import MarketplaceImportJob # noqa: F401
from app.modules.tenancy.models.admin import (
AdminAuditLog,

View File

@@ -56,9 +56,8 @@ class User(Base, TimestampMixin):
preferred_language = Column(String(5), nullable=True)
# Relationships
marketplace_import_jobs = relationship(
"MarketplaceImportJob", back_populates="user"
)
# NOTE: marketplace_import_jobs relationship removed - owned by marketplace module
# Use: MarketplaceImportJob.query.filter_by(user_id=user.id) instead
owned_companies = relationship("Company", back_populates="owner")
vendor_memberships = relationship(
"VendorUser", foreign_keys="[VendorUser.user_id]", back_populates="user"

View File

@@ -3,7 +3,9 @@
Vendor model representing entities that sell products or services.
This module defines the Vendor model along with its relationships to
other models such as User (owner), Product, Customer, Order, and MarketplaceImportJob.
other models such as User (owner), Product, Customer, and Order.
Note: MarketplaceImportJob relationships are owned by the marketplace module.
"""
import enum
@@ -143,9 +145,8 @@ class Vendor(Base, TimestampMixin):
orders = relationship(
"Order", back_populates="vendor"
) # Relationship with Order model for orders placed by this vendor
marketplace_import_jobs = relationship(
"MarketplaceImportJob", back_populates="vendor"
) # Relationship with MarketplaceImportJob model for import jobs related to this vendor
# NOTE: marketplace_import_jobs relationship removed - owned by marketplace module
# Use: MarketplaceImportJob.query.filter_by(vendor_id=vendor.id) instead
# Letzshop integration credentials (one-to-one)
letzshop_credentials = relationship(