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.api.leave.accrual;
17  
18  import org.joda.time.DateTime;
19  import org.joda.time.LocalDate;
20  import org.kuali.kpme.core.api.accrualcategory.AccrualCategoryContract;
21  import org.kuali.kpme.core.api.calendar.entry.CalendarEntry;
22  import org.kuali.kpme.core.api.leaveplan.LeavePlanContract;
23  
24  import java.math.BigDecimal;
25  import java.util.List;
26  import java.util.Map;
27  
28  public interface AccrualService {
29  	public void runAccrual(String principalId);
30  	
31  	/*
32  	 * run Accrual for the given principal id and dates. 
33  	 * If recordRanData is true, record the timestamp of this run in database 
34  	 */
35  	public void runAccrual(String principalId, DateTime startDate, DateTime endDate, boolean recordRanData);
36  	public void runAccrual(String principalId, DateTime startDate, DateTime endDate, boolean recordRanData, String runAsPrincipalId);
37  	public void runAccrual(List<String> principalIds);
38  	
39  	/*
40  	 * run Accrual for the all employees with the given leave plan and dates. 
41  	 * If recordRanData is true, record the timestamp of this run in database 
42  	 */
43  	public void runAccrualForLeavePlan(LeavePlanContract aLeavePlan, DateTime startDate, DateTime endDate, boolean recordRanData);
44  	
45  	
46  	/**
47  	 * determine if the given date is at the earn interval
48  	 * @param aDate
49  	 * @param earnInterval
50  	 * @return boolean
51  	 */
52  	public boolean isDateAtEarnInterval(LocalDate aDate, String earnInterval);
53  	
54  	/**
55  	 * build a RateRangeAggregate with given parameters
56  	 * @param principalId
57  	 * @param startDate
58  	 * @param endDate
59  	 * @return boolean
60  	 */
61  	public RateRangeAggregateContract buildRateRangeAggregate(String principalId, DateTime startDate, DateTime endDate);
62  	
63  	/**
64  	 * determine if the employee's future status is changed during the range of given Calendar Entry
65  	 * @param principalId
66  	 * @param startDate
67  	 * @param endDate
68  	 * @return boolean
69  	 */
70  	public boolean isEmpoyeementFutureStatusChanged(String principalId, DateTime startDate, DateTime endDate);
71  	
72  	/**
73  	 * calculate future accrual for given principal id
74  	 * @param principalId
75  	 * @param asOfDate
76  	 * @param string 
77  	 * @return
78  	 */
79  	public void calculateFutureAccrualUsingPlanningMonth(String principalId, LocalDate asOfDate, String string);
80  
81  	/**
82  	 * get the accrual interval date of the previous accrual period with given parameters
83  	 * @param earnInterval
84  	 * @param aDate
85  	 * @return
86  	 */
87  	public DateTime getPreviousAccrualIntervalDate(String earnInterval, DateTime aDate);
88  	
89  	/**
90  	 * get the accrual interval date of the next accrual period with given parameters
91  	 * @param earnInterval
92  	 * @param aDate
93  	 * @return
94  	 */
95  	public DateTime getNextAccrualIntervalDate(String earnInterval, DateTime aDate);
96  
97  	/**
98  	 * calculate # of work days in an accrual period
99  	 * @param earnInterval
100 	 * @param aDate
101 	 * @return	int
102 	 */
103 	public int getWorkDaysInAccrualInterval(String earnInterval, DateTime aDate);
104 	
105 	public boolean statusChangedSinceLastRun(String principalId);
106 
107     /**
108      * Retreives the principal's balance on the current calendar for the given accrual category through the date supplied.
109      * @param principalId The id of the principal 
110      * @param accrualCategory The accrual category the balance is being requested of
111      * @param asOfDate 
112      * @return
113      * @throws Exception 
114      */
115 	public BigDecimal getAccruedBalanceForPrincipal(String principalId, AccrualCategoryContract accrualCategory, LocalDate asOfDate);
116 	
117 	public BigDecimal getApprovedBalanceForPrincipal(String principalId, AccrualCategoryContract accrualCategory, LocalDate asOfDate);
118 
119     DateTime getNextIntervalDate(DateTime aDate, String earnInterval, String payCalName, Map<String, List<CalendarEntry>> aMap);
120 }