FEAT: Corporate onboarding implemented with Tax ID validation (HU) and isolated NAS storage
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,14 +1,18 @@
|
||||
import enum
|
||||
from sqlalchemy import Column, Integer, String, Boolean, Enum, DateTime, ForeignKey
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, JSON
|
||||
from sqlalchemy.dialects.postgresql import ENUM as PG_ENUM
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
from app.db.base import Base
|
||||
|
||||
class OrgType(str, enum.Enum):
|
||||
INDIVIDUAL = "individual"
|
||||
SERVICE = "service"
|
||||
FLEET_OWNER = "fleet_owner"
|
||||
CLUB = "club"
|
||||
# A tagok neveit kisbetűre állítjuk, hogy egyezzenek a Postgres Enum értékekkel
|
||||
individual = "individual"
|
||||
service = "service"
|
||||
service_provider = "service_provider"
|
||||
fleet_owner = "fleet_owner"
|
||||
club = "club"
|
||||
business = "business"
|
||||
|
||||
class Organization(Base):
|
||||
__tablename__ = "organizations"
|
||||
@@ -16,24 +20,38 @@ class Organization(Base):
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String, nullable=False)
|
||||
# A stabilitás miatt VARCHAR-ként kezeljük a DB-ben
|
||||
org_type = Column(String(50), default="individual")
|
||||
|
||||
# A flotta technikai tulajdonosa (User)
|
||||
# PG_ENUM használata a Python Enum-mal szinkronizálva
|
||||
org_type = Column(
|
||||
PG_ENUM(OrgType, name="orgtype", inherit_schema=True),
|
||||
default=OrgType.individual
|
||||
)
|
||||
|
||||
tax_number = Column(String(20), unique=True, index=True)
|
||||
reg_number = Column(String(50))
|
||||
headquarters_address = Column(String(255))
|
||||
country_code = Column(String(2), default="HU")
|
||||
|
||||
status = Column(String(30), default="pending_verification")
|
||||
is_deleted = Column(Boolean, default=False)
|
||||
|
||||
notification_settings = Column(JSON, default={
|
||||
"notify_owner": True,
|
||||
"notify_manager": True,
|
||||
"notify_contact": True,
|
||||
"alert_days_before": [30, 15, 7, 1]
|
||||
})
|
||||
external_integration_config = Column(JSON, default={})
|
||||
|
||||
owner_id = Column(Integer, ForeignKey("data.users.id"), nullable=True)
|
||||
|
||||
# Üzleti szabályok
|
||||
is_active = Column(Boolean, default=True)
|
||||
is_transferable = Column(Boolean, default=True)
|
||||
|
||||
# Verifikáció
|
||||
is_verified = Column(Boolean, default=False)
|
||||
verification_expires_at = Column(DateTime(timezone=True), nullable=True)
|
||||
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
# Kapcsolatok (Asset-re hivatkozunk a Vehicle helyett)
|
||||
assets = relationship("Asset", back_populates="organization", cascade="all, delete-orphan")
|
||||
members = relationship("OrganizationMember", back_populates="organization")
|
||||
owner = relationship("User", back_populates="owned_organizations")
|
||||
@@ -48,5 +66,5 @@ class OrganizationMember(Base):
|
||||
|
||||
organization = relationship("Organization", back_populates="members")
|
||||
|
||||
# --- EZT A SORT TEDD KÍVÜLRE, A MARGÓRA ---
|
||||
# Kompatibilitási réteg a korábbi kódokhoz
|
||||
Organization.vehicles = Organization.assets
|
||||
@@ -20,15 +20,17 @@ class VehicleCatalog(Base):
|
||||
engine_type = Column(String(50))
|
||||
engine_power_kw = Column(Integer)
|
||||
|
||||
# --- EZ A SOR HIÁNYZOTT ---
|
||||
# Robot státusz és gyári adatok
|
||||
verification_status = Column(String(20), default="verified")
|
||||
|
||||
factory_specs = Column(JSON, default={})
|
||||
maintenance_plan = Column(JSON, default={})
|
||||
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
# Kapcsolat az egyedi példányok felé
|
||||
assets = relationship("Asset", back_populates="catalog_entry")
|
||||
|
||||
# 2. EGYEDI ESZKÖZ (Asset) - A felhasználó tulajdona
|
||||
class Asset(Base):
|
||||
__tablename__ = "assets"
|
||||
@@ -52,13 +54,16 @@ class Asset(Base):
|
||||
factory_config = Column(JSON, default={})
|
||||
aftermarket_mods = Column(JSON, default={})
|
||||
|
||||
# Állapot és láthatóság (EZ HIÁNYZOTT)
|
||||
status = Column(String(50), default="active")
|
||||
privacy_level = Column(String(20), default="private")
|
||||
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
# Kapcsolatok
|
||||
organization = relationship("Organization", back_populates="assets")
|
||||
catalog_entry = relationship("VehicleCatalog")
|
||||
catalog_entry = relationship("VehicleCatalog", back_populates="assets")
|
||||
events = relationship("AssetEvent", back_populates="asset", cascade="all, delete-orphan")
|
||||
ratings = relationship("AssetRating", back_populates="asset")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user