- Replace black, isort, and flake8 with Ruff (all-in-one linter and formatter) - Add comprehensive pyproject.toml configuration - Simplify Makefile code quality targets - Configure exclusions for venv/.venv in pyproject.toml - Auto-fix 1,359 linting issues across codebase Benefits: - Much faster builds (Ruff is written in Rust) - Single tool replaces multiple tools - More comprehensive rule set (UP, B, C4, SIM, PIE, RET, Q) - All configuration centralized in pyproject.toml - Better import sorting and formatting consistency 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
85 lines
1.9 KiB
Python
85 lines
1.9 KiB
Python
# models/schema/inventory.py
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class InventoryBase(BaseModel):
|
|
product_id: int = Field(..., description="Product ID in vendor catalog")
|
|
location: str = Field(..., description="Storage location")
|
|
|
|
|
|
class InventoryCreate(InventoryBase):
|
|
"""Set exact inventory quantity (replaces existing)."""
|
|
|
|
quantity: int = Field(..., description="Exact inventory quantity", ge=0)
|
|
|
|
|
|
class InventoryAdjust(InventoryBase):
|
|
"""Add or remove inventory quantity."""
|
|
|
|
quantity: int = Field(
|
|
..., description="Quantity to add (positive) or remove (negative)"
|
|
)
|
|
|
|
|
|
class InventoryUpdate(BaseModel):
|
|
"""Update inventory fields."""
|
|
|
|
quantity: int | None = Field(None, ge=0)
|
|
reserved_quantity: int | None = Field(None, ge=0)
|
|
location: str | None = None
|
|
|
|
|
|
class InventoryReserve(BaseModel):
|
|
"""Reserve inventory for orders."""
|
|
|
|
product_id: int
|
|
location: str
|
|
quantity: int = Field(..., gt=0)
|
|
|
|
|
|
class InventoryResponse(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
product_id: int
|
|
vendor_id: int
|
|
location: str
|
|
quantity: int
|
|
reserved_quantity: int
|
|
gtin: str | None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
@property
|
|
def available_quantity(self):
|
|
return max(0, self.quantity - self.reserved_quantity)
|
|
|
|
|
|
class InventoryLocationResponse(BaseModel):
|
|
location: str
|
|
quantity: int
|
|
reserved_quantity: int
|
|
available_quantity: int
|
|
|
|
|
|
class ProductInventorySummary(BaseModel):
|
|
"""Inventory summary for a product."""
|
|
|
|
product_id: int
|
|
vendor_id: int
|
|
product_sku: str | None
|
|
product_title: str
|
|
total_quantity: int
|
|
total_reserved: int
|
|
total_available: int
|
|
locations: list[InventoryLocationResponse]
|
|
|
|
|
|
class InventoryListResponse(BaseModel):
|
|
inventories: list[InventoryResponse]
|
|
total: int
|
|
skip: int
|
|
limit: int
|