package devopsdistilled.operp.server.data.entity.business;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;

import devopsdistilled.operp.server.data.entity.Entiti;
import devopsdistilled.operp.server.data.entity.items.Item;

@MappedSuperclass
public abstract class BusinessDescRow<D extends BusinessDesc<?, ?>> extends
		Entiti<Long> {

	private static final long serialVersionUID = 9140270277994676490L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	protected Long businessDescRowId;

	@ManyToOne
	@JoinColumn(name = "businessDescId")
	protected D businessDesc;

	@OneToOne
	@JoinColumn(name = "itemId")
	protected Item item;

	private Double rate = 0.0;
	private Long quantity = 0L;
	private Double amount = 0.0;

	public Item getItem() {
		return item;
	}

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

	public Double getRate() {
		return rate;
	}

	public void setRate(Double rate) {
		this.rate = rate;
		setAmount(getRate() * getQuantity());
	}

	public Long getQuantity() {
		return quantity;
	}

	public void setQuantity(Long quantity) {
		this.quantity = quantity;
		setAmount(getRate() * getQuantity());
	}

	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}

	public void setBusinessDesc(D businessDesc) {
		this.businessDesc = businessDesc;
	}

	@Override
	public Long id() {
		return null;
	}

	@Override
	public String toString() {
		return new String(getQuantity().toString() + " "
				+ getItem().getItemName() + " at " + getRate().toString());
	}

}
@@ -431,16 +431,81 @@
 ms.Item;
+%0Aimport devopsdistilled.operp.server.data.entity.stock.Warehouse;
 %0A%0A@Mappe
@@ -911,16 +911,95 @@
  item;%0A%0A
+%09@OneToOne%0A%09@JoinColumn(name = %22warehouseId%22)%0A%09protected Warehouse warehouse;%0A%0A
 %09private
@@ -1172,32 +1172,174 @@
 tem = item;%0A%09%7D%0A%0A
+%09public Warehouse getWarehouse() %7B%0A%09%09return warehouse;%0A%09%7D%0A%0A%09public void setWarehouse(Warehouse warehouse) %7B%0A%09%09this.warehouse = warehouse;%0A%09%7D%0A%0A
 %09public Double g
@@ -1883,12 +1883,25 @@
 urn 
-null
+businessDescRowId
 ;%0A%09%7D

Add warehouse attribute