22 lines
734 B
Python
22 lines
734 B
Python
from sqlalchemy import Column, Integer, Float, String, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
from config.database import Base
|
|
|
|
|
|
class Opex(Base):
|
|
__tablename__ = "opex"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
scenario_id = Column(Integer, ForeignKey("scenario.id"), nullable=False)
|
|
amount = Column(Float, nullable=False)
|
|
description = Column(String, nullable=True)
|
|
currency_code = Column(String(3), nullable=False, default="USD")
|
|
|
|
scenario = relationship("Scenario", back_populates="opex_items")
|
|
|
|
def __repr__(self):
|
|
return (
|
|
f"<Opex id={self.id} scenario_id={self.scenario_id} "
|
|
f"amount={self.amount} currency={self.currency_code}>"
|
|
)
|