package com.uas.finance.model;


import javax.persistence.*;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * 应收账款转让表
 * created by shicr on 2018/1/25
 **/
@Entity
@Table(name = "accountapply")
public class AccountApply implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /**
     * 买方额度表id
     */
    @Column(name = "cq_id")
    private Long cqId;

    /**
     * 保理转让款
     */
    @Column(name = "aa_transferamount")
    private Double aa_transferamount;

    /**
     * 保理首付款
     */
    @Column(name = "aa_dueamount")
    private Double aa_dueamount;

    /**
     * 应收账款到期日
     */
    @Column(name = "aa_maturitydate")
    private Date aa_maturitydate;

    /**
     * 合同总金额
     */
    @Column(name = "aa_saamount")
    private Double aa_saamount;

    /**
     * 开票总金额
     */
    @Column(name = "aa_billamount")
    private Double aa_billamount;

    /**
     * 申请日期
     */
    @Column(name = "indate")
    private Date indate;

    /**
     * 审核状态
     * 201:已保存
     * 202:已提交
     * 204:批复成功
     * 205:批复失败
     */
    @Column(name = "status")
    private Integer status;

    /**
     * ERP下载状态
     */
    @Column(name = "erpstatus")
    private Integer erpstatus;

    /**
     * 还款状态
     */
    @Column(name = "aa_iscloseoff")
    private String aa_iscloseoff;

    /**
     * 保理uu
     */
    @Column(name = "fauu")
    private Long fauu;

    /**
     * ERP系统中的主键id
     */
    @Column(name = "erpId")
    private Long erpId;

    @OneToMany(mappedBy = "accountApply", cascade = CascadeType.REFRESH)
    private List<FsSale> fsSaleList;

    @OneToMany(mappedBy = "accountApply", cascade = CascadeType.REFRESH)
    private List<Receipt> receipts;

    @OneToMany(mappedBy = "accountApply",cascade = CascadeType.REFRESH)
    private List<AccountApplyAttach> attaches;

    public Double getAa_billamount() {
        return aa_billamount;
    }

    public void setAa_billamount(Double aa_billamount) {
        this.aa_billamount = aa_billamount;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getErpstatus() {
        return erpstatus;
    }

    public void setErpstatus(Integer erpstatus) {
        this.erpstatus = erpstatus;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Double getAa_transferamount() {
        return aa_transferamount;
    }

    public void setAa_transferamount(Double aa_transferamount) {
        this.aa_transferamount = aa_transferamount;
    }

    public Double getAa_dueamount() {
        return aa_dueamount;
    }

    public void setAa_dueamount(Double aa_dueamount) {
        this.aa_dueamount = aa_dueamount;
    }

    public String getAa_maturitydate() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date = this.aa_maturitydate;
        return date != null ? sdf.format(date) : null;
    }

    public void setAa_maturitydate(Date aa_maturitydate) {
        this.aa_maturitydate = aa_maturitydate;
    }

    public Double getAa_saamount() {
        return aa_saamount;
    }

    public void setAa_saamount(Double aa_saamount) {
        this.aa_saamount = aa_saamount;
    }

    public String getIndate() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date = this.indate;
        return date != null ? sdf.format(date) :null;
    }

    public void setIndate(Date indate) {
        this.indate = indate;
    }

    public String getAa_iscloseoff() {
        return aa_iscloseoff;
    }

    public void setAa_iscloseoff(String aa_iscloseoff) {
        this.aa_iscloseoff = aa_iscloseoff;
    }

    public List<FsSale> getFsSaleList() {
        return fsSaleList;
    }

    public void setFsSaleList(List<FsSale> fsSaleList) {
        this.fsSaleList = fsSaleList;
    }

    public List<Receipt> getReceipts() {
        return receipts;
    }

    public void setReceipts(List<Receipt> receipts) {
        this.receipts = receipts;
    }

    public List<AccountApplyAttach> getAttaches() {
        return attaches;
    }

    public void setAttaches(List<AccountApplyAttach> attaches) {
        this.attaches = attaches;
    }

    public Long getCqId() {
        return cqId;
    }

    public void setCqId(Long cqId) {
        this.cqId = cqId;
    }

    public Long getFauu() {
        return fauu;
    }

    public void setFauu(Long fauu) {
        this.fauu = fauu;
    }

    public Long getErpId() {
        return erpId;
    }

    public void setErpId(Long erpId) {
        this.erpId = erpId;
    }
}
