- Implemented the items tab form in Svelte for editing invoices, displaying item quantities and import values. - Created saveInvoice function to handle both creation and updating of invoices, including validation of required fields and building a unified payload for API requests. - Added support for compliance, financials, and logistics data in the invoice payload.
53 lines
2.7 KiB
Python
53 lines
2.7 KiB
Python
from decimal import Decimal
|
|
from typing import Optional
|
|
from pydantic import BaseModel, Field, ConfigDict
|
|
|
|
# ============================================================================
|
|
# LINE QUANTITY SCHEMAS
|
|
# ============================================================================
|
|
|
|
class LineQuantityBase(BaseModel):
|
|
"""Base schema for line quantities"""
|
|
# Quantities
|
|
quantity: Optional[Decimal] = Field(None, description="Main quantity (CANTIMPO/CANTEXPO/CANTIMPODEF)")
|
|
alternate_quantity: Optional[Decimal] = Field(None, description="Alternate quantity (CANTALTERNA)")
|
|
quantity_uma: Optional[Decimal] = Field(None, description="UMA quantity (CANTIMPOUMA/CANTEXPOUMA)")
|
|
auxiliary_quantity: Optional[Decimal] = Field(None, description="Auxiliary quantity (CANTIMPOAUXILIAR/CANTEXPOAUXILIAR)")
|
|
|
|
# Quantities - Special (SCAF specific)
|
|
quantity_temp_export: Optional[Decimal] = Field(None, description="Temporary export quantity (CANTEXPOTEMP)")
|
|
quantity_existence: Optional[Decimal] = Field(None, description="Existence quantity (CANTEXISTENCIA)")
|
|
quantity_returned: Optional[Decimal] = Field(None, description="Returned quantity (CANTRETORNADA)")
|
|
quantity_returned_temp: Optional[Decimal] = Field(None, description="Returned temporary quantity (CANTRETORNADATEMP)")
|
|
serial_count: Optional[int] = Field(None, description="Serial count (CANT_SERIES/CANT_SERIESDEF)")
|
|
|
|
# Weight
|
|
weight_unit: Optional[str] = Field(None, max_length=3, description="Weight unit ('KG' or 'LB')")
|
|
net_weight: Optional[Decimal] = Field(None, description="Net weight (PESONETO)")
|
|
gross_weight: Optional[Decimal] = Field(None, description="Gross weight (PESOBRUTO)")
|
|
|
|
# Packaging
|
|
package_key: Optional[str] = Field(None, max_length=5, description="Package key (CLAVEBULTOS)")
|
|
package_quantity: Optional[int] = Field(None, description="Package quantity (CANTBULTOS)")
|
|
package_description: Optional[str] = Field(None, max_length=40, description="Package description (DESCBULTOS)")
|
|
container_quantity: Optional[int] = Field(None, description="Container quantity (CANTBULCONT)")
|
|
container_description: Optional[str] = Field(None, max_length=40, description="Container description (DESCCONTENEDOR)")
|
|
box_count: Optional[str] = Field(None, max_length=30, description="Box count (NOCAJAS)")
|
|
|
|
|
|
class LineQuantityCreate(LineQuantityBase):
|
|
"""Schema for creating line quantity"""
|
|
pass
|
|
|
|
|
|
class LineQuantityUpdate(LineQuantityBase):
|
|
"""Schema for updating line quantity"""
|
|
pass
|
|
|
|
|
|
class LineQuantityResponse(LineQuantityBase):
|
|
"""Schema for line quantity response"""
|
|
id: int
|
|
item_line_id: int
|
|
|
|
model_config = ConfigDict(from_attributes=True) |