import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import UnitMeasureEntity from "./unit_measure.entity";
import RateEntity from "./rate.entity";

@Entity({name: "article"})
export default class ArticleEntity {

    constructor(id?: number){
        this.id = id;
    }

    @PrimaryGeneratedColumn()
    id?: number;

    @Column()
    code?: string;

    @Column()
    title?: string;

    @Column()
    subtitle?: string;

    @Column({name: "short_description"})
    shortDescription?: string;

    @Column({name: "long_description"})
    longDescription?: string;

    @Column()
    attribute?: string;

    @Column()
    sku?: string;

    @Column({name: "available_on_pos"})
    availableOnPos?: number;

    @Column({name: "last_value_cost"})
    lastValueCost?: number;

    @Column({name: "last_value_sale"})
    lastValueSale?: number;


    @Column({name: "last_value_cost_taxable"})
    lastValueCostTaxable?: number;

    @Column({name: "last_value_sale_taxable"})
    lastValueSaleTaxable?: number;

    @Column()
    discount?: number;

    @JoinColumn({name: "id_unit_measure"})
    @ManyToOne(type => UnitMeasureEntity)
    unitMeasure?: UnitMeasureEntity;

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

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

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

}