feat(customers): add initial admin bootstrap and csv import
This commit is contained in:
parent
c816e9869d
commit
ecab0fe6b6
27 changed files with 1197 additions and 34 deletions
49
backend/hermes/app/schemas/customer_import.py
Normal file
49
backend/hermes/app/schemas/customer_import.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue