package com.dev.swms.server.model.receiving;

import java.util.Set;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import com.dev.swms.server.model.base.Item;
import com.dev.swms.server.model.base.LotInfo;
import com.dev.swms.server.model.base.PackageUnit;
import com.dev.energy.server.model.Entity;

public class ReceivingDocDetail extends Entity {
	/** 所属收货单 */
	private ReceivingDoc receivingDoc;
	/** 商品 */
	private Item item;
	/** 商品属性 */
	private LotInfo lotInfo;
	/** 期望包装数量 */
	private double expectedQuantity;
	/** 期望基本单位数量 */
	private double expectedQtyOfMasterUnit;
	/** 已收数量 */
	private double receivedQuantity;
	/** ASN数量 */
	private double asnQuantity;
	/** 盲收数量 */
	private double blindQuantity;
	/** 包装单位 */
	private PackageUnit packageUnit;
	/** 收货记录 */
	private Set<ReceivedRecord> receivedRecords;
	
	/**
	 * 行号
	 *
	 */
	private Integer lineNo;

	public boolean equals(final Object other) {
		if (!(other instanceof ReceivingDocDetail))
			return false;
		ReceivingDocDetail castOther = (ReceivingDocDetail) other;
		return new EqualsBuilder().append(receivingDoc, castOther.receivingDoc)
				.append(lineNo, castOther.lineNo).isEquals();
	}

	public int hashCode() {
		return new HashCodeBuilder().append(receivingDoc).append(lineNo)
				.toHashCode();
	}

	protected ReceivingDocDetail() {
	}

	public Integer getLineNo() {
		return lineNo;
	}

	public void setLineNo(Integer lineNo) {
		this.lineNo = lineNo;
	}

	public double getExpectedQuantity() {
		return expectedQuantity;
	}
	public void setExpectedQuantity(double expectedQuantity) {
		this.expectedQuantity = expectedQuantity;
	}
	public double getExpectedQtyOfMasterUnit() {
		return expectedQtyOfMasterUnit;
	}
	public void setExpectedQtyOfMasterUnit(double expectedQtyOfMasterUnit) {
		this.expectedQtyOfMasterUnit = expectedQtyOfMasterUnit;
	}
	public PackageUnit getPackageUnit() {
		return packageUnit;
	}
	public void setPackageUnit(PackageUnit packageUnit) {
		this.packageUnit = packageUnit;
	}
	public double getReceivedQuantity() {
		return receivedQuantity;
	}
	public void setReceivedQuantity(double receivedQuantity) {
		this.receivedQuantity = receivedQuantity;
	}
	public double getAsnQuantity() {
		return asnQuantity;
	}
	public void setAsnQuantity(double asnQuantity) {
		this.asnQuantity = asnQuantity;
	}
	public ReceivingDoc getReceivingDoc() {
		return receivingDoc;
	}
	public void setReceivingDoc(ReceivingDoc receivingDoc) {
		this.receivingDoc = receivingDoc;
	}
	public Set<ReceivedRecord> getReceivedRecords() {
		return receivedRecords;
	}
	public void setReceivedRecords(Set<ReceivedRecord> receivedRecords) {
		this.receivedRecords = receivedRecords;
	}
	public double getBlindQuantity() {
		return blindQuantity;
	}
	public void setBlindQuantity(double blindQuantity) {
		this.blindQuantity = blindQuantity;
	}

	/**
	 * 增加收货单明细的期待数量
	 * @param quantity 待增加的期待数量
	 */
	public void addExpectedQuantity(double quantity) {
		this.expectedQuantity += quantity;
		this.expectedQtyOfMasterUnit = this.expectedQuantity*this.packageUnit.getConvertFigure();
	}

	public void addReceivedQuantity(double quantity) {
		this.receivedQuantity += quantity;
		this.receivingDoc.addReceivedQuantity(quantity);
	}

	public Item getItem() {
		return item;
	}

	public void setItem(Item item) {
		this.item = item;
	}

	public LotInfo getLotInfo() {
		return lotInfo;
	}

	public void setLotInfo(LotInfo lotInfo) {
		this.lotInfo = lotInfo;
	}
}
