String concept = null;
Validate.notEmpty(stockIncomeDescriptionList,
"The StockIncomeDescriptionList cannot be empty");
Set<StockExpensesAnnotation> stocksBoughtSet = new HashSet<StockExpensesAnnotation>();
for (StockIncomeDescription stockIncomeDescription : stockIncomeDescriptionList) {
StockIncomeAnnotation stockIncomeAnnotation = stockIncomeDescription
.getStockIncomeAnnotation();
numberOfStocks += stockIncomeAnnotation.getNumberOfStocks();
profits += stockIncomeAnnotation.getAmount();
for (StocksBuySubtransaction stocksBuySubtransaction : stockIncomeDescription
.getStocksBuySubtransactionSet()) {
profits -= (stocksBuySubtransaction.getNumberOfStocks() * stocksBuySubtransaction
.getPricePerStock());
stocksBoughtSet.add(stocksBuySubtransaction
.getStockExpensesAnnotation());
}
if (lastSoldDate == null) {
lastSoldDate = stockIncomeAnnotation.getDate();
} else if (lastSoldDate.before(stockIncomeAnnotation.getDate())) {
lastSoldDate = stockIncomeAnnotation.getDate();
}
book = stockIncomeAnnotation.getBook();
concept = stockIncomeAnnotation.getConcept();
}
Long numberOfStocksBought = 0L;
for (StockExpensesAnnotation stockExpensesAnnotation : stocksBoughtSet) {
numberOfStocksBought += stockExpensesAnnotation.getNumberOfStocks();
}