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

@Entity(
    { name: "document_supplier" }
)
export default class DocumentSupplierEntity {

    @PrimaryGeneratedColumn()
    id?: number;

    @Column({name: "business_name"})
    businessName?: string;

    @Column()
    firstname?: string;

    @Column()
    lastname?: string;

    @Column({name: "vat_number"})
    vatNumber?: string;

    @Column({name: "fiscal_code"})
    fiscalCode?: string;

    @Column()
    city?: string;

    @Column()
    address?: string;

    @Column()
    province?: string;

    @Column({name: "zip_code"})
    zipCode?: string;

    @Column({name: "sdi_code"})
    sdiCode?: string;
    
    @Column()
    pec?: string;

    @Column({name: "phone_number"})
    phoneNumber?: string;

    @Column()
    email?: string;

    @JoinColumn({name: "id_supplier"})
    @ManyToOne(type => SupplierEntity)
    supplier?: SupplierEntity;

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

}