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.balancetransfer.service; 017 018 import java.math.BigDecimal; 019 import java.sql.Date; 020 import java.util.ArrayList; 021 import java.util.List; 022 import java.util.Map; 023 import java.util.Set; 024 025 import org.kuali.hr.lm.accrual.AccrualCategory; 026 import org.kuali.hr.lm.balancetransfer.BalanceTransfer; 027 import org.kuali.hr.lm.leaveSummary.LeaveSummaryRow; 028 import org.kuali.hr.lm.leaveblock.LeaveBlock; 029 import org.kuali.hr.lm.leavecalendar.LeaveCalendarDocument; 030 import org.kuali.hr.time.calendar.CalendarEntries; 031 import org.kuali.rice.kew.api.exception.WorkflowException; 032 033 public interface BalanceTransferService { 034 035 //Data access 036 public List<BalanceTransfer> getAllBalanceTransfersForPrincipalId(String principalId); 037 public List<BalanceTransfer> getAllBalanceTransferForPrincipalIdAsOfDate(String principalId, Date effectiveDate); 038 public List<BalanceTransfer> getAllBalanceTransferByEffectiveDate(Date effectiveDate); 039 public void saveOrUpdate(BalanceTransfer balanceTransfer); 040 041 //@Cacheable(value= LeaveDonation.CACHE_NAME, key="'balanceTransferId=' + #p0") 042 public BalanceTransfer getBalanceTransferById(String balanceTransferId); 043 044 //Use-Case specific service providers. Could be combined if max carry over applies to all use cases. 045 /** 046 * A service that instantiates and returns BalanceTransfer objects that follow the given accrual category rule. 047 * 048 * @param principalId The principal this transfer pertains to. 049 * @param accrualCategoryRule The accrual category rule that contains the max balance information. 050 * @param accruedBalance Holds balance information needed for transfer. 051 * @param effectiveDate 052 * @return A BalanceTransfer object conforming to @param accrualCategoryRule, if one exists. Null otherwise. 053 * 054 * The transfer amount will be the minimum of: 055 * 056 * 1.) the accrual category rule's maximum transfer amount, adjusted for the employees FTE. 057 * 2.) the number of time units exceeding the maximum balance 058 * 059 */ 060 public BalanceTransfer initializeTransfer(String principalId, String accrualCategoryRule, BigDecimal accruedBalance, Date effectiveDate); 061 062 /** 063 * Consumes a BalanceTransfer object, creating up to three leave blocks. 064 * @param balanceTransfer The BalanceTransfer object to use for transfer. 065 * @return The same BalanceTransfer object, but with associated leave block ids. 066 */ 067 public BalanceTransfer transfer(BalanceTransfer balanceTransfer); 068 069 /** 070 * Helper Services 071 */ 072 073 /** 074 * Determines which accrual categories within the given leave calendar document, are TRANSFERABLE for the given action frequency. 075 * Includes accrual categories for which ACTION_AT_MAX_BALANCE = LOSE. 076 * 077 * @param document The LeaveCalendarDocument to use in gathering transfer eligible accrual categories. 078 * @param actionFrequency One of LMConstants.MAX_BAL_ACTION_FREQ 079 * @return A List of accrualCategoryRuleId's in {@param document}'s leave summary with MAX_BAL_ACTION_FREQUENCY = {@param actionFrequency} 080 * @throws Exception 081 */ 082 /* public Map<String,ArrayList<String>> getEligibleTransfers(CalendarEntries calendarEntry, String principalId) throws Exception; 083 */ 084 public void submitToWorkflow(BalanceTransfer balanceTransfer) throws WorkflowException; 085 086 /** 087 * transfer system scheduled time off 088 * @param balanceTransfer 089 * @return 090 */ 091 public BalanceTransfer transferSsto(BalanceTransfer balanceTransfer); 092 093 public List<BalanceTransfer> getBalanceTransfers(String viewPrincipal, Date beginPeriodDate, Date endPeriodDate); 094 095 }