package cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity;

import cokr.xit.ens.core.jpa.support.BooleanToYnConverter;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.BillSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PaidTypeCd;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.OrgMng;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.SuperBuilder;

import javax.persistence.*;
import java.io.Serializable;

@Entity
@Getter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
//@Inheritance(strategy = InheritanceType.JOINED)
//@DiscriminatorColumn(name = "dtype")
//@DiscriminatorValue("master")
@Table(name = "ens_bill", schema = "", catalog = "")
@Schema(name = "Bill")
public class Bill extends BillBaseEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "Bill_Generator")
    @TableGenerator(table = "ens_seq_generator", name = "Bill_Generator"
            , pkColumnName = "seq_name", pkColumnValue = "Bill_id"
            , initialValue = 0, allocationSize = 200)
    @Schema(required = true, title = "PK", example = " ")
    private Long billId;               

    @Enumerated(EnumType.STRING)
    @Schema(required = true, title = "청구서 타입", example = " ")
    @Column(name = "bill_se_cd", nullable = false)
    private BillSeCd billSeCd;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "org_cd", nullable = false)
    @Setter
    private OrgMng orgMng;

    @Convert(converter = BooleanToYnConverter.class)
    @Schema(required = false, title = "납부(결제)여부", example = " ")
    @Column(name = "paid_at", nullable = true, length = 1)
    @Setter
    private Boolean paidAt;
    @Schema(required = false, title = "지불 유형", example = " ")
    @Column(name = "paid_type", nullable = true, length = 15)
    @Enumerated(EnumType.STRING)
    @Setter
    private PaidTypeCd paidType;
    @Schema(required = false, title = "납부(결제) 날짜", example = " ")
    @Column(name = "paid_dt", nullable = true, length = 14)
    @Setter
    private String paidDt;
    @Schema(required = false, title = "납부(결제) 취소 날짜", example = " ")
    @Column(name = "paid_cancel_dt", nullable = true, length = 14)
    @Setter
    private String paidCancelDt;

    @Schema(required = false, title = "카카오 청구서", example = " ")
    @Column(name = "doc_bill_kko", nullable = true)
    @Lob
    private String docBillKko;

    @Schema(required = false, title = "네이버 청구서", example = " ")
    @Column(name = "doc_bill_nv", nullable = true)
    @Lob
    private String docBillNv;
}
