- pyproject.toml: add [tool.ruff] config suppressing E402/W293 globally, F841/E741/E702 in tests, E741 in scripts - inventory.py: split semicolon import (E702) - recipes.py: fix logger -> log (F821 undefined name) - shopping.py: rename l -> lnk in list comprehension (E741) - format_conversion.py: noqa F841 on CUDA flag (used as future hook) - backfill_keywords.py: rename done -> _done (F841) - ingest_purplecarrot.py: drop == True comparison (E712) - Auto-fix: I001 import sorting, F401 unused imports across all files
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
"""Receipt schemas (integer IDs, SQLite-compatible)."""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ReceiptResponse(BaseModel):
|
|
id: int
|
|
filename: str
|
|
status: str
|
|
error: Optional[str] = None
|
|
metadata: Dict[str, Any] = {}
|
|
created_at: str
|
|
updated_at: str
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class ApproveOCRRequest(BaseModel):
|
|
"""Approve staged OCR items for inventory population.
|
|
|
|
item_indices: which items (by 0-based index) to approve.
|
|
Omit or pass null to approve all items.
|
|
location: pantry location for created inventory items.
|
|
"""
|
|
item_indices: Optional[List[int]] = Field(
|
|
default=None,
|
|
description="0-based indices of items to approve. Null = approve all.",
|
|
)
|
|
location: str = Field(default="pantry")
|
|
|
|
|
|
class ApprovedInventoryItem(BaseModel):
|
|
inventory_id: int
|
|
product_name: str
|
|
quantity: float
|
|
location: str
|
|
expiration_date: Optional[str] = None
|
|
|
|
|
|
class ApproveOCRResponse(BaseModel):
|
|
receipt_id: int
|
|
approved: int
|
|
skipped: int
|
|
inventory_items: List[ApprovedInventoryItem]
|