View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }