package com.uas.platform.b2b.model;

import com.uas.platform.b2b.erp.model.PurchaseAPBill;
import com.uas.platform.b2b.support.SystemSession;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 货款调账
 * 
 * @author hejq
 * @time 创建时间：2017年5月18日
 */
@Table(name = "purc$apbilladjustment", indexes = {
        @Index(name = "adjust_aa_custuu_index", columnList = "aa_custuu"),
        @Index(name = "adjust_aa_enuu_index", columnList = "aa_enuu")
})
@Entity
public class ApbillAdjustment implements Serializable {

	/**
	 * 序列号
	 */
	private static final long serialVersionUID = 1L;

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

	/**
	 * 单据编号
	 */
	@Column(name = "aa_inoutno")
	private String inoutno;

	/**
	 * 时间
	 */
	@Column(name = "aa_date")
	private Date date;

	/**
	 * 单据时间
	 */
	@Column(name = "aa_orderdate")
	private Date orderdate;

	/**
	 * 税率
	 */
	@Column(name = "aa_rate")
	private Double rate;

	/**
	 * 应收供应商编号
	 */
	@Column(name = "aa_receivecode")
	private String receivecode;

	/**
	 * 应收供应商名称
	 */
	@Column(name = "aa_receivename")
	private String receivename;

	/**
	 * 原单据序号
	 */
	@Column(name = "aa_orderdetno")
	private Short orderdetno;

	/**
	 * 订单编号
	 */
	@Column(name = "aa_ordercode")
	private String ordercode;

	/**
	 * 单据序号
	 */
	@Column(name = "aa_detno")
	private Short detno;
	
	/**
	 * 物料id
	 */
	@Column(name = "aa_prid")
	private Long prid;

	/**
	 * 物料编号
	 */
	@Column(name = "aa_prodcode")
	private String prodcode;

	/**
	 * 物料规格
	 */
	@Column(name = "aa_prodspec")
	private String prodspec;

	/**
	 * 物料名称
	 */
	@Column(name = "aa_prodtitle")
	private String prodtitle;

	/**
	 * 总数量
	 */
	@Column(name = "aa_qty")
	private Double qty;
	
	/**
	 * 订单单价
	 */
	@Column(name = "aa_orderprice")
	private Double orderprice;

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

	/**
	 * 费率
	 */
	@Column(name = "aa_taxrate")
	private Double taxrate;

	/**
	 * 仓库
	 */
	@Column(name = "aa_whname")
	private String whname;

	/**
	 * 对账数量
	 */
	@Column(name = "aa_ycheckqty")
	private Double ycheckqty;

	/**
	 * 本次对账数量
	 */
	@Column(name = "aa_thischeckqty")
	private Double thischeckqty;

	/**
	 * 客户uu号
	 */
	@Column(name = "aa_custuu")
	private Long custuu;

	/**
	 * 应收供应商
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "aa_custuu", insertable = false, updatable = false)
	private EnterpriseInfo enterprise;

	/**
	 * 客户名称
	 */
	@Column(name = "aa_custname")
	private String custname;

	/**
	 * 企业uu
	 */
	@Column(name = "aa_enuu")
	private Long enuu;

	/**
	 * 来源id
	 */
	@Column(name = "aa_sourceid")
	private Long sourceid;

	/**
	 * 发货单号
	 */
	@Column(name = "aa_sendcode")
	private String sendcode;

	/**
	 * 工厂
	 */
	@Column(name = "aa_factory")
	private String factory;

	/**
	 * 传到erp状态
	 */
	@Column(name = "aa_sendstatus")
	private Integer sendstatus;

	/**
	 * 反过账状态
	 */
	@Column(name = "aa_nonposting")
	private Short nonposting;

	public Long getId() {
		return id;
	}

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

	public String getInoutno() {
		return inoutno;
	}

	public void setInoutno(String inoutno) {
		this.inoutno = inoutno;
	}

	public Date getDate() {
		return date;
	}

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

	public Double getRate() {
		return rate;
	}

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

	public String getReceivecode() {
		return receivecode;
	}

