clockingsMap.put(record.getDate().toYearMonthDay(), clocks);
clockingsMap.put(clockDay, clocks);
    private EmployeeWorkSheet getEmployeeWorkSheet(Assiduousness assiduousness, YearMonthDay beginDate,            YearMonthDay endDate, YearMonthDay today) {        final List<WorkDaySheet> workSheet = new ArrayList<WorkDaySheet>();        Duration totalBalance = Duration.ZERO;        Duration totalUnjustified = Duration.ZERO;        final Schedule beginDaySchedule = assiduousness.getSchedule(beginDate);        DateTime init = beginDate.toDateTime(Assiduousness.defaultStartWorkDay);        if (beginDaySchedule != null) {            WorkSchedule beginWorkSchedule = beginDaySchedule.workScheduleWithDate(beginDate);            if (beginWorkSchedule != null) {                init = beginDate.toDateTime(beginWorkSchedule.getWorkScheduleType()                        .getWorkTime());            }        }        final Schedule endDaySchedule = assiduousness.getSchedule(endDate);        DateTime end = endDate.toDateTime(Assiduousness.defaultEndWorkDay);        if (endDaySchedule != null) {            WorkSchedule endWorkSchedule = endDaySchedule.workScheduleWithDate(endDate);            if (endWorkSchedule != null) {                end = endDate.toDateTime(endWorkSchedule.getWorkScheduleType().getWorkTime());                if (endWorkSchedule.getWorkScheduleType().isWorkTimeNextDay()) {                    end = end.plusDays(1);                }            }        }        final List<AssiduousnessRecord> clockings = assiduousness                .getClockingsAndMissingClockings(init, end);        HashMap<YearMonthDay, List<AssiduousnessRecord>> clockingsMap = new HashMap<YearMonthDay, List<AssiduousnessRecord>>();        for (AssiduousnessRecord record : clockings) {            List<AssiduousnessRecord> clocks = clockingsMap.get(record.getDate()                    .toYearMonthDay());            if (clocks == null) {                clocks = new ArrayList<AssiduousnessRecord>();            }            clocks.add(record);            clockingsMap.put(record.getDate().toYearMonthDay(), clocks);        }        final List<Leave> leaves = assiduousness.getLeaves(beginDate, endDate);        HashMap<YearMonthDay, List<Leave>> leavesMap = new HashMap<YearMonthDay, List<Leave>>();        for (Leave record : leaves) {            YearMonthDay endLeaveDay = record.getDate().toYearMonthDay().plusDays(1);            if (record.getEndYearMonthDay() != null) {                endLeaveDay = record.getEndYearMonthDay().plusDays(1);            }            for (YearMonthDay leaveDay = record.getDate().toYearMonthDay(); leaveDay                    .isBefore(endLeaveDay); leaveDay = leaveDay.plusDays(1)) {                List<Leave> leaveList = leavesMap.get(leaveDay);                if (leaveList == null) {                    leaveList = new ArrayList<Leave>();                }                leaveList.add(record);                leavesMap.put(leaveDay, leaveList);            }        }        for (YearMonthDay thisDay = beginDate; thisDay.isBefore(endDate.plusDays(1)); thisDay = thisDay                .plusDays(1)) {            WorkDaySheet workDaySheet = new WorkDaySheet();            workDaySheet.setDate(thisDay);            final Schedule schedule = assiduousness.getSchedule(thisDay);            if (schedule == null) {                workDaySheet.setNotes("");                workDaySheet.setBalanceTime(new Period(0));                workDaySheet.setUnjustifiedTime(Duration.ZERO);                workSheet.add(workDaySheet);            } else {                final boolean isDayHoliday = assiduousness.isHoliday(thisDay);                final WorkSchedule workSchedule = schedule.workScheduleWithDate(thisDay);                workDaySheet.setWorkSchedule(workSchedule);                if (workSchedule != null && !isDayHoliday) {                    List<AssiduousnessRecord> clockingsList = clockingsMap.get(thisDay);                    if (clockingsList == null) {                        clockingsList = new ArrayList<AssiduousnessRecord>();                    }                    Collections.sort(clockingsList, AssiduousnessRecord.COMPARATORY_BY_DATE);                    workDaySheet.setAssiduousnessRecords(clockingsList);                    List<Leave> leavesList = leavesMap.get(thisDay);                    if (leavesList == null) {                        leavesList = new ArrayList<Leave>();                    }                    Collections.sort(leavesList, Leave.COMPARATORY_BY_DATE);                    workDaySheet.setLeaves(leavesList);                    final StringBuilder notes = new StringBuilder();                    for (final Leave leave : leavesList) {                        if (notes.length() != 0) {                            notes.append(" / ");                        }                        notes.append(leave.getJustificationMotive().getAcronym());                    }                    workDaySheet.setNotes(notes.toString());                    workDaySheet = assiduousness.calculateDailyBalance(workDaySheet, thisDay,                            isDayHoliday);                    if (!thisDay.equals(today)) {                        totalBalance = totalBalance.plus(workDaySheet.getBalanceTime()                                .toDurationFrom(new DateMidnight()));                    }                    totalUnjustified = totalUnjustified.plus(workDaySheet.getUnjustifiedTime());                    workDaySheet.setWorkScheduleAcronym(workSchedule.getWorkScheduleType()                            .getAcronym());                    workSheet.add(workDaySheet);                } else {                    List<AssiduousnessRecord> clockingsList = clockingsMap.get(thisDay);                    if (clockingsList == null) {                        clockingsList = new ArrayList<AssiduousnessRecord>();                    }                    Collections.sort(clockingsList, AssiduousnessRecord.COMPARATORY_BY_DATE);                    workDaySheet.setAssiduousnessRecords(clockingsList);                    workDaySheet.setLeaves(new ArrayList<Leave>());                    workDaySheet = assiduousness.calculateDailyBalance(workDaySheet, thisDay,                            isDayHoliday);                    workDaySheet.setNotes("");                    if (isDayHoliday) {                        ResourceBundle bundle = ResourceBundle                                .getBundle("resources.AssiduousnessResources");                        workDaySheet.setWorkScheduleAcronym(bundle.getString("label.holiday"));                    }                    workDaySheet.setUnjustifiedTime(Duration.ZERO);                    workSheet.add(workDaySheet);                }            }        }        EmployeeWorkSheet employeeWorkSheet = new EmployeeWorkSheet();        employeeWorkSheet.setWorkDaySheetList(workSheet);        employeeWorkSheet.setEmployee(assiduousness.getEmployee());        Unit unit = assiduousness.getEmployee().getLastWorkingPlaceByPeriod(beginDate, endDate);        employeeWorkSheet.setUnit(unit);        if (unit != null) {            employeeWorkSheet.setUnitCode(unit.getCostCenterCode().toString());        } else {            employeeWorkSheet.setUnitCode("");        }        employeeWorkSheet.setTotalBalance(totalBalance);        employeeWorkSheet.setUnjustifiedBalance(totalUnjustified);        return employeeWorkSheet;    }