import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import ArticleEntity from "./article.entity";
import PriceEntity from "./price.entity";
import RateEntity from "./rate.entity";

@Entity({name: "article_price"})
export default class ArticlePriceEntity {

    @PrimaryGeneratedColumn()
    id?: number;

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

    @JoinColumn({name: "id_price"})
    @ManyToOne(type => PriceEntity)
    priceEntity?: PriceEntity;

    @Column({type: "decimal"})
    price?: number;

    @Column({type: "decimal"})
    taxable?: number;

    @Column({type: "decimal"})
    tax?: number;

    @JoinColumn({name: "id_rate"})
    @ManyToOne(type => RateEntity)
    rate?: RateEntity | null;

    @Column(
        { type: "datetime", name: "created_at" }
    )
    createdAt?: Date;

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

}