YearMonthDay lowerBeginDate = beginDate.minusDays(8);
    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;//      TODO remove comment in 2007//        Duration totalComplementaryWeeklyRestBalance = Duration.ZERO;//        Duration totalWeeklyRestBalance = Duration.ZERO;        HashMap<YearMonthDay, WorkSchedule> workScheduleMap = new HashMap<YearMonthDay, WorkSchedule>();        for (YearMonthDay thisDay = beginDate.minusDays(1); thisDay.isBefore(endDate.plusDays(1)); thisDay = thisDay                .plusDays(1)) {            final Schedule schedule = assiduousness.getSchedule(thisDay);            if (schedule != null) {                workScheduleMap.put(thisDay, schedule.workScheduleWithDate(thisDay));            } else {                workScheduleMap.put(thisDay, null);            }        }        DateTime init = beginDate.toDateTime(Assiduousness.defaultStartWorkDay);        WorkSchedule beginWorkSchedule = workScheduleMap.get(beginDate);        if (beginWorkSchedule != null) {            init = beginDate.toDateTime(beginWorkSchedule.getWorkScheduleType().getWorkTime());        }        DateTime end = endDate.toDateTime(Assiduousness.defaultEndWorkDay);        WorkSchedule endWorkSchedule = workScheduleMap.get(endDate);        if (endWorkSchedule != null) {            end = endDate.toDateTime(endWorkSchedule.getWorkScheduleType().getWorkTime()).plus(                    endWorkSchedule.getWorkScheduleType().getWorkTimeDuration());            if (endWorkSchedule.getWorkScheduleType().isWorkTimeNextDay()) {                end = end.plusDays(2);            }        }        final List<AssiduousnessRecord> clockings = assiduousness.getClockingsAndMissingClockings(init                .minusDays(1), end);        Collections.sort(clockings, AssiduousnessRecord.COMPARATORY_BY_DATE);        HashMap<YearMonthDay, List<AssiduousnessRecord>> clockingsMap = new HashMap<YearMonthDay, List<AssiduousnessRecord>>();        for (AssiduousnessRecord record : clockings) {            YearMonthDay clockDay = record.getDate().toYearMonthDay();            if (overlapsSchedule(record.getDate(), workScheduleMap)) {                if (clockingsMap.get(clockDay.minusDays(1)) != null                        && clockingsMap.get(clockDay.minusDays(1)).size() % 2 != 0) {                    clockDay = clockDay.minusDays(1);                }            }            List<AssiduousnessRecord> clocks = clockingsMap.get(clockDay);            if (clocks == null) {                clocks = new ArrayList<AssiduousnessRecord>();            }            clocks.add(record);            clockingsMap.put(clockDay, 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)) {                if (record.getAplicableWeekDays() == null                        || record.getAplicableWeekDays().contains(leaveDay.toDateTimeAtMidnight())) {                    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 StringBuilder notes = new StringBuilder();                final boolean isDayHoliday = assiduousness.isHoliday(thisDay);                final WorkSchedule workSchedule = workScheduleMap.get(thisDay);                workDaySheet.setWorkSchedule(workSchedule);                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);                if (workSchedule != null && !isDayHoliday) {                    for (final Leave leave : leavesList) {                        if (notes.length() != 0) {                            notes.append(" / ");                        }                        notes.append(leave.getJustificationMotive().getAcronym());                    }                    workDaySheet.setNotes(notes.toString());                    if (!thisDay.equals(today)) {                        workDaySheet = assiduousness.calculateDailyBalance(workDaySheet, thisDay,                                isDayHoliday);                        totalBalance = totalBalance.plus(workDaySheet.getBalanceTime().toDurationFrom(                                new DateMidnight()));                        totalUnjustified = totalUnjustified.plus(workDaySheet.getUnjustifiedTime());                    }                    workDaySheet.setWorkScheduleAcronym(workSchedule.getWorkScheduleType().getAcronym());                    workSheet.add(workDaySheet);                } else {//                  TODO remove comment in 2007//                    if (!thisDay.equals(today)) {//                        workDaySheet = assiduousness.calculateDailyBalance(workDaySheet, thisDay,//                                isDayHoliday);//                        totalComplementaryWeeklyRestBalance = totalComplementaryWeeklyRestBalance//                                .plus(workDaySheet.getComplementaryWeeklyRest());//                        totalWeeklyRestBalance = totalWeeklyRestBalance.plus(workDaySheet//                                .getWeeklyRest());//                    }                    for (final Leave leave : leavesList) {                        if (leave.getJustificationMotive().getJustificationType() == JustificationType.OCCURRENCE                                && leave.getJustificationMotive().getDayType() != DayType.WORKDAY                                && leave.getJustificationMotive().getJustificationGroup() != JustificationGroup.CURRENT_YEAR_HOLIDAYS                                && leave.getJustificationMotive().getJustificationGroup() != JustificationGroup.LAST_YEAR_HOLIDAYS) {                            if (notes.length() != 0) {                                notes.append(" / ");                            }                            notes.append(leave.getJustificationMotive().getAcronym());                        }                    }                    workDaySheet.setNotes(notes.toString());                    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);        if (assiduousness.getEmployee().getLastContract() != null                && assiduousness.getEmployee().getLastContract().getMailingUnit() != null) {            unit = assiduousness.getEmployee().getLastContract().getMailingUnit();        }        employeeWorkSheet.setUnit(unit);        if (unit != null) {            employeeWorkSheet.setUnitCode((new DecimalFormat("0000")).format(unit.getCostCenterCode()));        } else {            employeeWorkSheet.setUnitCode("");        }        employeeWorkSheet.setTotalBalance(totalBalance);        employeeWorkSheet.setUnjustifiedBalance(totalUnjustified);        //TODO remove comment in 2007//        employeeWorkSheet.setComplementaryWeeklyRest(totalComplementaryWeeklyRestBalance);//        employeeWorkSheet.setWeeklyRest(totalWeeklyRestBalance);        return employeeWorkSheet;    } // if returns false the clocking belongs to the clocking date // if returns true it may