simple-ocpp-cs/app/models/transaction.py

20 lines
822 B
Python
Raw Permalink Normal View History

2024-04-19 00:08:29 +02:00
from sqlalchemy import String, Uuid, Column, DateTime, Enum, Numeric, ForeignKey
2024-04-13 22:43:03 +02:00
from app.schemas.transaction import TransactionEventTriggerReason, TransactionStatus
from app.database import Base
class Transaction(Base):
__tablename__ = "transactions"
2024-04-19 00:08:29 +02:00
id = Column(String, primary_key=True)
2024-04-13 22:43:03 +02:00
status = Column(Enum(TransactionStatus), index=True)
started_at = Column(DateTime, index=True)
ended_at = Column(DateTime, nullable=True, index=True)
2024-04-19 00:08:29 +02:00
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))
2024-04-13 22:43:03 +02:00
2024-04-19 00:08:29 +02:00
user_id = Column(Uuid, ForeignKey("users.id"), nullable=True, index=True)
chargepoint_id = Column(Uuid, ForeignKey("chargepoints.id"), index=True)