1
from __future__ import annotations
3
from typing import Optional, List
5
from fastapi_filter.contrib.sqlalchemy import Filter
6
from pydantic import BaseModel, Field, UUID4
8
from app.basic.uom.models.uom_models import Uom
9
from app.basic.uom.models.uom_models import UomType
10
from core.schemas import BaseFilter
11
from core.schemas.basic_schemes import BasicModel
12
from core.schemas.list_schema import GenericListSchema
13
from core.schemas.timestamps import TimeStampScheme
16
class UomBaseScheme(BasicModel):
17
title: str = Field(title="Title", table=True)
18
uom_category_id: UUID4 = Field(title="Uom Category", table=True, description='Select category of UOM Category', model='uom_category')
19
type: 'UomType' = Field(title="Uom Type", table=True,
20
description='Select type \n SMALLER: this category is smaller \n BIGGER... STANDART')
21
ratio: float = Field(title="Ratio", table=True, description='Ratio')
22
precision: float = Field(title="Presicion", table=True, description='Rouding Precision')
26
from_attributes = True
28
service = 'app.basic.uom.services.UomService'
31
class UomUpdateScheme(UomBaseScheme):
35
class UomCreateScheme(UomBaseScheme):
39
class UomScheme(UomCreateScheme, TimeStampScheme):
45
class UomFilter(BaseFilter):
46
title__in: Optional[List[str]] = Field(default=None, description="title")
47
uom_category_id__in: Optional[List[str]] = Field(default=None, description="category_id", model='uom_category')
48
type__in: Optional[List['UomType']] = Field(default=None, description="type")
51
populate_by_name = True
53
class Constants(Filter.Constants):
55
ordering_field_name = "order_by"
56
search_field_name = "search"
57
search_model_fields = ["title", ]
60
class UomListSchema(GenericListSchema):
61
data: Optional[List['UomScheme']]
64
class ConvertSchema(BaseModel):
69
quantity_out: Optional[float] = None