1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.holidaycalendar.service;
17
18 import org.kuali.hr.job.Job;
19 import org.kuali.hr.time.assignment.Assignment;
20 import org.kuali.hr.time.holidaycalendar.HolidayCalendar;
21 import org.kuali.hr.time.holidaycalendar.HolidayCalendarDateEntry;
22 import org.kuali.hr.time.holidaycalendar.dao.HolidayCalendarDao;
23 import org.kuali.hr.time.service.base.TkServiceLocator;
24 import org.kuali.hr.time.timesheet.TimesheetDocument;
25 import org.kuali.hr.time.util.TkConstants;
26
27 import java.math.BigDecimal;
28 import java.util.Date;
29 import java.util.List;
30
31 public class HolidayCalendarServiceImpl implements HolidayCalendarService {
32 private HolidayCalendarDao holidayCalendarDao;
33
34
35 @Override
36 public HolidayCalendar getHolidayCalendarByGroup(String holidayCalendarGroup) {
37 return holidayCalendarDao.getHolidayCalendarByGroup(holidayCalendarGroup);
38 }
39
40
41 public HolidayCalendarDao getHolidayCalendarDao() {
42 return holidayCalendarDao;
43 }
44
45
46 public void setHolidayCalendarDao(HolidayCalendarDao holidayCalendarDao) {
47 this.holidayCalendarDao = holidayCalendarDao;
48 }
49
50
51 @Override
52 public List<HolidayCalendarDateEntry> getHolidayCalendarDateEntriesForPayPeriod(
53 String hrHolidayCalendarId, Date startDate, Date endDate) {
54 return holidayCalendarDao.getHolidayCalendarDateEntriesForPayPeriod(hrHolidayCalendarId, startDate, endDate);
55 }
56
57 @Override
58 public HolidayCalendarDateEntry getHolidayCalendarDateEntryByDate(String hrHolidayCalendarId, Date startDate) {
59 return holidayCalendarDao.getHolidayCalendarDateEntryByDate(hrHolidayCalendarId, startDate);
60 }
61
62 @Override
63 public Assignment getAssignmentToApplyHolidays(TimesheetDocument timesheetDocument, java.sql.Date payEndDate) {
64 Job primaryJob = TkServiceLocator.getJobService().getPrimaryJob(timesheetDocument.getPrincipalId(), payEndDate);
65 for(Assignment assign : timesheetDocument.getAssignments()){
66 if(assign.getJobNumber().equals(primaryJob.getJobNumber())){
67 return assign;
68 }
69 }
70 return null;
71 }
72
73
74 @Override
75 public BigDecimal calculateHolidayHours(Job job, BigDecimal holidayHours) {
76 BigDecimal fte = job.getStandardHours().divide(new BigDecimal(40.0),TkConstants.BIG_DECIMAL_SCALE);
77 return fte.multiply(holidayHours).setScale(TkConstants.BIG_DECIMAL_SCALE);
78 }
79
80 }