package com.uas.platform.b2b.model;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * 平台里面，供应商发起的主动报价单<br>
 * （以供应商的视角）
 *  存在根据截止日期判断是否过期，所以采用视图
 * 
 * @author yingp
 * 
 */
@Table(name = "v$sale$quotation")
@Entity
public class SaleQuotationAll implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

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

	/**
	 * 流水号
	 */
	@Column(name = "qu_code")
	private String code;

	/**
	 * 所属企业(卖家)UU
	 */
	@Column(name = "qu_enuu")
	private Long enUU;

	@Column(name = "qu_environment")
	private String environment;

	/**
	 * 所属用户(卖家)UU
	 */
	@Column(name = "qu_useruu")
	private Long userUU;

	/**
	 * 所属用户（卖家）=录入人
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "qu_useruu", insertable = false, updatable = false)
	private UserBaseInfo user;

	/**
	 * 客户UU
	 */
	@Column(name = "qu_custuu")
	private Long custUU;

	/**
	 * 客户企业
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "qu_custuu", insertable = false, updatable = false)
	private EnterpriseInfo cust;

	/**
	 * 客户联系人UU
	 */
	@Column(name = "qu_custuseruu")
	private Long custUserUU;

	/**
	 * 客户联系人
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "qu_custuseruu", insertable = false, updatable = false)
	private UserBaseInfo custUser;

	/**
	 * 录入日期（有效开始日期）
	 */
	@Column(name = "qu_date")
	private Date date;

	/**
	 * 有效截止日期
	 */
	@Column(name = "qu_enddate")
	private Date endDate;

	/**
	 * 币种
	 */
	@Column(name = "qu_currency")
	private String currency;

	/**
	 * 汇率
	 */
	@Column(name = "qu_rate")
	private Float rate;

	/**
	 * 税率
	 */
	@Column(name = "qu_taxrate")
	private Float taxrate;

	/**
	 * 备注
	 */
	@Column(name = "qu_remark")
	private String remark;

	/**
	 * （对买家）传输状态
	 */
	@Column(name = "qu_sendstatus")
	private Short sendStatus;

	/**
	 * 报价明细
	 */
	@OneToMany(mappedBy = "quotation", cascade = { CascadeType.REFRESH, CascadeType.PERSIST, CascadeType.REMOVE,
			CascadeType.MERGE }, fetch = FetchType.EAGER)
	@OrderBy("number")
	private Set<SaleQuotationItemAll> quotationItems;

	/**
	 * 单据状态（在录入100， 已提交101， 已作废314）
	 */
	@Column(name = "qu_status")
	private Short status;

	/**
	 * （对卖家）传输状态
	 */
	@Column(name = "qu_backstatus")
	private Short backStatus;

	/**
	 * 是否过期（1为是，0为否）
	 *
	 * @return
	 */
	@Column(name = "qu_overdue")
	private Short overdue;

	/**
	 * 是否同意<br>
	 * 1. 同意<br>
	 * 0. 不同意
	 */
	@Column(name = "qu_agreed")
	private Short agreed;

	public Long getId() {
		return id;
	}

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

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getEnvironment() {
		return environment;
	}

	public void setEnvironment(String environment) {
		this.environment = environment;
	}

	public Long getEnUU() {
		return enUU;
	}

	public void setEnUU(Long enUU) {
		this.enUU = enUU;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}

	public Float getRate() {
		return rate;
	}

	public void setRate(Float rate) {
		this.rate = rate;
	}

	public Float getTaxrate() {
		return taxrate;
	}

	public void setTaxrate(Float taxrate) {
		this.taxrate = taxrate;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Long getCustUU() {
		return custUU;
	}

	public void setCustUU(Long custUU) {
		this.custUU = custUU;
	}

	public Long getCustUserUU() {
		return custUserUU;
	}

	public void setCustUserUU(Long custUserUU) {
		this.custUserUU = custUserUU;
	}

	public Short getSendStatus() {
		return sendStatus;
	}

	public void setSendStatus(Short sendStatus) {
		this.sendStatus = sendStatus;
	}

	public Long getUserUU() {
		return userUU;
	}

	public void setUserUU(Long userUU) {
		this.userUU = userUU;
	}

	public Set<SaleQuotationItemAll> getQuotationItems() {
		return quotationItems;
	}

	public void setQuotationItems(Set<SaleQuotationItemAll> quotationItems) {
		this.quotationItems = quotationItems;
	}

	public UserBaseInfo getUser() {
		return user;
	}

	public void setUser(UserBaseInfo user) {
		this.user = user;
	}

	public EnterpriseInfo getCust() {
		return cust;
	}

	public void setCust(EnterpriseInfo cust) {
		this.cust = cust;
	}

	public UserBaseInfo getCustUser() {
		return custUser;
	}

	public void setCustUser(UserBaseInfo custUser) {
		this.custUser = custUser;
	}

	public Short getStatus() {
		return status;
	}

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

	public Short getBackStatus() {
		return backStatus;
	}

	public void setBackStatus(Short backStatus) {
		this.backStatus = backStatus;
	}

	public Short getOverdue() {
		return overdue;
	}

	public void setOverdue(Short overdue) {
		this.overdue = overdue;
	}

	public Short getAgreed() {
		return agreed;
	}

	public void setAgreed(Short agreed) {
		this.agreed = agreed;
	}

	@Override
	public String toString() {
		return "SaleQuotationAll{" +
				"id=" + id +
				", code='" + code + '\'' +
				", enUU=" + enUU +
				", environment='" + environment + '\'' +
				", userUU=" + userUU +
				", user=" + user +
				", custUU=" + custUU +
				", cust=" + cust +
				", custUserUU=" + custUserUU +
				", custUser=" + custUser +
				", date=" + date +
				", endDate=" + endDate +
				", currency='" + currency + '\'' +
				", rate=" + rate +
				", taxrate=" + taxrate +
				", remark='" + remark + '\'' +
				", sendStatus=" + sendStatus +
				", quotationItems=" + quotationItems +
				", status=" + status +
				", backStatus=" + backStatus +
				", overdue=" + overdue +
				'}';
	}
}
