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

@Entity({name: "document"})
export default class DocumentEntity {

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

    @PrimaryGeneratedColumn()
    id?: number;

    @Column({name: "document_area"})
    documentArea?: string;

    @Column({name: "document_date", type: "date"})
    documentDate?: string;

    @Column({name: "document_time", type: "time"})
    documentTime?: string;

    @Column({name: "document_progressive"})
    documentProgressive?: number;

    @Column({name: "document_number"})
    documentNumber?: string;

    @Column({name: "receipt_number"})
    receiptNumber?: string;

    @Column({name: "receipt_close"})
    receiptClose?: string;

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

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

    @Column({name: "amount_tax", type: "decimal"})
    amountTax?: 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()
    note?: string;

    @Column()
    cancelled?: number;

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

    @JoinColumn({name: "id_ref_document"})
    @ManyToOne(type => DocumentEntity)
    refDocument?: DocumentEntity;

    @Column({name: "invoice_xml"})
    invoiceXml?: string;

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

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

}