from sqlalchemy import Column, Integer, String, Float, Date
from sqlalchemy.ext.declarative import declarative_base


Base = declarative_base()

"""
Transaction Record Table. Record every stock purchase transaction.
"""

class Record(Base):

    __tablename__ = 'records'

    id = Column(Integer, primary_key=True)
    purchase_date = Column(Date)
    price = Column(Float)
    shares = Column(Integer)
    symbol = Column(String(15))
    company_name = Column(String)

    def __repr__(self):
        return '<Record> (date=%s, price=%s, shares=%s, symbol=%s, company_name=%s)'\
            % (self.purchase_date, self.price, self.shares, self.symbol, self.company_name)

    def get_total_price(self):
        return self.shares * self.price
