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