Spaces:
Sleeping
Sleeping
| """ | |
| Client Model - Telecom operators/companies that hire contractors | |
| """ | |
| from sqlalchemy import Column, String, Boolean, Integer, DateTime | |
| from sqlalchemy.dialects.postgresql import JSONB | |
| from sqlalchemy.orm import relationship | |
| from app.models.base import BaseModel | |
| class Client(BaseModel): | |
| """ | |
| Client model - Companies that hire contractors for field work | |
| Examples: Airtel Kenya, Safaricom, Zuku, Kenya Power | |
| Maps to 'clients' table in docs/schema/schema.sql | |
| """ | |
| __tablename__ = "clients" | |
| # Basic Info | |
| name = Column(String(255), nullable=False, unique=True) | |
| swiftops_code = Column(String(10), unique=True, nullable=True, index=True) # Unique org code like "FWL25001" | |
| description = Column(String, nullable=True) | |
| industry = Column(String(255), nullable=True) # 'Telecommunications', 'Utilities', etc. | |
| # Contact Info | |
| main_email = Column(String(255), unique=True, nullable=True) | |
| main_phone = Column(String(50), nullable=True) | |
| website = Column(String(500), nullable=True) | |
| # Status | |
| is_active = Column(Boolean, default=True) | |
| # SLA Configuration | |
| default_sla_days = Column(Integer, nullable=True) # Default SLA window for jobs | |
| # Additional Metadata | |
| additional_metadata = Column(JSONB, default={}) | |
| # Relationships (Note: Use string references to avoid circular imports) | |
| customers = relationship("Customer", back_populates="client", lazy="dynamic") | |
| def __repr__(self): | |
| return f"<Client(name='{self.name}', industry='{self.industry}')>" | |