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.Index;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * 买家的应付发票
 * 
 * @author suntg
 * 
 */
@Table(name = "purc$apbill", indexes = {@Index(name = "unique_enuu_code", columnList = "pad_enuu,pab_code", unique = true)})
@Entity
public class PurchaseApBill implements Serializable {

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

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

	/**
	 * 单号
	 */
	@Column(name = "pab_code")
	private String code;

	/**
	 * 日期
	 */
	@Column(name = "pab_date")
	private Date date;

	/**
	 * 账期
	 */
	@Column(name = "pab_yearmoubth")
	private Long yearMouth;

	/**
	 * 币别
	 */
	@Column(name = "pab_currency")
	private String currency;

	/**
	 * 汇率
	 */
	@Column(name = "pab_rate")
	private Double rate;

	/**
	 * 采购单所属企业UU
	 */
	@Column(name = "pad_enuu")
	private Long enUU;

	/**
	 * 采购企业
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "pad_enuu", insertable = false, updatable = false)
	private EnterpriseInfo enterprise;

	/**
	 * 供应商所属企业UU
	 */
	@Column(name = "pad_venduu")
	private Long vendUU;

	/**
	 * 日期
	 */
	@Column(name = "pab_username")
	private String userName;

	/**
	 * 状态
	 */
	@Column(name = "pab_status")
	private String status;

	/**
	 * 付款方式
	 */
	@Column(name = "pab_payments")
	private String payments;

	/**
	 * 付款日期
	 */
	@Column(name = "pab_paydate")
	private Date paydate;

	/**
	 * 发票号
	 */
	@Column(name = "pab_refno")
	private String refNo;

	/**
	 * 录入人
	 */
	@Column(name = "pab_recorde")
	private String recorder;

	/**
	 * 录入日期
	 */
	@Column(name = "pab_indate")
	private Date indate;

	/**
	 * 应付金额
	 */
	@Column(name = "pab_apamount")
	private Double apAmount;

	/**
	 * 付款金额
	 */
	@Column(name = "pab_paymount")
	private Double payAmount;

	/**
	 * 价格条件
	 */
	@Column(name = "pab_pricetermdes")
	private String priceTermdes;

	/**
	 * 税金合计
	 */
	@Column(name = "pab_taxsum")
	private Double taxSum;

	/**
	 * 税金差异
	 */
	@Column(name = "pab_differ")
	private Double differ;

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

	/**
	 * 传输状态
	 */
	@Column(name = "pab_sendstatus")
	private Short sendStatus;

	/**
	 * 验收明细
	 */
	@OneToMany(mappedBy = "aPBill", cascade = { CascadeType.REFRESH, CascadeType.PERSIST, CascadeType.REMOVE,
			CascadeType.MERGE }, fetch = FetchType.EAGER)
	@OrderBy("number")
	private Set<PurchaseApBillItem> items;

	/**
	 * 已反过账(1 已反过账, 0|空 未反过账(默认未空))
	 */
	@Column(name = "pab_nonposting")
	private Short nonPosting;

	/**
	 * 对应erpid
	 * 
	 * @return
	 */
	@Column(name = "pab_erpid")
	private Long erpId;

	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 Date getDate() {
		return date;
	}

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

	public Long getYearMouth() {
		return yearMouth;
	}

	public void setYearMouth(Long yearMouth) {
		this.yearMouth = yearMouth;
	}

	public String getCurrency() {
		return currency;
	}

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

	public Double getRate() {
		return rate;
	}

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

	public Long getEnUU() {
		return enUU;
	}

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

	public EnterpriseInfo getEnterprise() {
		return enterprise;
	}

	public void setEnterprise(EnterpriseInfo enterprise) {
		this.enterprise = enterprise;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getStatus() {
		return status;
	}

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

	public String getPayments() {
		return payments;
	}

	public void setPayments(String payments) {
		this.payments = payments;
	}

	public Date getPaydate() {
		return paydate;
	}

	public void setPaydate(Date paydate) {
		this.paydate = paydate;
	}

	public String getRefNo() {
		return refNo;
	}

	public void setRefNo(String refNo) {
		this.refNo = refNo;
	}

	public String getRecorder() {
		return recorder;
	}

	public void setRecorder(String recorder) {
		this.recorder = recorder;
	}

	public Date getIndate() {
		return indate;
	}

	public void setIndate(Date indate) {
		this.indate = indate;
	}

	public Double getApAmount() {
		return apAmount;
	}

	public void setApAmount(Double apAmount) {
		this.apAmount = apAmount;
	}

	public Double getPayAmount() {
		return payAmount;
	}

	public void setPayAmount(Double payAmount) {
		this.payAmount = payAmount;
	}

	public String getPriceTermdes() {
		return priceTermdes;
	}

	public void setPriceTermdes(String priceTermdes) {
		this.priceTermdes = priceTermdes;
	}

	public Double getTaxSum() {
		return taxSum;
	}

	public void setTaxSum(Double taxSum) {
		this.taxSum = taxSum;
	}

	public Double getDiffer() {
		return differ;
	}

	public void setDiffer(Double differ) {
		this.differ = differ;
	}

	public String getRemark() {
		return remark;
	}

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

	public Short getSendStatus() {
		return sendStatus;
	}

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

	public Set<PurchaseApBillItem> getItems() {
		return items;
	}

	public void setItems(Set<PurchaseApBillItem> items) {
		this.items = items;
	}

	public Long getVendUU() {
		return vendUU;
	}

	public void setVendUU(Long vendUU) {
		this.vendUU = vendUU;
	}

	public Short getNonPosting() {
		return nonPosting;
	}

	public void setNonPosting(Short nonPosting) {
		this.nonPosting = nonPosting;
	}

	public Long getErpId() {
		return erpId;
	}

	public void setErpId(Long erpId) {
		this.erpId = erpId;
	}

}
