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

import java.util.List;

import ee.ut.math.tvt2008.salessystem.domain.data.Client;
import ee.ut.math.tvt2008.salessystem.domain.data.Sale;
import ee.ut.math.tvt2008.salessystem.domain.data.StockItem;

/**
 * Sales domain controller is responsible for the domain specific
 * business processes.
 */
public interface SalesDomainController {
	
	/**
	 * Load the current state of the warehouse.
	 * @return List of ${link ee.ut.math.tvt2008.salessystem.domain.data.StockItem}s.
	 */
	public List<StockItem> loadWarehouseState();

	/**
	 * Load list of all clients.
	 * @return List of ${link ee.ut.math.tvt2008.salessystem.domain.data.Client}s.
	 */
	public List<Client> loadAllClients();

	/**
	 * Get client with specified id.
	 * @param id client id.
	 * @return client.
	 */
	public Client getClientById(long id);

	/**
	 * Load purchase history.
	 * @return List of ${link ee.ut.math.tvt2008.salessystem.domain.data.Sale}s.
	 */
	public List<Sale> loadPurchaseHistory();

	/**
	 * Find detailed info for Sale with specified id. 
	 * @param id sale id.
	 * @return sale.
	 */
	public Sale findSaleInfo(Long id);

	// business processes
	/**
	 * Initiate new business transaction - purchase of the goods.
	 * @throws VerificationFailedException
	 */
	public void startNewPurchase() throws VerificationFailedException;
	
	/**
	 * Rollback business transaction - purchase of goods.
	 * @throws VerificationFailedException
	 */
	public void cancelCurrentPurchase() throws VerificationFailedException;
	
	/**
	 * Commit business transaction - purchsae of goods.
	 * @param goods Goods that the buyer has chosen to buy.
	 * @param currentClient client for current sale.
	 * @throws VerificationFailedException
	 */
	public void submitCurrentPurchase(List<StockItem> goods, Client currentClient) throws VerificationFailedException;

}
