- 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.
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from sqlalchemy import (
|
|
ForeignKeyConstraint,
|
|
Integer,
|
|
PrimaryKeyConstraint,
|
|
String,
|
|
UniqueConstraint,
|
|
)
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from sqlalchemy.orm.base import Mapped
|
|
from core.database import Base
|
|
|
|
|
|
class SClasses(Base):
|
|
__tablename__ = "s_classes" # SClases
|
|
__table_args__ = (
|
|
ForeignKeyConstraint(
|
|
["tenant_id"], ["a76.tenants.id"], name="fk_sclasses_tenants"
|
|
),
|
|
ForeignKeyConstraint(
|
|
["company_id"], ["a76.company.id"], name="fk_sclasses_company"
|
|
),
|
|
ForeignKeyConstraint(
|
|
["class_id"], ["a76.clases.class_id"], name="fk_sclasses_classes"
|
|
),
|
|
PrimaryKeyConstraint("id", name="sclases_pk"),
|
|
{"schema": "a24"},
|
|
)
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
class_id: Mapped[int] = mapped_column(Integer, nullable=False) # Id de clase
|
|
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
|
company_id: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
|
|
|
|
stock_um: Mapped[str] = mapped_column(String(5)) # Unidad de medida para existencia
|
|
us_tariff_code: Mapped[str] = mapped_column(String(19)) # Fracción americana (USA)
|