import {Entity, PrimaryGeneratedColumn, Column, OneToMany, OneToOne, ManyToOne, JoinColumn, JoinTable} from "typeorm";
import { Client } from "./Client";
import { ClassDetail } from "./ClassDetail";
import { TeachingMode } from "./TeachingMode";
import { PaymentType } from "./PaymentType";
import { User } from "./User";

@Entity()
export class Classes {

    @PrimaryGeneratedColumn()
    id!: number;

    @Column({ default: null, nullable: true })
    number!: string;

    @Column({ type: 'timestamp', default: null, nullable: true })
    timestamp!: Date;

    @Column({ default: null, nullable: true })
    invoiceNumber!: string;

    @Column()
    address1!: string;

    @Column({ default: null, nullable: true })
    address2!: string;

    @Column()
    city!: string;

    @Column()
    zip!: string;

    @Column()
    state!: string;

    @Column({ type: 'decimal', precision: 10, scale: 2, default: null, nullable: true })
    milesTravel!: number;

    @Column({ type: 'decimal', precision: 10, scale: 2, default: null, nullable: true })
    timeTravel!: number;

    @Column({ type: 'decimal', precision: 10, scale: 2, default: 0, nullable: true })
    mileAmount!: number;

    @Column({ type: 'timestamp', default: () => "CURRENT_TIMESTAMP" })
    createDate!: Date;

    @Column({ type: 'timestamp', default: () => "CURRENT_TIMESTAMP" })
    modifyDate!: Date;

    @Column({ type: 'timestamp', default: null, nullable: true })
    startDate!: Date;

    @Column({ type: 'timestamp', default: null, nullable: true })
    endDate!: Date;

    @Column("text")
    note!: string;

    @Column({ default: null, nullable: true })
    phoneNumber!: string;

    @Column({ default: null, nullable: true })
    emergencyContact!: string;

    @Column({ default: null, nullable: true })
    emergencyPhone!: string;

    @Column({ default: null, nullable: true })
    paiymentNumber!: string;

    @Column({ type: 'timestamp', default: null, nullable: true })
    paiymentDate!: Date;

    @Column({ type: 'text', default: null, nullable: true })
    paiymentNote!: string;

    @Column({ type: 'decimal', precision: 10, scale: 2, default: 0, nullable: true })
    amount!: number;

    @Column({ default: null, nullable: true })
    cc_checkNumber!: string;

    @Column({ type: 'timestamp', default: null, nullable: true })
    ccExpires!: Date;

    @Column({ type: 'decimal', precision: 10, scale: 2, default: 0, nullable: true })
    discount!: number;

    @Column({ default: null, nullable: true })
    meetingUUID!: string;

    @Column({ default: false })
    canceled!: boolean;

    @ManyToOne(type => TeachingMode, TeachingMode => TeachingMode.Classes)
    TeachingMode!: TeachingMode;

    @ManyToOne(type => Client, class_customer => class_customer.Students)
    client!: Client;
    
    @ManyToOne(type => PaymentType)
    PaymentType!: PaymentType;

    @OneToMany(type => ClassDetail, ClassesDetail => ClassesDetail.Class)
    ClassesDetails!: ClassDetail[];

    @ManyToOne(type => User, User => User.Classes)
    User!: User;

}