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.lm.timeoff.service; 017 018 import org.apache.log4j.Logger; 019 import org.kuali.hr.job.Job; 020 import org.kuali.hr.lm.timeoff.SystemScheduledTimeOff; 021 import org.kuali.hr.lm.timeoff.dao.SystemScheduledTimeOffDao; 022 import org.kuali.hr.time.assignment.Assignment; 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 SystemScheduledTimeOffServiceImpl implements SystemScheduledTimeOffService { 032 033 private static final Logger LOG = Logger.getLogger(SystemScheduledTimeOffServiceImpl.class); 034 private SystemScheduledTimeOffDao systemScheduledTimeOffDao; 035 036 public SystemScheduledTimeOffDao getSystemScheduledTimeOffDao() { 037 return systemScheduledTimeOffDao; 038 } 039 040 public void setSystemScheduledTimeOffDao( 041 SystemScheduledTimeOffDao systemScheduledTimeOffDao) { 042 this.systemScheduledTimeOffDao = systemScheduledTimeOffDao; 043 } 044 045 @Override 046 public SystemScheduledTimeOff getSystemScheduledTimeOff(String lmSystemScheduledTimeOffId) { 047 return getSystemScheduledTimeOffDao().getSystemScheduledTimeOff(lmSystemScheduledTimeOffId); 048 } 049 050 @Override 051 public List<SystemScheduledTimeOff> getSystemScheduledTimeOffForPayPeriod( 052 String leavePlan, Date startDate, Date endDate) { 053 return getSystemScheduledTimeOffDao().getSystemScheduledTimeOffForPayPeriod(leavePlan, startDate, endDate); 054 } 055 056 @Override 057 public SystemScheduledTimeOff getSystemScheduledTimeOffByDate( 058 String leavePlan, Date startDate) { 059 return getSystemScheduledTimeOffDao().getSystemScheduledTimeOffByDate(leavePlan, startDate); 060 } 061 @Override 062 public Assignment getAssignmentToApplyHolidays(TimesheetDocument timesheetDocument, java.sql.Date payEndDate) { 063 Job primaryJob = TkServiceLocator.getJobService().getPrimaryJob(timesheetDocument.getPrincipalId(), payEndDate); 064 for(Assignment assign : timesheetDocument.getAssignments()){ 065 if(assign.getJobNumber().equals(primaryJob.getJobNumber())){ 066 return assign; 067 } 068 } 069 return null; 070 } 071 072 @Override 073 public BigDecimal calculateSysSchTimeOffHours(Job job, BigDecimal sstoHours) { 074 BigDecimal fte = job.getStandardHours().divide(new BigDecimal(40.0),TkConstants.BIG_DECIMAL_SCALE); 075 return fte.multiply(sstoHours).setScale(TkConstants.BIG_DECIMAL_SCALE); 076 } 077 078 @Override 079 public List<SystemScheduledTimeOff> getSystemScheduledTimeOffs(Date fromEffdt, Date toEffdt, String earnCode, Date fromAccruedDate, Date toAccruedDate, 080 Date fromSchTimeOffDate, Date toSchTimeOffDate, String active, String showHist) { 081 return systemScheduledTimeOffDao.getSystemScheduledTimeOffs(fromEffdt, toEffdt, earnCode, fromAccruedDate, toAccruedDate, fromSchTimeOffDate, 082 toSchTimeOffDate, active, showHist); 083 } 084 085 @Override 086 public List<SystemScheduledTimeOff> getSystemScheduledTimeOffsForLeavePlan(Date fromAccruedDate,Date toAccruedDate, String leavePlan) { 087 return systemScheduledTimeOffDao.getSystemScheduledTimeOffsForLeavePlan(fromAccruedDate, toAccruedDate, leavePlan); 088 } 089 090 }