* @param si - Store item
*/
public void checkInventory(ShoppingCartItem si)
{
Util.debug("ShoppingCart.checkInventory() - checking Inventory quantity of item: " + si.getID());
Inventory inv = getInventoryItem(si.getID());
/**
* Decrease the quantity of this inventory item.
* @param quantity The number to decrease the inventory by.
* @return The number of inventory items removed.
*/
int quantity=si.getQuantity();
int minimumItems = inv.getMinThreshold();
int amountToOrder = 0;
Util.debug("ShoppingCartBean:checkInventory() - Decreasing inventory item " +inv.getInventoryId());
int quantityNotFilled = 0;
if (inv.getQuantity() < 1)
{
quantityNotFilled = quantity;
}
else if (inv.getQuantity() < quantity)
{
quantityNotFilled = quantity - inv.getQuantity();
}
// When quantity becomes < 0, this will be to determine the
// quantity of unfilled orders due to insufficient stock.
inv.setQuantity(inv.getQuantity() - quantity);
// Check to see if more inventory needs to be ordered from the supplier
// based on a set minimum Threshold
if (inv.getQuantity() < minimumItems)
{
// Calculate the amount of stock to order from the supplier
// to get the inventory up to the maximum.
amountToOrder = quantityNotFilled;
backOrder(inv, amountToOrder);