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

@Entity({name: "document_row"})
export default class DocumentRowEntity {

    @PrimaryGeneratedColumn()
    id?: number;

    @Column()
    code?: string;

    @Column()
    title?: string;

    @Column()
    barcode?: string;

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

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

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

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

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

    @Column({name: "amount_taxable", type: "decimal"})
    amountTaxable?: number;

    @Column({name: "amount_tax", type: "decimal"})
    amountTax?: number;

    @Column({name: "price_discount", type: "decimal"})
    priceDiscount?: number;

    @Column({name: "taxable_discount", type: "decimal"})
    taxableDiscount?: number;

    @Column({name: "tax_discount", type: "decimal"})
    taxDiscount?: number;

    @Column({name: "amount_discount", type: "decimal"})
    amountDiscount?: number;

    @Column({name: "amount_taxable_discount", type: "decimal"})
    amountTaxableDiscount?: number;

    @Column({name: "amount_tax_discount", type: "decimal"})
    amountTaxDiscount?: number;

    @Column({name: "rate", type: "decimal"})
    rate?: number;
    
    @Column()
    nature?: string;

    @Column()
    enforceability?: string;

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

    @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;

}