import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import ArticleEntity from "./article.entity";
import StoreEntity from "./store.entity";
import StorageEntity from "./storage.entity";
import DocumentEntity from "./document.entity";

@Entity({name: "movement"})
export default class MovementEntity {

    @PrimaryGeneratedColumn()
    id?: number;

    @Column({name: "movement_date", type: "date"})
    movementDate?: string;

    @Column()
    charge?: number;

    @Column()
    discharge?: number;

    @JoinColumn({name: "id_article"})
    @ManyToOne(type => ArticleEntity)
    article?: ArticleEntity;

    @JoinColumn({name: "id_store"})
    @ManyToOne(type => StoreEntity)
    store?: StoreEntity;

    @JoinColumn({name: "id_storage"})
    @ManyToOne(type => StorageEntity)
    storage?: StorageEntity;

    @JoinColumn({name: "id_document"})
    @ManyToOne(type => DocumentEntity)
    document?: DocumentEntity;
    
    @Column(
        { type: "datetime", name: "created_at" }
    )
    createdAt?: Date;

    @Column(
        { type: "datetime", name: "updated_at" }
    )
    updatedAt?: Date;

}