View Javadoc
1   /**
2    * Copyright 2004-2014 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.kpme.tklm.time.timesheet.service;
17  
18  import org.joda.time.DateTime;
19  import org.joda.time.LocalDate;
20  import org.kuali.kpme.core.api.assignment.Assignment;
21  import org.kuali.kpme.core.api.calendar.entry.CalendarEntry;
22  import org.kuali.kpme.core.api.earncode.EarnCode;
23  import org.kuali.kpme.core.api.earncode.EarnCodeContract;
24  import org.kuali.kpme.tklm.api.time.timeblock.TimeBlock;
25  import org.kuali.kpme.tklm.time.timesheet.TimesheetDocument;
26  import org.kuali.rice.kew.api.exception.WorkflowException;
27  import org.springframework.cache.annotation.Cacheable;
28  
29  import java.util.List;
30  
31  public interface TimesheetService {
32  
33  	/**
34  	 * Opens the timesheet document for the user at the given payEndDate provided.
35  	 * If the timesheet does not exist, it is created.
36  	 * @param principalId
37  	 * @return
38  	 */
39  	public TimesheetDocument openTimesheetDocument(String principalId, CalendarEntry payCalendarDates) throws WorkflowException;
40  	/**
41  	 * Route the given timesheet
42  	 * @param principalId
43  	 * @param timesheetDocument
44  	 */
45  	public void routeTimesheet(String principalId, TimesheetDocument timesheetDocument);
46  
47      public void approveTimesheet(String principalId, TimesheetDocument timesheetDocument);
48  
49      public void disapproveTimesheet(String principalId, TimesheetDocument timesheetDocument);
50  
51  	/**
52  	 * For a given document ID, return a fully populated time sheet document.
53  	 *
54  	 * Fully populated means: TimeBlocks, Jobs, Assignments
55  	 *
56  	 * @param documentId
57  	 * @return
58  	 */
59  	public TimesheetDocument getTimesheetDocument(String documentId);
60  	/**
61  	 * Is user a Clock in/out person or do they manually enter TimeBlocks
62  	 * @return
63  	 */
64  	public boolean isSynchronousUser();
65  	/**
66  	 * Fetch TimeBlocks for previous pay periods
67  	 * @param principalId
68  	 * @param payBeginDate
69  	 * @return
70  	 */
71  	public List<TimeBlock> getPrevDocumentTimeBlocks(String principalId, DateTime payBeginDate);
72  	/**
73  	 * Load holidays on given timesheet
74  	 * @param timesheetDocument
75  	 * @param principalId
76  	 * @param beginDate
77  	 * @param endDate
78  	 */
79  	public void loadHolidaysOnTimesheet(TimesheetDocument timesheetDocument, String principalId, LocalDate beginDate, LocalDate endDate);
80  	/**
81  	 * Delete a timesheet(used for testing only)
82  	 * @param documentId
83  	 */
84  	public void deleteTimesheet(String documentId);
85  	
86  	public List<TimeBlock> resetTimeBlock(List<TimeBlock> timeBlock, LocalDate asOfDate);
87  
88      void approveTimesheet(String principalId, TimesheetDocument timesheetDocument, String action);
89  
90      void routeTimesheet(String principalId, TimesheetDocument timesheetDocument, String action);
91  	public boolean isReadyToApprove(TimesheetDocument document);
92  	
93  	/**
94  	 * Previously in EarnCodeService
95  	 * @param assignment
96  	 * @param asOfDate
97  	 * @return
98  	 */
99  	@Cacheable(value= EarnCodeContract.CACHE_NAME, key="'{getEarnCodesForTime}' + 'principalId=' + T(org.kuali.kpme.tklm.time.util.TkContext).getPrincipalId() + '|' + 'targetId=' + T(org.kuali.kpme.tklm.time.util.TkContext).getTargetPrincipalId() + '|' + 'a=' + #p0.getTkAssignmentId() + '|' + 'asOfDate=' + #p1 + '|' + 'includeRegularEarnCode=' + false")
100 	public List<EarnCode> getEarnCodesForTime(Assignment assignment, LocalDate asOfDate);
101 	
102 	/**
103 	 * Fetch a list of earn codes for Time usage, for a particular assignment as of a particular date
104 	 * @param a
105 	 * @param asOfDate
106 	 * @return
107 	 */
108 	@Cacheable(value= EarnCodeContract.CACHE_NAME, key="'{getEarnCodesForTime}' + 'principalId=' + T(org.kuali.kpme.tklm.time.util.TkContext).getPrincipalId() + '|' + 'targetId=' + T(org.kuali.kpme.tklm.time.util.TkContext).getTargetPrincipalId() + '|' + 'a=' + #p0.getTkAssignmentId() + '|' + 'asOfDate=' + #p1 + '|' + 'includeRegularEarnCode=' + #p2")
109 	public List<EarnCode> getEarnCodesForTime(Assignment a, LocalDate asOfDate, boolean includeRegularEarnCode);
110 
111 
112     public List<String> validateTimeBlock(TimesheetDocument td);
113     public List<String> validateHours(TimesheetDocument td);
114     public boolean isTimesheetValid(TimesheetDocument td);
115 }