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

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.util.CollectionUtils;

import com.uas.platform.b2b.model.MakeAccept;
import com.uas.platform.b2b.model.MakeAcceptItem;
import com.uas.platform.b2b.model.MakeReturn;
import com.uas.platform.b2b.model.MakeReturnItem;

/**
 * 供应商方，ERP系统的客户委外验收单
 * @author aof
 * @date 2015年8月28日
 */
public class OutSourceProdInOutDown {
	private Long pi_b2bid;//b2b id
	private String pi_inoutno;//采购检验单号
	private Long pi_customeruu;//客户uu号
	private String pi_currency;//币别
	private String pi_sendcode;//送货单号
	private Float pi_rate;//汇率
	private String pi_payment;//付款方式
	private String pi_transport;//运输方式
	private String pi_inoutman;//过账人
	private Date pi_date1;//过账日期
	private String pi_remark;//备注
	private List<OutSourceProdInOutDownDetail> details;//明细
	public Long getPi_b2bid() {
		return pi_b2bid;
	}
	public void setPi_b2bid(Long pi_b2bid) {
		this.pi_b2bid = pi_b2bid;
	}
	public String getPi_inoutno() {
		return pi_inoutno;
	}
	public void setPi_inoutno(String pi_inoutno) {
		this.pi_inoutno = pi_inoutno;
	}
	public Long getPi_customeruu() {
		return pi_customeruu;
	}
	public void setPi_customeruu(Long pi_customeruu) {
		this.pi_customeruu = pi_customeruu;
	}
	public String getPi_currency() {
		return pi_currency;
	}
	public void setPi_currency(String pi_currency) {
		this.pi_currency = pi_currency;
	}
	public String getPi_sendcode() {
		return pi_sendcode;
	}
	public void setPi_sendcode(String pi_sendcode) {
		this.pi_sendcode = pi_sendcode;
	}
	public Float getPi_rate() {
		return pi_rate;
	}
	public void setPi_rate(Float pi_rate) {
		this.pi_rate = pi_rate;
	}
	public String getPi_payment() {
		return pi_payment;
	}
	public void setPi_payment(String pi_payment) {
		this.pi_payment = pi_payment;
	}
	public String getPi_transport() {
		return pi_transport;
	}
	public void setPi_transport(String pi_transport) {
		this.pi_transport = pi_transport;
	}
	public String getPi_inoutman() {
		return pi_inoutman;
	}
	public void setPi_inoutman(String pi_inoutman) {
		this.pi_inoutman = pi_inoutman;
	}
	public Date getPi_date1() {
		return pi_date1;
	}
	public void setPi_date1(Date pi_date1) {
		this.pi_date1 = pi_date1;
	}
	public String getPi_remark() {
		return pi_remark;
	}
	public void setPi_remark(String pi_remark) {
		this.pi_remark = pi_remark;
	}
	public List<OutSourceProdInOutDownDetail> getDetails() {
		return details;
	}
	public void setDetails(List<OutSourceProdInOutDownDetail> details) {
		this.details = details;
	}
	public OutSourceProdInOutDown(MakeAccept accept) {
		this.pi_b2bid = accept.getId();
		this.pi_currency = accept.getCurrency();
		this.pi_date1 = accept.getDate();
		this.pi_inoutman = accept.getRecorder();
		this.pi_inoutno = accept.getCode();
		this.pi_sendcode = accept.getSendCode();
		this.pi_payment = accept.getPayments();
		this.pi_rate = accept.getRate();
		this.pi_remark = accept.getRemark();
		this.pi_customeruu = accept.getEnUU();
		if(! CollectionUtils.isEmpty(accept.getAcceptItems())) {
			List<OutSourceProdInOutDownDetail> downDetails = new ArrayList<OutSourceProdInOutDownDetail>();
			for(MakeAcceptItem acceptItem : accept.getAcceptItems()) {
				downDetails.add(new OutSourceProdInOutDownDetail(acceptItem));
			}
			this.details = downDetails;
		}
	}
	
	public OutSourceProdInOutDown(MakeReturn makeReturn) {
		this.pi_b2bid = makeReturn.getId();
		this.pi_currency = makeReturn.getCurrency();
		this.pi_date1 = makeReturn.getDate();
		this.pi_inoutman = makeReturn.getRecorder();
		this.pi_inoutno = makeReturn.getCode();
		this.pi_sendcode = makeReturn.getSendCode();
		this.pi_payment = makeReturn.getPayments();
		this.pi_rate = makeReturn.getRate();
		this.pi_remark = makeReturn.getRemark();
		this.pi_customeruu = makeReturn.getEnUU();
		if(! CollectionUtils.isEmpty(makeReturn.getReturnItems())) {
			List<OutSourceProdInOutDownDetail> downDetails = new ArrayList<OutSourceProdInOutDownDetail>();
			for(MakeReturnItem returnItem : makeReturn.getReturnItems()) {
				downDetails.add(new OutSourceProdInOutDownDetail(returnItem));
			}
			this.details = downDetails;
		}
	}

}
