001 /*
002 * Copyright 2011 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.kfs.gl.batch.service;
017
018 import java.io.PrintStream;
019 import java.util.Iterator;
020 import java.util.List;
021 import java.util.Map;
022
023 import org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException;
024 import org.kuali.kfs.gl.businessobject.Balance;
025 import org.kuali.kfs.gl.businessobject.OriginEntryFull;
026 import org.kuali.kfs.sys.service.ReportWriterService;
027
028 public interface OrganizationReversionProcess {
029 /**
030 * Runs the organization reversion process.
031 * @param jobParameters the parameters used in the process
032 * @param organizationReversionCounts a Map of named statistics generated by running the process
033 */
034 public abstract void organizationReversionProcess(Map jobParameters, Map<String, Integer> organizationReversionCounts);
035
036 /**
037 * This method initializes several properties needed for the process to run correctly
038 */
039 public abstract void initializeProcess();
040
041 /**
042 * Given a list of balances, this method generates the origin entries for the organization reversion/carry forward process, and saves those
043 * to an initialized origin entry group
044 *
045 * @param balances an iterator of balances to process; each balance returned by the iterator will be processed by this method
046 */
047 public abstract void processBalances(Iterator<Balance> balances);
048
049 /**
050 * This method determines which origin entries (reversion, cash reversion, or carry forward) need to be generated for the current unit of work,
051 * and then delegates to the origin entry generation methods to create those entries
052 *
053 * @return a list of OriginEntries which need to be written
054 * @throws FatalErrorException thrown if object codes are missing in any of the generation methods
055 */
056 public abstract List<OriginEntryFull> generateOutputOriginEntries() throws FatalErrorException;
057
058 /**
059 * This method generates cash reversion origin entries for the current organization reversion, and adds them to the given list
060 *
061 * @param originEntriesToWrite a list of OriginEntryFulls to stick generated origin entries into
062 * @throws FatalErrorException thrown if an origin entry's object code can't be found
063 */
064 public abstract void generateCashReversions(List<OriginEntryFull> originEntriesToWrite) throws FatalErrorException;
065
066 /**
067 * Generates carry forward origin entries on a category by category basis (if the organization reversion record asks for that), assuming carry
068 * forwards are required for the current unit of work
069 *
070 * @param originEntriesToWrite a list of origin entries to write, which any generated origin entries should be added to
071 * @throws FatalErrorException thrown if an object code cannot be found
072 */
073 public abstract void generateMany(List<OriginEntryFull> originEntriesToWrite) throws FatalErrorException;
074
075 /**
076 * If carry forwards need to be generated for this unit of work, this method will generate the origin entries to accomplish those object codes.
077 * Note: this will only be called if the organization reversion record tells the process to munge all carry forwards for all categories
078 * together; if the organization reversion record does not call for such a thing, then generateMany will be called
079 *
080 * @param originEntriesToWrite a list of origin entries to write, that any generated origin entries should be added to
081 * @throws FatalErrorException thrown if the current object code can't be found in the database
082 */
083 public abstract void generateCarryForwards(List<OriginEntryFull> originEntriesToWrite) throws FatalErrorException;
084
085 /**
086 * If reversions are necessary, this will generate the origin entries for those reversions
087 *
088 * @param originEntriesToWrite the list of origin entries to add reversions into
089 * @throws FatalErrorException thrown if object code if the entry can't be found
090 */
091 public abstract void generateReversions(List<OriginEntryFull> originEntriesToWrite) throws FatalErrorException;
092
093 /**
094 * This method calculates the totals for a given unit of work's reversion
095 *
096 * @throws FatalErrorException
097 */
098 public abstract void calculateTotals() throws FatalErrorException;
099
100 /**
101 * Writes out the encapsulated origin entry ledger report to the given reportWriterService
102 * @param reportWriterService the report to write the ledger summary report to
103 */
104 public abstract void writeLedgerSummaryReport(ReportWriterService reportWriterService);
105
106 /**
107 * Sets the holdGeneratedOriginEntries attribute value.
108 *
109 * @param holdGeneratedOriginEntries The holdGeneratedOriginEntries to set.
110 */
111 public abstract void setHoldGeneratedOriginEntries(boolean holdGeneratedOriginEntries);
112
113 /**
114 * Gets the generatedOriginEntries attribute.
115 *
116 * @return Returns the generatedOriginEntries.
117 */
118 public abstract List<OriginEntryFull> getGeneratedOriginEntries();
119
120 /**
121 * Returns the total number of balances for the previous fiscal year
122 *
123 * @return the total number of balances for the previous fiscal year
124 */
125 public abstract int getBalancesRead();
126
127 /**
128 * Returns the total number of balances selected for inclusion in this process
129 *
130 * @return the total number of balances selected for inclusion in this process
131 */
132 public abstract int getBalancesSelected();
133 }