- Enhanced TenantMiddleware to validate tenant information from JWT tokens. - Added LicenseValidationMiddleware to check tenant licenses before processing requests. - Updated security utilities to extract tenant information from tokens and validate company access. - Introduced CompanyStore to manage active company state and handle company switching in the frontend. - Modified API routes to include company_id in requests for better resource management. - Improved logging and error handling throughout the middleware and API layers. - Updated frontend components to reflect changes in company management and selection. - Added new API route for fetching user's companies with proper authentication handling.
43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
from decimal import Decimal
|
|
from sqlalchemy import (
|
|
Boolean,
|
|
ForeignKeyConstraint,
|
|
Integer,
|
|
Numeric,
|
|
PrimaryKeyConstraint,
|
|
String,
|
|
)
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from sqlalchemy.orm.base import Mapped
|
|
|
|
from core.database import Base
|
|
|
|
|
|
class QClasses(Base):
|
|
__tablename__ = "q_classes" # QClases
|
|
__table_args__ = (
|
|
PrimaryKeyConstraint("id", name="qclases_pk"),
|
|
ForeignKeyConstraint(
|
|
["tenant_id"], ["a76.tenants.id"], name="fk_qclasses_tenants"
|
|
),
|
|
ForeignKeyConstraint(
|
|
["company_id"], ["a76.company.id"], name="fk_qclasses_company"
|
|
),
|
|
ForeignKeyConstraint(["class_id"], ["classes.id"], name="fk_qclasses_classes"),
|
|
{"schema": "a24"},
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
class_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
|
company_id: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
|
|
|
|
import_tariff_code: Mapped[str] = mapped_column(String(10)) # FRACCIONIMPO
|
|
import_tariff_type: Mapped[str] = mapped_column(String(6)) # TIPOFRACIMPO
|
|
export_tariff_code: Mapped[str] = mapped_column(String(10)) # FRACCIONEXPO
|
|
export_tariff_type: Mapped[str] = mapped_column(String(6)) # TIPOFRACEXPO
|
|
depreciation_rate: Mapped[Decimal] = mapped_column(Numeric(5, 2)) # TASADEPRECIA
|
|
fda_code: Mapped[str] = mapped_column(String(20)) # FDA
|
|
eccn_code: Mapped[str] = mapped_column(String(20)) # ECCN
|
|
class_enabled: Mapped[bool] = mapped_column(Boolean) # HABILITADESHABILITACLASE
|