001 /** 002 * Copyright 2004-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.hr.time.holidaycalendar.service; 017 018 import org.kuali.hr.job.Job; 019 import org.kuali.hr.time.assignment.Assignment; 020 import org.kuali.hr.time.holidaycalendar.HolidayCalendar; 021 import org.kuali.hr.time.holidaycalendar.HolidayCalendarDateEntry; 022 import org.kuali.hr.time.holidaycalendar.dao.HolidayCalendarDao; 023 import org.kuali.hr.time.service.base.TkServiceLocator; 024 import org.kuali.hr.time.timesheet.TimesheetDocument; 025 import org.kuali.hr.time.util.TkConstants; 026 027 import java.math.BigDecimal; 028 import java.util.Date; 029 import java.util.List; 030 031 public class HolidayCalendarServiceImpl implements HolidayCalendarService { 032 private HolidayCalendarDao holidayCalendarDao; 033 034 035 @Override 036 public HolidayCalendar getHolidayCalendarByGroup(String holidayCalendarGroup) { 037 return holidayCalendarDao.getHolidayCalendarByGroup(holidayCalendarGroup); 038 } 039 040 041 public HolidayCalendarDao getHolidayCalendarDao() { 042 return holidayCalendarDao; 043 } 044 045 046 public void setHolidayCalendarDao(HolidayCalendarDao holidayCalendarDao) { 047 this.holidayCalendarDao = holidayCalendarDao; 048 } 049 050 051 @Override 052 public List<HolidayCalendarDateEntry> getHolidayCalendarDateEntriesForPayPeriod( 053 String hrHolidayCalendarId, Date startDate, Date endDate) { 054 return holidayCalendarDao.getHolidayCalendarDateEntriesForPayPeriod(hrHolidayCalendarId, startDate, endDate); 055 } 056 057 @Override 058 public HolidayCalendarDateEntry getHolidayCalendarDateEntryByDate(String hrHolidayCalendarId, Date startDate) { 059 return holidayCalendarDao.getHolidayCalendarDateEntryByDate(hrHolidayCalendarId, startDate); 060 } 061 062 @Override 063 public Assignment getAssignmentToApplyHolidays(TimesheetDocument timesheetDocument, java.sql.Date payEndDate) { 064 Job primaryJob = TkServiceLocator.getJobService().getPrimaryJob(timesheetDocument.getPrincipalId(), payEndDate); 065 for(Assignment assign : timesheetDocument.getAssignments()){ 066 if(assign.getJobNumber().equals(primaryJob.getJobNumber())){ 067 return assign; 068 } 069 } 070 return null; 071 } 072 073 074 @Override 075 public BigDecimal calculateHolidayHours(Job job, BigDecimal holidayHours) { 076 BigDecimal fte = job.getStandardHours().divide(new BigDecimal(40.0),TkConstants.BIG_DECIMAL_SCALE); 077 return fte.multiply(holidayHours).setScale(TkConstants.BIG_DECIMAL_SCALE); 078 } 079 080 }