from django.db import models
from django.conf import settings

# Create your models here.
class Stock(models.Model):
    def __str__(self):
        '''
            Returns stock name when querying in shell
        '''
        return self.stock_name

    stockId = models.AutoField(primary_key=True)
    stock_name = models.CharField(max_length=200)
    price = models.DecimalField(max_digits=5, decimal_places=2,)


class Userstock(models.Model):
    def __str__(self):
        return ("{}".format(self.stock_id))

    user_stockId = models.AutoField(primary_key=True)
    user_id = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE)
    stock_id = models.ForeignKey('Stock',null=False,db_column='stockId', on_delete=models.CASCADE)
    stock_price = models.DecimalField(max_digits=19, decimal_places=2)
    amount_invested = models.DecimalField(max_digits=19, decimal_places=2)
    number_of_stock_bought = models.IntegerField()
    total_amount_invested = models.DecimalField(max_digits=19, decimal_places=2)
    total_stock = models.IntegerField()
    pur_date = models.DateTimeField('date purchased')

