import {
    BaseEntity,
    Column,
    Entity,
    Generated,
    JoinColumn,
    ManyToOne,
    PrimaryGeneratedColumn,
  } from "typeorm";
import { User } from "../user/user";

  @Entity({ name: "Transaction" })
  export class Transaction extends BaseEntity {
    @PrimaryGeneratedColumn({ name: "id" })
    @Generated("uuid")
    id: string;

    @ManyToOne(type => User, user => user.transactions) 
    @JoinColumn({ name: "userId" }) 
    userId: User;

    @Column({ name: "depositAmount", type: "float", default: 0 }) 
    depositAmount: number;

    @Column({ name: "withdrawAmount", type: "float" , default: 0 }) 
    withdrawAmount: number;

    @Column({ name: "totalInvestedAmount", type: "float", default: 0 }) 
    totalInvestedAmount: number;

    @Column({ name: "iswithdrawAmount", default: false }) 
    iswithdrawAmount: boolean;

    @Column({ name: "isdepositAmount", default: false }) 
    isdepositAmount: boolean;
    
    @Column({ name: "created_at",
      type: "varchar",
      length: 255,
      default: null,
      nullable: true, })
    created_at: string;
    
    @Column({ name: "updated_at",
      type: "varchar",
      length: 255,
      default: null,
      nullable: true, })
    updated_at: string;
  
  }
  