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.PurchaseAccept;
import com.uas.platform.b2b.model.PurchaseAcceptItem;
import com.uas.platform.b2b.model.PurchaseBadIn;
import com.uas.platform.b2b.model.PurchaseBadInItem;
import com.uas.platform.b2b.model.PurchaseBadOut;
import com.uas.platform.b2b.model.PurchaseBadOutItem;
import com.uas.platform.b2b.model.PurchaseReturn;
import com.uas.platform.b2b.model.PurchaseReturnItem;

/**
 * 供应商方，ERP系统的客户采购验收单
 * @author suntg
 * @date 2015年4月20日14:02:13
 */
public class SaleProdInOutDown {
	
	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<SaleProdInOutDownDetail> 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 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 String getPi_sendcode() {
		return pi_sendcode;
	}
	public void setPi_sendcode(String pi_sendcode) {
		this.pi_sendcode = pi_sendcode;
	}
	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<SaleProdInOutDownDetail> getDetails() {
		return details;
	}
	public void setDetails(List<SaleProdInOutDownDetail> details) {
		this.details = details;
	}
	
	public SaleProdInOutDown(PurchaseAccept 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<SaleProdInOutDownDetail> downDetails = new ArrayList<SaleProdInOutDownDetail>();
			for(PurchaseAcceptItem acceptItem : accept.getAcceptItems()) {
				downDetails.add(new SaleProdInOutDownDetail(acceptItem));
			}
			this.details = downDetails;
		}
	}
	
	public SaleProdInOutDown(PurchaseReturn purchaseReturn) {
		this.pi_b2bid = purchaseReturn.getId();
		this.pi_currency = purchaseReturn.getCurrency();
		this.pi_date1 = purchaseReturn.getDate();
		this.pi_inoutman = purchaseReturn.getRecorder();
		this.pi_inoutno = purchaseReturn.getCode();
		this.pi_sendcode = purchaseReturn.getSendCode();
		this.pi_payment = purchaseReturn.getPayments();
		this.pi_rate = purchaseReturn.getRate();
		this.pi_remark = purchaseReturn.getRemark();
		this.pi_customeruu = purchaseReturn.getEnUU();
		if(! CollectionUtils.isEmpty(purchaseReturn.getReturnItems())) {
			List<SaleProdInOutDownDetail> downDetails = new ArrayList<SaleProdInOutDownDetail>();
			for(PurchaseReturnItem returnItem : purchaseReturn.getReturnItems()) {
				downDetails.add(new SaleProdInOutDownDetail(returnItem));
			}
			this.details = downDetails;
		}
	}

	public SaleProdInOutDown(PurchaseBadIn purchaseBadIn) {
		this.pi_b2bid = purchaseBadIn.getId();
		this.pi_currency = purchaseBadIn.getCurrency();
		this.pi_date1 = purchaseBadIn.getDate();
		this.pi_inoutman = purchaseBadIn.getRecorder();
		this.pi_inoutno = purchaseBadIn.getCode();
		this.pi_sendcode = purchaseBadIn.getSendCode();
		this.pi_payment = purchaseBadIn.getPayments();
		this.pi_rate = purchaseBadIn.getRate();
		this.pi_remark = purchaseBadIn.getRemark();
		this.pi_customeruu = purchaseBadIn.getEnUU();
		if(! CollectionUtils.isEmpty(purchaseBadIn.getBadInItems())) {
			List<SaleProdInOutDownDetail> downDetails = new ArrayList<SaleProdInOutDownDetail>();
			for(PurchaseBadInItem badInItem : purchaseBadIn.getBadInItems()) {
				downDetails.add(new SaleProdInOutDownDetail(badInItem));
			}
			this.details = downDetails;
		}
	}
	
	public SaleProdInOutDown(PurchaseBadOut purchaseBadOut) {
		this.pi_b2bid = purchaseBadOut.getId();
		this.pi_currency = purchaseBadOut.getCurrency();
		this.pi_date1 = purchaseBadOut.getDate();
		this.pi_inoutman = purchaseBadOut.getRecorder();
		this.pi_inoutno = purchaseBadOut.getCode();
		this.pi_sendcode = purchaseBadOut.getSendCode();
		this.pi_payment = purchaseBadOut.getPayments();
		this.pi_rate = purchaseBadOut.getRate();
		this.pi_remark = purchaseBadOut.getRemark();
		this.pi_customeruu = purchaseBadOut.getEnUU();
		if(! CollectionUtils.isEmpty(purchaseBadOut.getBadOutItems())) {
			List<SaleProdInOutDownDetail> downDetails = new ArrayList<SaleProdInOutDownDetail>();
			for(PurchaseBadOutItem badOutItem : purchaseBadOut.getBadOutItems()) {
				downDetails.add(new SaleProdInOutDownDetail(badOutItem));
			}
			this.details = downDetails;
		}
	}

}
