package com.uas.platform.b2b.erp.model;

import com.uas.platform.b2b.model.PurchaseNotice;
import com.uas.platform.b2b.model.PurchaseOrder;
import com.uas.platform.b2b.model.PurchaseOrderItem;
import com.uas.platform.b2b.model.SaleSendItem;
import com.uas.platform.b2b.support.SystemSession;

/**
 * 收料通知单明细
 * 
 * @author yingp
 *
 */
public class AcceptNotifyDetail {

	private String and_ordercode;
	private Short and_orderdetno;
	private Long and_pnid;
	private Double and_inqty;
	private Double and_price;
	private String and_remark;
	private Short and_detno;

	public String getAnd_ordercode() {
		return and_ordercode;
	}

	public void setAnd_ordercode(String and_ordercode) {
		this.and_ordercode = and_ordercode;
	}

	public Short getAnd_orderdetno() {
		return and_orderdetno;
	}

	public void setAnd_orderdetno(Short and_orderdetno) {
		this.and_orderdetno = and_orderdetno;
	}

	public Double getAnd_inqty() {
		return and_inqty;
	}

	public void setAnd_inqty(Double and_inqty) {
		this.and_inqty = and_inqty;
	}

	public String getAnd_remark() {
		return and_remark;
	}

	public void setAnd_remark(String and_remark) {
		this.and_remark = and_remark;
	}

	public Short getAnd_detno() {
		return and_detno;
	}

	public void setAnd_detno(Short and_detno) {
		this.and_detno = and_detno;
	}

	public Double getAnd_price() {
		return and_price;
	}

	public void setAnd_price(Double and_price) {
		this.and_price = and_price;
	}

	public Long getAnd_pnid() {
		return and_pnid;
	}

	public void setAnd_pnid(Long and_pnid) {
		this.and_pnid = and_pnid;
	}

	public AcceptNotifyDetail() {
	}

	/**
	 * 卖家做的发货单，转到买家的收料通知
	 */
	public AcceptNotifyDetail(SaleSendItem item) {
		this.and_detno = item.getNumber();
		this.and_inqty = item.getQty();
		this.and_pnid = item.getNotice().getSourceId();
		this.and_ordercode = item.getNotice().getOrderItem().getOrder().getCode();
		this.and_orderdetno = item.getNotice().getOrderItem().getNumber();
		this.and_price = item.getPrice();
		this.and_remark = item.getRemark();
	}

	/**
	 * 买家主动做的收料通知明细，转到平台的发货单明细
	 * 
	 * @return
	 */
	public SaleSendItem convert() {
		SaleSendItem item = new SaleSendItem();
		item.setNumber(this.and_detno);
		item.setPrice(this.and_price);
		item.setQty(this.and_inqty);
		item.setRemark(this.and_remark);
		PurchaseOrder order = new PurchaseOrder();
		order.setCode(this.and_ordercode);
		PurchaseOrderItem orderItem = new PurchaseOrderItem();
		orderItem.setNumber(this.and_detno);
		orderItem.setOrder(order);
		PurchaseNotice notice = new PurchaseNotice();
		notice.setOrderItem(orderItem);
		notice.setSourceId(this.and_pnid);
		notice.setEnUU(SystemSession.getUser().getEnterprise().getUu());
		item.setNotice(notice);
		return item;
	}

}
