File size: 1,575 Bytes
dce1329
 
 
 
 
5dccf83
dce1329
 
 
 
 
 
 
 
 
 
 
 
 
 
2b747fd
dce1329
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38ac151
5dccf83
38ac151
dce1329
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
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}')>"