public static boolean isProductInventoryAvailableByFacility(ProductConfigWrapper productConfig, String inventoryFacilityId, double quantity, LocalDispatcher dispatcher) throws GenericServiceException {
boolean available = true;
List options = productConfig.getSelectedOptions();
Iterator optionsIt = options.iterator();
while (optionsIt.hasNext()) {
ConfigOption ci = (ConfigOption)optionsIt.next();
List products = ci.getComponents();
Iterator productsIt = products.iterator();
while (productsIt.hasNext()) {
GenericValue product = (GenericValue)productsIt.next();
String productId = product.getString("productId");
Double cmpQuantity = product.getDouble("quantity");
double neededQty = 1.0;
if (cmpQuantity != null) {
neededQty = quantity * cmpQuantity.doubleValue();
}
if (!isProductInventoryAvailableByFacility(productId, inventoryFacilityId, neededQty, dispatcher)) {
ci.setAvailable(false);
}
}
if (!ci.isAvailable()) {
available = false;
}
}
return available;
}