
- Fix unused imports in API endpoints - Add proper __all__ exports in model and schema modules - Add proper TYPE_CHECKING imports in models to prevent circular imports - Fix import order in migrations - Fix long lines in migration scripts - All ruff checks passing
58 lines
1.5 KiB
Python
58 lines
1.5 KiB
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from app.models.inventory_transaction import TransactionType
|
|
|
|
|
|
# Shared properties
|
|
class InventoryTransactionBase(BaseModel):
|
|
"""
|
|
Base schema for inventory transaction data.
|
|
"""
|
|
transaction_type: Optional[TransactionType] = None
|
|
quantity: Optional[int] = None
|
|
transaction_date: Optional[datetime] = None
|
|
notes: Optional[str] = None
|
|
unit_price: Optional[float] = None
|
|
reference_number: Optional[str] = None
|
|
product_id: Optional[str] = None
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
class InventoryTransactionCreate(InventoryTransactionBase):
|
|
"""
|
|
Schema for creating new inventory transactions.
|
|
"""
|
|
transaction_type: TransactionType
|
|
quantity: int
|
|
product_id: str
|
|
transaction_date: datetime = Field(default_factory=datetime.utcnow)
|
|
|
|
|
|
# Properties to receive via API on update
|
|
class InventoryTransactionUpdate(InventoryTransactionBase):
|
|
"""
|
|
Schema for updating inventory transaction data.
|
|
"""
|
|
pass
|
|
|
|
|
|
class InventoryTransactionInDBBase(InventoryTransactionBase):
|
|
"""
|
|
Base schema for inventory transaction data from the database.
|
|
"""
|
|
id: str
|
|
created_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Additional properties to return via API
|
|
class InventoryTransaction(InventoryTransactionInDBBase):
|
|
"""
|
|
Schema for inventory transaction data to return via API.
|
|
"""
|
|
pass |