	public void setReceivecode(String receivecode) {
		this.receivecode = receivecode;
	}

	public String getReceivename() {
		return receivename;
	}

	public void setReceivename(String receivename) {
		this.receivename = receivename;
	}

	public Short getOrderdetno() {
		return orderdetno;
	}

	public void setOrderdetno(Short orderdetno) {
		this.orderdetno = orderdetno;
	}

	public Short getDetno() {
		return detno;
	}

	public void setDetno(Short detno) {
		this.detno = detno;
	}

	public Long getPrid() {
		return prid;
	}

	public void setPrid(Long prid) {
		this.prid = prid;
	}

	public String getOrdercode() {
		return ordercode;
	}

	public void setOrdercode(String ordercode) {
		this.ordercode = ordercode;
	}

	public String getProdcode() {
		return prodcode;
	}

	public void setProdcode(String prodcode) {
		this.prodcode = prodcode;
	}

	public String getProdspec() {
		return prodspec;
	}

	public void setProdspec(String prodspec) {
		this.prodspec = prodspec;
	}

	public String getProdtitle() {
		return prodtitle;
	}

	public void setProdtitle(String prodtitle) {
		this.prodtitle = prodtitle;
	}

	public Double getOrderprice() {
		return orderprice;
	}

	public void setOrderprice(Double orderprice) {
		this.orderprice = orderprice;
	}

	public String getCurrency() {
		return currency;
	}

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

	public Double getTaxrate() {
		return taxrate;
	}

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

	public String getWhname() {
		return whname;
	}

	public void setWhname(String whname) {
		this.whname = whname;
	}

	public Double getQty() {
		return qty;
	}

	public void setQty(Double qty) {
		this.qty = qty;
	}

	public Double getYcheckqty() {
		return ycheckqty;
	}

	public void setYcheckqty(Double ycheckqty) {
		this.ycheckqty = ycheckqty;
	}

	public Double getThischeckqty() {
		return thischeckqty;
	}

	public void setThischeckqty(Double thischeckqty) {
		this.thischeckqty = thischeckqty;
	}

	public Long getCustuu() {
		return custuu;
	}

	public void setCustuu(Long custuu) {
		this.custuu = custuu;
	}

	public String getCustname() {
		return custname;
	}

	public void setCustname(String custname) {
		this.custname = custname;
	}

	public Long getEnuu() {
		return enuu;
	}

	public void setEnuu(Long enuu) {
		this.enuu = enuu;
	}

	public Long getSourceid() {
		return sourceid;
	}

	public void setSourceid(Long sourceid) {
		this.sourceid = sourceid;
	}

	public String getSendcode() {
		return sendcode;
	}

	public void setSendcode(String sendcode) {
		this.sendcode = sendcode;
	}

	public String getFactory() {
		return factory;
	}

	public void setFactory(String factory) {
		this.factory = factory;
	}

	public EnterpriseInfo getEnterprise() {
		return enterprise;
	}

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

	public Date getOrderdate() {
		return orderdate;
	}

	public void setOrderdate(Date orderdate) {
		this.orderdate = orderdate;
	}

	public Integer getSendstatus() {
		return sendstatus;
	}

	public void setSendstatus(Integer sendstatus) {
		this.sendstatus = sendstatus;
	}

	public Short getNonposting() {
		return nonposting;
	}

	public void setNonposting(Short nonposting) {
		this.nonposting = nonposting;
	}

	public ApbillAdjustment(PurchaseAPBill apBill) {
		Enterprise enterprise = SystemSession.getUser().getEnterprise();
		this.setCurrency(apBill.getAb_currency());
		this.setDate(new Date());
		this.setOrderdate(apBill.getAb_date());
		this.setSourceid(apBill.getAb_id());
		this.setEnuu(apBill.getAb_vendoruu());
		this.setCustuu(enterprise.getUu());
		this.setCustname(enterprise.getEnName());
		this.setInoutno(apBill.getAb_code());
		this.setRate(apBill.getAb_rate());
	}

	public ApbillAdjustment() {

	}
}
