List<GenericValue> invoiceItems = new ArrayList<GenericValue>();
try {
List<EntityExpr> invoiceRoleConds = UtilMisc.toList(
EntityCondition.makeCondition("invoiceId", EntityOperator.EQUALS, salesInvoiceId),
EntityCondition.makeCondition("roleTypeId", EntityOperator.EQUALS, "BILL_FROM_VENDOR"));
billFromVendorInvoiceRoles = EntityUtil.getFieldListFromEntityList(delegator.findList("InvoiceRole", EntityCondition.makeCondition(invoiceRoleConds, EntityOperator.AND), null, null, null, false), "partyId", true);
invoiceRoleConds = UtilMisc.toList(
EntityCondition.makeCondition("invoiceId", EntityOperator.EQUALS, salesInvoiceId),
EntityCondition.makeCondition("roleTypeId", EntityOperator.EQUALS, "SALES_REP"));
// if the receiving parties is empty then we will create commission invoices for all sales agent associated to sales invoice.
if (UtilValidate.isEmpty(salesRepPartyIds)) {