// Get the list of shipments which are associated with the filtered purchase orders
if (! UtilValidate.isEmpty(invoiceablePrimaryOrderIds)) {
List invoiceableShipmentConds = UtilMisc.toList(
new EntityExpr("primaryOrderId", EntityOperator.IN, invoiceablePrimaryOrderIds),
new EntityExpr("shipmentId", EntityOperator.IN, shipmentIds));
invoiceableShipments = delegator.findByCondition("Shipment", new EntityConditionList(invoiceableShipmentConds, EntityOperator.AND), null, null);
}
} else {
List invoiceableShipmentIds = EntityUtil.getFieldListFromEntityList(toBillItems, "shipmentId", true);
if (! UtilValidate.isEmpty(invoiceableShipmentIds)) {
invoiceableShipments = delegator.findByCondition("Shipment", new EntityExpr("shipmentId", EntityOperator.IN, invoiceableShipmentIds), null, null);