BigDecimal unitPrice = orderItem.getBigDecimal("unitPrice");
BigDecimal itemValue = unitPrice.multiply(selectedAmount);
// total value for package (per unit * quantity)
totalIssued = totalIssued.add(issuanceQuantity);
totalValue = totalValue.add(itemValue.multiply(issuanceQuantity));
}
}
}
// take the average value of the issuances and multiply it by the shipment package content quantity
value = totalValue.divide(totalIssued, 10, BigDecimal.ROUND_HALF_EVEN).multiply(quantity);