package cn.palmte.work.model.process;

import org.hibernate.Hibernate;
import org.hibernate.annotations.GenericGenerator;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import lombok.Data;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;

/**
 * 采购合同流程预算采购明细的详情
 * <p>
 * 一个 BudgetPurchaseAmount 对应 多个 BudgetPurchaseDetail
 *
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
 * @since 2.0 2022/12/28 11:41
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "procurement_contract_budget_purchase_detail")
public class BudgetPurchaseDetail implements Serializable {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @GenericGenerator(name = "persistenceGenerator", strategy = "increment")
  private Integer id;

  // 供应商名称
  private String supplierName;

  // 设备厂商名称
  private String manufacturerName;

  // 对应采购清单
  private String purchaseList;

  // 规格型号
  private String spec;

  // 对应采购数目
  private BigDecimal procurementAmount;

  // 采购单价
  private BigDecimal procurementPrice;

  // 含税总金额（元）
  private BigDecimal totalTaxInclude;

  private Integer processId;

  // 对应的 procurement_contract 的ID
  private Integer contractId;

  private Integer amountId;

  // 项目的成本明细ID
  private Integer budgetCostId;

  @Override
  public boolean equals(Object o) {
    if (this == o)
      return true;
    if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o))
      return false;
    BudgetPurchaseDetail that = (BudgetPurchaseDetail) o;
    return id != null && Objects.equals(id, that.id);
  }

  @Override
  public int hashCode() {
    return getClass().hashCode();
  }

}
