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

@Entity(
    { name: "document_customer" }
)
export default class DocumentCustomerEntity {

    @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_customer"})
    @ManyToOne(type => CustomerEntity)
    customer?: CustomerEntity;

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

}