package cn.palmte.work.model.process;

import org.hibernate.annotations.GenericGenerator;

import java.io.Serializable;

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

import cn.palmte.work.model.enums.ProcurementMode;
import cn.palmte.work.model.process.form.ProcessCreationForm;
import lombok.Data;

/**
 * 采购合同
 *
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
 * @since 2.0 2022/12/21 11:47
 */
@Data
@Entity
@Table(name = "procurement_contract")
public class ProcurementContract implements Serializable {

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

  private ProcurementMode procurementMode;

  private String supplierName;

  // 收款条件
  private String paymentTerms;

  private Integer processId;

  public static ProcurementContract from(ProcessCreationForm form) {
    ProcurementContract contract = new ProcurementContract();
    contract.setProcurementMode(form.getProcurementMode());
    contract.setPaymentTerms(form.getPaymentTerms());
    contract.setSupplierName(form.getSupplierName());
    return contract;
  }

}
