001/*
002 * Copyright 2009 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 */
016package org.kuali.ole.gl.batch.service;
017
018import java.sql.Date;
019
020import org.kuali.ole.gl.batch.service.impl.OriginEntryOffsetPair;
021import org.kuali.ole.gl.batch.service.impl.exception.FatalErrorException;
022import org.kuali.ole.gl.businessobject.Encumbrance;
023import org.kuali.ole.gl.businessobject.OriginEntryFull;
024
025/**
026 * Service which generates encumbrance closing origin entries
027 */
028public interface EncumbranceClosingOriginEntryGenerationService {
029    /**
030     * Create a pair of cost share entries, one explicit and one offset to carry forward an encumbrance after validating the
031     * encumbrance.
032     * 
033     * @param encumbrance the encumbrance to create origin entry and offset for
034     * @param transactionDate the date all origin entries should have as their transaction date
035     * @return a cost share entry/offset pair to carry forward the given encumbrance.
036     */
037    public abstract OriginEntryOffsetPair createCostShareBeginningBalanceEntryOffsetPair(Encumbrance encumbrance, Date transactionDate);
038    
039    /**
040     * Create a pair of OriginEntries, one explicit and one offset to carry forward an encumbrance.
041     * 
042     * @param encumbrance the encumbrance to create origin entries for
043     * @param closingFiscalYear the fiscal year that's closing
044     * @param transactionDate the transaction date these entries should have
045     * @return a entry/offset pair for the given encumbrance
046     */
047    public abstract OriginEntryOffsetPair createBeginningBalanceEntryOffsetPair(Encumbrance encumbrance, Integer closingFiscalYear, Date transactionDate);
048    
049    /**
050     * Determine whether or not an encumbrance should be carried forward from one fiscal year to the next.
051     * 
052     * @param encumbrance the encumbrance to qualify
053     * @return true if the encumbrance should be rolled forward from the closing fiscal year to the opening fiscal year.
054     */
055    public abstract boolean shouldForwardEncumbrance(Encumbrance encumbrance);
056    
057    /**
058     * Do some validation and make sure that the encumbrance A21SubAccount is a cost share sub-account.
059     * 
060     * @param entry not used in this implementation
061     * @param offset not used in this implementation
062     * @param encumbrance the encumbrance whose A21SubAccount must be qualified
063     * @param objectTypeCode the object type code of the generated entries
064     * @return true if the encumbrance is eligible for cost share.
065     * @throws FatalErrorException thrown if a given A21SubAccount, SubFundGroup, or PriorYearAccount record is not found in the database
066     */
067    public abstract boolean shouldForwardCostShareForEncumbrance(OriginEntryFull entry, OriginEntryFull offset, Encumbrance encumbrance, String objectTypeCode) throws FatalErrorException;
068    
069    /**
070     * Determine whether or not the encumbrance has been fully relieved.
071     * 
072     * @param encumbrance the encumbrance to qualify
073     * @return true if the amount closed on the encumbrance is NOT equal to the amount of the encumbrance itself, e.g. if the
074     *         encumbrance has not yet been paid off.
075     */
076    public abstract boolean isEncumbranceClosed(Encumbrance encumbrance);
077}