from sqlalchemy import String, Uuid, Column, DateTime, Enum, Numeric, ForeignKey from app.schemas.transaction import TransactionEventTriggerReason, TransactionStatus from app.database import Base class Transaction(Base): __tablename__ = "transactions" id = Column(String, primary_key=True) status = Column(Enum(TransactionStatus), index=True) started_at = Column(DateTime, index=True) ended_at = Column(DateTime, nullable=True, index=True) meter_start = Column(Numeric(10,2)) meter_end = Column(Numeric(10,2), nullable=True) end_reason = Column(Enum(TransactionEventTriggerReason), nullable=True) price = Column(Numeric(10,2)) user_id = Column(Uuid, ForeignKey("users.id"), nullable=True, index=True) chargepoint_id = Column(Uuid, ForeignKey("chargepoints.id"), index=True)