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

@Entity({name: "supplier"})
export default class SupplierEntity {

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

    @PrimaryGeneratedColumn()
    id?: number;

    @Column()
    code?: string;

    @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_price_default"})
    @ManyToOne(type => PriceEntity)
    price?: PriceEntity;

    @JoinColumn({name: "id_payment_default"})
    @ManyToOne(type => PaymentEntity)
    payment?: PaymentEntity;

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

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

}