- Implemented packages section for item details in `packages-section.svelte` - Created summary section to display general data and weights in `summary-section.svelte` - Developed tab continuation for additional item details in `tab-continuation.svelte` - Added identifiers tab for managing item identifiers in `tab-identifiers.svelte` - Introduced labeling tab for item labeling information in `tab-labeling.svelte` - Created serial numbers tab for entering multiple serial numbers in `tab-series.svelte` - Built item sheet for inventory items in `item-sheet-inv.svelte` - Developed items tab form for managing invoice items in `items-tab-form.svelte`
75 lines
2.5 KiB
Python
75 lines
2.5 KiB
Python
"""
|
|
Schemas for Items and related entities
|
|
Complete nested one-to-one structure:
|
|
Item -> LineItem -> LineFinancial -> LineQuantity -> LineCustoms -> LineDescription -> LineReference
|
|
"""
|
|
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
from decimal import Decimal
|
|
from pydantic import BaseModel, Field, ConfigDict
|
|
|
|
# Import schemas from individual modules
|
|
from .line_items.schemas import (
|
|
LineItemCreate,
|
|
LineItemUpdate,
|
|
LineItemResponse
|
|
)
|
|
|
|
|
|
# ============================================================================
|
|
# ITEM SCHEMAS
|
|
# ============================================================================
|
|
|
|
class ItemBase(BaseModel):
|
|
"""Base schema for items"""
|
|
invoice_id: int = Field(..., description="Invoice ID")
|
|
reference_number: Optional[str] = Field(
|
|
None, max_length=20, description="Reference number")
|
|
order: Optional[str] = Field(None, max_length=50, description="Order")
|
|
guide_number: Optional[str] = Field(
|
|
None, max_length=50, description="Guide number")
|
|
|
|
# Dates
|
|
depreciation_date: Optional[int] = Field(
|
|
None, description="Depreciation date")
|
|
|
|
# Administrative fields
|
|
rectification: Optional[int] = Field(None, description="Rectification")
|
|
warehouse: Optional[str] = Field(
|
|
None, max_length=30, description="Warehouse")
|
|
location: Optional[str] = Field(
|
|
None, max_length=200, description="Location")
|
|
|
|
|
|
class ItemCreate(ItemBase):
|
|
"""Schema for creating item with nested lines (one-to-many)"""
|
|
lines: Optional[list[LineItemCreate]] = Field(
|
|
default=[], description="List of line items")
|
|
|
|
|
|
class ItemUpdate(ItemBase):
|
|
"""Schema for updating item"""
|
|
invoice_id: Optional[int] = Field(None, description="Invoice ID")
|
|
lines: Optional[list[LineItemUpdate]] = Field(
|
|
None, description="List of line items to update")
|
|
|
|
|
|
class ItemResponse(ItemBase):
|
|
"""Schema for item response with nested data (one-to-many)"""
|
|
id: int
|
|
lines: list[LineItemResponse] = Field(
|
|
default=[], description="List of line items")
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class ItemListResponse(BaseModel):
|
|
"""Schema for paginated item list"""
|
|
total: int = Field(..., description="Total number of items")
|
|
items: list[ItemResponse] = Field(..., description="List of items")
|
|
skip: int = Field(..., description="Number of skipped items")
|
|
limit: int = Field(..., description="Maximum items per page")
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|