diff --git a/app/main.py b/app/main.py index c2ed2e8..98c5d31 100644 --- a/app/main.py +++ b/app/main.py @@ -24,7 +24,9 @@ from app.core.monitoring import record_error, record_request from app.core.service_container import get_container from app.plugins.registry import get_registry from app.routes import ( + addresses, ai_copilot, + audit, auth, companies, contacts, @@ -157,6 +159,18 @@ async def lifespan(app: FastAPI): await db.commit() + # Seed default data (EUR currency, 19%/7% tax rates) for all tenants + from app.core.seeds import seed_default_data + + async with async_session() as db: + try: + await seed_default_data(db) + await db.commit() + logger.info("Default data seeding completed") + except Exception as exc: + logger.warning(f"Default data seeding failed: {exc}") + await db.rollback() + yield await close_engine() @@ -196,8 +210,10 @@ def create_app() -> FastAPI: app.include_router(sequences.router) app.include_router(system_settings.router) app.include_router(attachments.router) + app.include_router(addresses.router) + app.include_router(audit.router) - # ── Register plugin routes (before SPA catch-all) ──────────────── + # ── Register plugin routes (before SPA catch-all) ────────────────── registry = get_registry() try: registry.discover_builtins() @@ -216,7 +232,7 @@ def create_app() -> FastAPI: except Exception as exc: logger.warning(f"Plugin discovery failed: {exc}") - # ── Serve frontend static files (SPA) ──────────────────────────── + # ── Serve frontend static files (SPA) ────────────────────────────── # Mount built frontend assets (JS, CSS, images) frontend_dist = os.path.join(os.path.dirname(__file__), "..", "frontend", "dist") if os.path.isdir(frontend_dist):