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.hr.lm.balancetransfer.service;
17
18 import java.math.BigDecimal;
19 import java.sql.Date;
20 import java.util.ArrayList;
21 import java.util.List;
22 import java.util.Map;
23
24 import org.kuali.hr.lm.accrual.AccrualCategory;
25 import org.kuali.hr.lm.balancetransfer.BalanceTransfer;
26 import org.kuali.hr.lm.leaveSummary.LeaveSummaryRow;
27 import org.kuali.hr.lm.leavecalendar.LeaveCalendarDocument;
28 import org.kuali.hr.time.calendar.CalendarEntries;
29 import org.kuali.rice.kew.api.exception.WorkflowException;
30
31 public interface BalanceTransferService {
32
33 //Data access
34 public List<BalanceTransfer> getAllBalanceTransfersForPrincipalId(String principalId);
35 public List<BalanceTransfer> getAllBalanceTransferForPrincipalIdAsOfDate(String principalId, Date effectiveDate);
36 public List<BalanceTransfer> getAllBalanceTransferByEffectiveDate(Date effectiveDate);
37 public void saveOrUpdate(BalanceTransfer balanceTransfer);
38
39 //@Cacheable(value= LeaveDonation.CACHE_NAME, key="'balanceTransferId=' + #p0")
40 public BalanceTransfer getBalanceTransferById(String balanceTransferId);
41
42 //Use-Case specific service providers. Could be combined if max carry over applies to all use cases.
43 /**
44 * A service that instantiates and returns BalanceTransfer objects that follow the given accrual category rule.
45 *
46 * @param principalId The principal this transfer pertains to.
47 * @param accrualCategoryRule The accrual category rule that contains the max balance information.
48 * @param accruedBalance Holds balance information needed for transfer.
49 * @param effectiveDate
50 * @return A BalanceTransfer object conforming to @param accrualCategoryRule, if one exists. Null otherwise.
51 *
52 * The transfer amount will be the minimum of:
53 *
54 * 1.) the accrual category rule's maximum transfer amount, adjusted for the employees FTE.
55 * 2.) the number of time units exceeding the maximum balance
56 *
57 */
58 public BalanceTransfer initializeTransfer(String principalId, String accrualCategoryRule, BigDecimal accruedBalance, Date effectiveDate);
59
60 /**
61 * Consumes a BalanceTransfer object, creating up to three leave blocks.
62 * @param balanceTransfer The BalanceTransfer object to use for transfer.
63 * @return The same BalanceTransfer object, but with associated leave block ids.
64 */
65 public BalanceTransfer transfer(BalanceTransfer balanceTransfer);
66
67 /**
68 * Helper Services
69 */
70
71 /**
72 * Determines which accrual categories within the given leave calendar document, are TRANSFERABLE for the given action frequency.
73 * Includes accrual categories for which ACTION_AT_MAX_BALANCE = LOSE.
74 *
75 * @param document The LeaveCalendarDocument to use in gathering transfer eligible accrual categories.
76 * @param actionFrequency One of LMConstants.MAX_BAL_ACTION_FREQ
77 * @return A List of accrualCategoryRuleId's in {@param document}'s leave summary with MAX_BAL_ACTION_FREQUENCY = {@param actionFrequency}
78 * @throws Exception
79 */
80 public Map<String,ArrayList<String>> getEligibleTransfers(CalendarEntries calendarEntry, String principalId) throws Exception;
81
82 public void submitToWorkflow(BalanceTransfer balanceTransfer) throws WorkflowException;
83
84 /**
85 * transfer system scheduled time off
86 * @param balanceTransfer
87 * @return
88 */
89 public BalanceTransfer transferSsto(BalanceTransfer balanceTransfer);
90 public List<BalanceTransfer> getBalanceTransfers(String viewPrincipal,
91 Date beginPeriodDate, Date endPeriodDate);
92 }