// ledger.setBalance(balance);
// }
public DaySheetView getDayTransactionsSheet(Calendar calendar)
{
DaySheetView daySheet = new DaySheetView();
daySheet.setDate(calendar.getTime());
//TODO: Use the appropriate implementation of map.
Map<String, String> creditsMap = new TreeMap<String, String>();
Map<String, String> debitsMap = new TreeMap<String, String>();
Double sumOfCredits = 0.0;
Double sumOfDebits = 0.0;
Calendar startTime = (Calendar)calendar.clone();
startTime.set(Calendar.HOUR_OF_DAY, 0);
startTime.set(Calendar.MINUTE, 0);
startTime.set(Calendar.SECOND, 0);
startTime.set(Calendar.MILLISECOND, 0);
Calendar endTime = calendar;
endTime.set(Calendar.HOUR_OF_DAY, 23);
endTime.set(Calendar.MINUTE, 59);
endTime.set(Calendar.SECOND, 59);
endTime.set(Calendar.MILLISECOND, 1000);
List<Object[]> list = transactionsDAO.getTransactionsSheet(startTime, endTime);
for(Object[] result : list){
if(Constants.CREDIT.equals(result[2])){
creditsMap.put((String)result[1], NumberFormatUtil.getFormattedNumber((Double)result[0]));
sumOfCredits += (Double)result[0];
}else{
debitsMap.put((String)result[1], NumberFormatUtil.getFormattedNumber((Double)result[0]));
sumOfDebits += (Double)result[0];
}
}
daySheet.setCreditsMap(creditsMap);
daySheet.setSumOfCredits(sumOfCredits);
daySheet.setDebitsMap(debitsMap);
daySheet.setSumOfDebits(sumOfDebits);
daySheet.setOpeningBalance(getTotalBalanceAtTime(startTime));
daySheet.setClosingBalance(getTotalBalanceAtTime(endTime));
return daySheet;
}