"""Supplier model for Work Statistics System.""" from datetime import datetime, timezone from app import db class Supplier(db.Model): """Supplier model representing a supplier in the system. Attributes: id: Primary key, auto-incremented name: Supplier's name (required, unique) created_at: Timestamp when the record was created updated_at: Timestamp when the record was last updated """ __tablename__ = 'suppliers' id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(100), nullable=False, unique=True, index=True) created_at = db.Column(db.DateTime, default=lambda: datetime.now(timezone.utc)) updated_at = db.Column(db.DateTime, default=lambda: datetime.now(timezone.utc), onupdate=lambda: datetime.now(timezone.utc)) def to_dict(self): """Convert model to dictionary for JSON serialization. Returns: Dictionary representation of the supplier """ return { 'id': self.id, 'name': self.name, 'created_at': self.created_at.isoformat() if self.created_at else None, 'updated_at': self.updated_at.isoformat() if self.updated_at else None } def __repr__(self): return f''