feat(estimates): integrate inventory items

This commit is contained in:
Schubert Ferenc 2026-07-05 11:54:23 +02:00
parent fb5c2cc26a
commit 663bdc41b1
15 changed files with 629 additions and 28 deletions

View file

@ -18,7 +18,9 @@ def normalize_text(value: object) -> str:
class RepairEstimateItemPayload(BaseModel):
item_type: EstimateItemType = "other"
title: str = Field(min_length=1, max_length=255)
inventory_item_id: int | None = None
inventory_price_overridden: bool = False
title: str = Field(default="", max_length=255)
description: str | None = None
quantity: Decimal = Field(gt=Decimal("0"))
unit: str = Field(default="Stk.", max_length=40)
@ -38,6 +40,12 @@ class RepairEstimateItemPayload(BaseModel):
return value.strip().replace(",", ".")
return value
@model_validator(mode="after")
def validate_inventory_or_title(self):
if self.inventory_item_id is None and not self.title.strip():
raise ValueError("Titel ist erforderlich")
return self
class RepairEstimatePayload(BaseModel):
title: str = Field(min_length=1, max_length=255)
@ -85,6 +93,11 @@ class RepairEstimateUpdate(RepairEstimatePayload):
class RepairEstimateItemResponse(BaseModel):
id: int
estimate_id: int
inventory_item_id: int | None
inventory_snapshot_name: str
inventory_snapshot_sku: str
inventory_snapshot_manufacturer: str | None
inventory_snapshot_part_number: str | None
position: int
item_type: EstimateItemType
title: str
@ -139,6 +152,10 @@ class RepairEstimateResponse(BaseModel):
class PublicEstimateItemResponse(BaseModel):
item_type: EstimateItemType
inventory_snapshot_name: str
inventory_snapshot_sku: str
inventory_snapshot_manufacturer: str | None
inventory_snapshot_part_number: str | None
title: str
description: str | None
quantity: Decimal