package ee.ut.math.tvt2008.salessystem.domain.data;

import java.math.BigDecimal;

/**
 * Already bought stock item. Sold item duplicates name and price for preserving history. 
 * This object is used by hibernate and corresponds to a table in database.
 */
public class SoldItem implements DisplayableItem {
	private Long id;
	private Sale sale;
	private StockItem stockItem;
	
	private String name;
	private Integer quantity;
	private BigDecimal price;
	
	public Long getId() {
		return id;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public BigDecimal getPrice() {
		return price;
	}
	
	public void setPrice(BigDecimal price) {
		this.price = price;
	}
	
	public Integer getQuantity() {
		return quantity;
	}
	
	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}

	public Sale getSale() {
		return sale;
	}

	public void setSale(Sale sale) {
		this.sale = sale;
	}

	public BigDecimal getValue() {
		return price.multiply(BigDecimal.valueOf(quantity));
	}

	public StockItem getStockItem() {
		return stockItem;
	}

	public void setStockItem(StockItem stockItem) {
		this.stockItem = stockItem;
	}
}
