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