- New clients table with PF/PJ support, fiscal data (CUI, IBAN, eFactura fields) - Full CRUD API for clients with search, sync integration - Order lifecycle: edit header (DRAFT), devalidate (VALIDAT→DRAFT), delete order/invoice - Invoice types: FACTURA (B2B) vs BON_FISCAL (B2C) with different nr formats - OrderCreateView redesigned as multi-step flow (client→vehicle→details) - Autocomplete from catalog_norme/catalog_preturi in OrderLineForm - Dashboard now combines stats + full orders table with filter tabs and search - ClientPicker and VehiclePicker with inline creation capability - Frontend schema aligned with backend (missing columns causing sync errors) - Mobile responsive fixes for OrderDetailView buttons Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.auth.router import router as auth_router
|
|
from app.client_portal.router import router as portal_router
|
|
from app.clients.router import router as clients_router
|
|
from app.config import settings
|
|
from app.db.base import Base
|
|
from app.db.session import engine
|
|
from app.invoices.router import router as invoices_router
|
|
from app.orders.router import router as orders_router
|
|
from app.sync.router import router as sync_router
|
|
from app.users.router import router as users_router
|
|
from app.vehicles.router import router as vehicles_router
|
|
|
|
# Import models so Base.metadata knows about them
|
|
import app.db.models # noqa: F401
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
async with engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.create_all)
|
|
yield
|
|
|
|
|
|
app = FastAPI(lifespan=lifespan)
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.CORS_ORIGINS.split(","),
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
allow_credentials=True,
|
|
)
|
|
app.include_router(auth_router, prefix="/api/auth")
|
|
app.include_router(sync_router, prefix="/api/sync")
|
|
app.include_router(clients_router, prefix="/api/clients")
|
|
app.include_router(orders_router, prefix="/api/orders")
|
|
app.include_router(vehicles_router, prefix="/api/vehicles")
|
|
app.include_router(invoices_router, prefix="/api/invoices")
|
|
app.include_router(users_router, prefix="/api/users")
|
|
app.include_router(portal_router, prefix="/api")
|
|
|
|
|
|
@app.get("/api/health")
|
|
async def health():
|
|
return {"status": "ok"}
|