Olympus/backend/hermes/app/schemas/customer_import.py

49 lines
1.2 KiB
Python

from typing import Literal
from pydantic import BaseModel, Field
ImportMode = Literal["create_only", "update_existing", "upsert"]
ImportAction = Literal["create", "update", "skip", "error"]
class CustomerImportIssue(BaseModel):
row: int
field: str = ""
message: str
class CustomerImportPreviewRow(BaseModel):
row: int
customer_number: str = ""
company_name: str = ""
action: ImportAction
errors: list[CustomerImportIssue] = Field(default_factory=list)
warnings: list[CustomerImportIssue] = Field(default_factory=list)
class CustomerImportSummary(BaseModel):
total_rows: int
valid_rows: int
error_count: int
warning_count: int
duplicate_count: int
create_count: int
update_count: int
skip_count: int
class CustomerImportPreviewResponse(BaseModel):
mode: ImportMode
summary: CustomerImportSummary
rows: list[CustomerImportPreviewRow]
errors: list[CustomerImportIssue]
warnings: list[CustomerImportIssue]
duplicates: list[CustomerImportIssue]
class CustomerImportCommitResponse(BaseModel):
mode: ImportMode
summary: CustomerImportSummary
created: int
updated: int
skipped: int