from sqlalchemy import Column, String, Text, ForeignKey, Integer from sqlalchemy.orm import relationship from app.db.base_class import Base class Client(Base): name = Column(String, index=True, nullable=False) contact_name = Column(String) email = Column(String) phone = Column(String) address = Column(Text) city = Column(String) state = Column(String) postal_code = Column(String) country = Column(String) tax_id = Column(String) notes = Column(Text) # Foreign keys organization_id = Column(Integer, ForeignKey("organization.id", ondelete="CASCADE")) created_by_id = Column(Integer, ForeignKey("user.id", ondelete="SET NULL"), nullable=True) # Relationships organization = relationship("Organization", back_populates="clients") created_by = relationship("User", back_populates="clients") invoices = relationship("Invoice", back_populates="client")