package cn.palmte.work.model.process;

import org.hibernate.annotations.GenericGenerator;

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.process.form.SaleContractProcessForm;
import lombok.Data;

/**
 * 销售合同
 *
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
 * @since 2.0 2022/12/21 11:40
 */
@Data
@Entity
@Table(name = "sale_contract")
public class SaleContract {

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

  // 客户名称
  private String clientName;

  // 收款条件
  private String paymentTerms;

  // 申请人电话
  private String applyPersonPhone;

  private Integer processId;

  public static SaleContract from(SaleContractProcessForm form) {
    SaleContract contract = new SaleContract();
    contract.setClientName(form.getClientName());
    contract.setPaymentTerms(form.getPaymentTerms());
    contract.setApplyPersonPhone(form.getApplyPersonPhone());
    return contract;
  }

}
