32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
"""Currency model — multi-currency support for ERP."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import uuid
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import Boolean, DateTime, Index, String
|
|
from sqlalchemy.dialects.postgresql import UUID as PGUUID
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.core.db import Base, TenantMixin
|
|
|
|
|
|
class Currency(Base, TenantMixin):
|
|
"""Currency entity — e.g. EUR, USD, GBP."""
|
|
|
|
__tablename__ = "currencies"
|
|
__table_args__ = (
|
|
Index("ix_currencies_tenant_code", "tenant_id", "code"),
|
|
Index("ix_currencies_tenant_default", "tenant_id", "is_default"),
|
|
)
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(
|
|
PGUUID(as_uuid=True), primary_key=True, default=uuid.uuid4
|
|
)
|
|
code: Mapped[str] = mapped_column(String(3), nullable=False, unique=True)
|
|
name: Mapped[str] = mapped_column(String(50), nullable=False)
|
|
symbol: Mapped[str] = mapped_column(String(5), nullable=False)
|
|
is_default: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
|
deleted_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|