f5ca91ee02
- Layout: mobile hamburger menu + overlay backdrop + close button; content area always full-width - Media browser: filter chips (default still+turntable); advanced toggle for GLB/STL; thumbnail_url previews for non-image types; video hover-play for turntable - Backend: asset_types multi-filter, thumbnail_url in MediaAssetOut, download proxy endpoint for MinIO/local files - Admin: "Import Existing Media" button → POST /api/admin/import-media-assets - Billing: fix invoice create 500 (MissingGreenlet — use selectinload after commit); PDF download uses axios blob instead of bare <a href> (auth header missing); fix storage.upload() accepting str|Path - SSE task logs: task_logs.py core + router, LiveRenderLog component - CadPreview: fix infinite loop when no gltf_geometry assets; loading screen before ThreeDViewer render - render-worker: add trimesh layer to Dockerfile Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
65 lines
1.5 KiB
Python
65 lines
1.5 KiB
Python
"""Billing schemas — Invoice + InvoiceLine Pydantic models."""
|
|
from __future__ import annotations
|
|
import uuid
|
|
from datetime import date, datetime
|
|
from decimal import Decimal
|
|
from pydantic import BaseModel, computed_field
|
|
|
|
|
|
class InvoiceLineCreate(BaseModel):
|
|
order_line_id: uuid.UUID | None = None
|
|
description: str
|
|
quantity: int = 1
|
|
unit_price: Decimal | None = None
|
|
|
|
|
|
class InvoiceLineOut(BaseModel):
|
|
id: uuid.UUID
|
|
invoice_id: uuid.UUID
|
|
order_line_id: uuid.UUID | None
|
|
description: str
|
|
quantity: int
|
|
unit_price: Decimal | None
|
|
total: Decimal | None
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class InvoiceCreate(BaseModel):
|
|
order_line_ids: list[uuid.UUID] = []
|
|
notes: str | None = None
|
|
issued_at: date | None = None
|
|
due_at: date | None = None
|
|
vat_rate: Decimal = Decimal("0.19")
|
|
currency: str = "EUR"
|
|
|
|
|
|
class InvoiceStatusUpdate(BaseModel):
|
|
status: str # draft|sent|paid|cancelled
|
|
|
|
|
|
class InvoiceOut(BaseModel):
|
|
id: uuid.UUID
|
|
tenant_id: uuid.UUID | None
|
|
invoice_number: str
|
|
status: str
|
|
issued_at: date | None
|
|
due_at: date | None
|
|
total_net: Decimal | None
|
|
total_vat: Decimal | None
|
|
vat_rate: Decimal
|
|
currency: str
|
|
notes: str | None
|
|
pdf_key: str | None
|
|
created_at: datetime
|
|
lines: list[InvoiceLineOut] = []
|
|
|
|
@computed_field # type: ignore[misc]
|
|
@property
|
|
def pdf_url(self) -> str | None:
|
|
if self.pdf_key:
|
|
return f"/api/billing/invoices/{self.id}/pdf"
|
|
return None
|
|
|
|
model_config = {"from_attributes": True}
|