- 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>
33 lines
1.8 KiB
Python
33 lines
1.8 KiB
Python
from sqlalchemy import Float, Integer, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.base import Base, UUIDMixin, TenantMixin, TimestampMixin
|
|
|
|
|
|
class Order(Base, UUIDMixin, TenantMixin, TimestampMixin):
|
|
__tablename__ = "orders"
|
|
nr_comanda: Mapped[str | None] = mapped_column(String(50))
|
|
vehicle_id: Mapped[str | None] = mapped_column(String(36))
|
|
client_id: Mapped[str | None] = mapped_column(String(36))
|
|
tip_deviz_id: Mapped[str | None] = mapped_column(String(36))
|
|
status: Mapped[str] = mapped_column(String(20), default="DRAFT", server_default="DRAFT")
|
|
data_comanda: Mapped[str | None] = mapped_column(Text)
|
|
km_intrare: Mapped[int | None] = mapped_column(Integer)
|
|
observatii: Mapped[str | None] = mapped_column(Text)
|
|
mecanic_id: Mapped[str | None] = mapped_column(String(36))
|
|
# Denormalized client/vehicle info for quick display
|
|
client_nume: Mapped[str | None] = mapped_column(String(200))
|
|
client_telefon: Mapped[str | None] = mapped_column(String(20))
|
|
nr_auto: Mapped[str | None] = mapped_column(String(20))
|
|
marca_denumire: Mapped[str | None] = mapped_column(String(100))
|
|
model_denumire: Mapped[str | None] = mapped_column(String(100))
|
|
# Totals — server_default ensures raw SQL INSERT without these fields still works
|
|
total_manopera: Mapped[float] = mapped_column(Float, default=0, server_default="0")
|
|
total_materiale: Mapped[float] = mapped_column(Float, default=0, server_default="0")
|
|
total_general: Mapped[float] = mapped_column(Float, default=0, server_default="0")
|
|
# Client portal
|
|
token_client: Mapped[str | None] = mapped_column(String(36))
|
|
status_client: Mapped[str | None] = mapped_column(String(20))
|
|
# Audit
|
|
created_by: Mapped[str | None] = mapped_column(String(36))
|