package com.ecep.contract.model;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Objects;

import com.ecep.contract.util.HibernateProxyUtils;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;

/**
 * 合同付款计划, CM_Contract_Pay
 */
@Getter
@Setter
@Entity
@Table(name = "CONTRACT_PAY_PLAN", schema = "supplier_ms", indexes = {
})
public class ContractPayPlan implements IdentityEntity, ContractBasedEntity, Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", nullable = false)
    private Integer id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CONTRACT_ID")
    private Contract contract;

    /**
     * 相关数据Id
     */
    @Column(name = "REF_ID")
    private Integer refId;

    @Column(name = "PAY_DATE")
    private LocalDate payDate;

    /**
     * 付款比例
     */
    @Column(name = "PAY_RATIO")
    private float payRatio;
    /**
     * 付款金额
     */
    @Column(name = "PAY_CURRENCY")
    private double payCurrency;
    /**
     * 付款条件
     */
    @Column(name = "PAY_TERM")
    private String payTerm;

    /**
     * 更新(同步)日期，从U8系统中同步更新数据的日期
     */
    @Column(name = "UPDATE_TIME")
    private LocalDateTime updateDate;

    @Override
    public final boolean equals(Object object) {
        if (this == object)
            return true;
        if (object == null)
            return false;
        if (HibernateProxyUtils.isNotEffectiveClassEquals(object, this)) {
            return false;
        }
        ContractPayPlan that = (ContractPayPlan) object;
        return getId() != null && Objects.equals(getId(), that.getId());
    }

    @Override
    public final int hashCode() {
        return HibernateProxyUtils.hashCode(this);
    }
}