44 lines
782 B
Python
44 lines
782 B
Python
import uuid
|
|
|
|
from decimal import Decimal
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from . import to_camel
|
|
|
|
|
|
class TaxIn(BaseModel):
|
|
name: str = Field(..., min_length=1)
|
|
rate: Decimal = Field(ge=0, default=0)
|
|
is_fixture: bool
|
|
|
|
class Config:
|
|
anystr_strip_whitespace = True
|
|
alias_generator = to_camel
|
|
|
|
|
|
class Tax(TaxIn):
|
|
id_: uuid.UUID
|
|
|
|
class Config:
|
|
anystr_strip_whitespace = True
|
|
alias_generator = to_camel
|
|
|
|
|
|
class TaxBlank(TaxIn):
|
|
name: str
|
|
|
|
class Config:
|
|
anystr_strip_whitespace = True
|
|
alias_generator = to_camel
|
|
|
|
|
|
class TaxLink(BaseModel):
|
|
id_: uuid.UUID = Field(...)
|
|
name: Optional[str]
|
|
rate: Optional[Decimal]
|
|
|
|
class Config:
|
|
fields = {"id_": "id"}
|