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

@Entity({name: "document_payment"})
export default class DocumentPaymentEntity {

    @PrimaryGeneratedColumn()
    id?: number;

    @Column()
    code?: string;

    @Column()
    title?: string;

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

    @Column({name: "payment_type"})
    paymentType?: string;

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

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

}