public static boolean isProductInventoryAvailableByFacility(ProductConfigWrapper productConfig,String inventoryFacilityId,BigDecimal quantity,LocalDispatcher dispatcher){
  boolean available=true;
  List<ConfigOption> options=productConfig.getSelectedOptions();
  for (  ConfigOption ci : options) {
    List<GenericValue> products=ci.getComponents();
    for (    GenericValue product : products) {
      String productId=product.getString("productId");
      BigDecimal cmpQuantity=product.getBigDecimal("quantity");
      BigDecimal neededQty=BigDecimal.ZERO;
      if (cmpQuantity != null) {
        neededQty=quantity.multiply(cmpQuantity);
      }
      if (!isProductInventoryAvailableByFacility(productId,inventoryFacilityId,neededQty,dispatcher)) {
        ci.setAvailable(false);
      }
    }
    if (!ci.isAvailable()) {
      available=false;
    }
  }
  return available;
}

public static boolean isProductInventoryAvailableByFacility ( ProductConfigWrapper productConfig , String inventoryFacilityId , BigDecimal quantity , LocalDispatcher dispatcher ) { boolean available = true ; List < ConfigOption > options = productConfig . getSelectedOptions ( ) ; for ( ConfigOption ci : options ) { List < GenericValue > products = ci . getComponents ( ) ; for ( GenericValue product : products ) { String productId = product . getString ( "productId" ) ; BigDecimal cmpQuantity = product . getBigDecimal ( "quantity" ) ; BigDecimal neededQty = BigDecimal . ZERO ; if ( cmpQuantity != null ) { neededQty = quantity . multiply ( cmpQuantity ) ; } if ( ! isProductInventoryAvailableByFacility ( productId , inventoryFacilityId , neededQty , dispatcher ) ) { ci . setAvailable ( false ) ; } } if ( ! ci . isAvailable ( ) ) { available = false ; } } return available ; }
invokes the getinventoryavailablebyfacility service , returns true if specified quantity is available for all the selected parts , else false . also , set the available flag for all the product configuration ' s options .
