2
from typing import Optional
3
from typing import TYPE_CHECKING
5
from sqlalchemy import ForeignKey, Sequence
6
from sqlalchemy import Numeric, Uuid
7
from sqlalchemy.orm import relationship, mapped_column, Mapped
9
from app.basic.uom.enums.uom_enum import UomType
10
from core.db import Base
11
from core.db.mixins import AllMixin
14
from app.basic.uom.models.uom_category_models import UomCategory
18
class Uom(Base, AllMixin):
21
lsn_seq = Sequence(f'uom_lsn_seq')
22
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, index=True, default=uuid.uuid4)
23
title: Mapped[str] = mapped_column(index=True)
24
uom_category_id: Mapped[Optional[uuid.UUID]] = mapped_column(Uuid, ForeignKey("uom_category.id"))
25
uom_category_rel: Mapped['UomCategory'] = relationship(back_populates='uom_list_rel', lazy='selectin')
26
type: Mapped[str] = mapped_column(index=True, default=UomType.STANDART)
27
ratio: Mapped[float] = mapped_column(Numeric(12, 2), default=1)
28
precision: Mapped[float] = mapped_column(Numeric(12, 2), default=0.01)