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