- Rearranged imports in multiple files for consistency and clarity. - Updated logging middleware to exclude specific paths from logging. - Enhanced security module by cleaning up token handling and improving tenant validation. - Added tenant and company scoped mixins for better database model management. - Implemented generic CRUD routes for tenant-scoped resources. - Improved error handling and response management in API routes. - Cleaned up login and logout processes to ensure proper session management. - Introduced mechanisms to clear local storage and cookies on tenant change. - Enhanced company store to detect tenant changes and clear data accordingly. - Added new DTO mixins for currency and value affect flags.
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
from decimal import Decimal
|
|
from typing import Optional
|
|
|
|
from api.v1.common.base_models import TenantScopedMixin
|
|
from core.database import Base
|
|
from sqlalchemy import (
|
|
DECIMAL,
|
|
DateTime,
|
|
ForeignKeyConstraint,
|
|
Integer,
|
|
PrimaryKeyConstraint,
|
|
String,
|
|
UniqueConstraint,
|
|
)
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
|
|
class ExchangeRate(Base, TenantScopedMixin):
|
|
__tablename__ = "exchange_rate"
|
|
__table_args__ = (
|
|
PrimaryKeyConstraint("id", name="exchange_rate_pkey"),
|
|
ForeignKeyConstraint(
|
|
["tenant_id"], ["a76.tenants.id"], name="fk_exchange_rate_tenant"
|
|
),
|
|
ForeignKeyConstraint(
|
|
["company_id"], ["a76.company.id"], name="fk_exchange_rate_company"
|
|
),
|
|
UniqueConstraint(
|
|
"tenant_id", "company_id", "date", name="uq_exchange_rate_date_tenant"
|
|
),
|
|
{"schema": "a76"},
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
|
|
date: Mapped[int] = mapped_column(DateTime)
|
|
value: Mapped[Optional[Decimal]] = mapped_column(DECIMAL(13, 6))
|
|
local_currency: Mapped[Optional[str]] = mapped_column(String(7))
|
|
foreign_currency: Mapped[Optional[str]] = mapped_column(String(7))
|