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.impl;
017    
018    import java.io.File;
019    import java.io.FileNotFoundException;
020    import java.io.PrintStream;
021    import java.sql.Date;
022    import java.util.HashMap;
023    import java.util.Iterator;
024    import java.util.Map;
025    import java.util.Set;
026    
027    import org.kuali.kfs.coa.service.BalanceTypeService;
028    import org.kuali.kfs.coa.service.ObjectTypeService;
029    import org.kuali.kfs.coa.service.PriorYearAccountService;
030    import org.kuali.kfs.coa.service.SubFundGroupService;
031    import org.kuali.kfs.gl.GeneralLedgerConstants;
032    import org.kuali.kfs.gl.batch.BalanceForwardRuleHelper;
033    import org.kuali.kfs.gl.batch.NominalActivityClosingHelper;
034    import org.kuali.kfs.gl.batch.dataaccess.YearEndDao;
035    import org.kuali.kfs.gl.batch.service.EncumbranceClosingOriginEntryGenerationService;
036    import org.kuali.kfs.gl.batch.service.YearEndService;
037    import org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException;
038    import org.kuali.kfs.gl.businessobject.Balance;
039    import org.kuali.kfs.gl.businessobject.Encumbrance;
040    import org.kuali.kfs.gl.businessobject.OriginEntryFull;
041    import org.kuali.kfs.gl.dataaccess.EncumbranceDao;
042    import org.kuali.kfs.gl.report.LedgerSummaryReport;
043    import org.kuali.kfs.gl.service.BalanceService;
044    import org.kuali.kfs.gl.service.OriginEntryGroupService;
045    import org.kuali.kfs.gl.service.OriginEntryService;
046    import org.kuali.kfs.sys.KFSConstants;
047    import org.kuali.kfs.sys.KFSKeyConstants;
048    import org.kuali.kfs.sys.service.ReportWriterService;
049    import org.kuali.rice.kns.service.DateTimeService;
050    import org.kuali.rice.kns.service.KualiConfigurationService;
051    import org.kuali.rice.kns.service.ParameterService;
052    import org.kuali.rice.kns.service.PersistenceService;
053    import org.springframework.transaction.annotation.Transactional;
054    
055    /**
056     * This class implements the logic to perform year end tasks.
057     */
058    @Transactional
059    public class YearEndServiceImpl implements YearEndService {
060        private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(YearEndServiceImpl.class);
061    
062        private EncumbranceDao encumbranceDao;
063        private OriginEntryService originEntryService;
064        private OriginEntryGroupService originEntryGroupService;
065        private DateTimeService dateTimeService;
066        private BalanceService balanceService;
067        private BalanceTypeService balanceTypeService;
068        private ObjectTypeService objectTypeService;
069        private ParameterService parameterService;
070        private KualiConfigurationService configurationService;
071        private PriorYearAccountService priorYearAccountService;
072        private SubFundGroupService subFundGroupService;
073        private PersistenceService persistenceService;
074        private YearEndDao yearEndDao;
075        private String batchFileDirectoryName;
076        private EncumbranceClosingOriginEntryGenerationService encumbranceClosingOriginEntryGenerationService;
077        private ReportWriterService nominalActivityClosingReportWriterService;
078        private ReportWriterService balanceForwardReportWriterService;
079        private ReportWriterService encumbranceClosingReportWriterService;
080    
081        public static final String TRANSACTION_DATE_FORMAT_STRING = "yyyy-MM-dd";
082    
083        /**
084         * Constructs a YearEndServiceImpl, and that's about it.
085         */
086        public YearEndServiceImpl() {
087            super();
088        }
089    
090        /**
091         * This class actually generates all the origin entries for nominal activity closing and saves them to the proper origin entry
092         * group. Note: Much (but no longer all) of the original COBOL program this code is based off of is within the comments.
093         * 
094         * @param nominalClosingOriginEntryGroup the origin entry group to save the generated nominal closing entries to
095         * @param nominalClosingJobParameters a map of parameters for the job:
096         * @param nominalClosingCounts various statistical counts
097         * @see org.kuali.kfs.gl.batch.service.YearEndService#closeNominalActivity()
098         */
099        public void closeNominalActivity(String nominalClosingFileName, Map nominalClosingJobParameters) {
100    
101            Integer varFiscalYear = (Integer) nominalClosingJobParameters.get(GeneralLedgerConstants.ColumnNames.UNIVERSITY_FISCAL_YEAR);
102            NominalActivityClosingHelper closingHelper = new NominalActivityClosingHelper(varFiscalYear, (Date) nominalClosingJobParameters.get(GeneralLedgerConstants.ColumnNames.UNIV_DT), parameterService, configurationService);
103            
104            closingHelper.addNominalClosingJobParameters(nominalClosingJobParameters);
105    
106            Map<String, Integer> nominalActivityClosingCounts = new HashMap<String, Integer>();
107            
108            nominalActivityClosingCounts.put("globalReadCount", new Integer(balanceService.countBalancesForFiscalYear(varFiscalYear)));
109            Iterator<Balance> balanceIterator = balanceService.findNominalActivityBalancesForFiscalYear(varFiscalYear);
110    
111            String accountNumberHold = null;
112    
113            boolean selectSw = false;
114    
115            nominalActivityClosingCounts.put("globalSelectCount", new Integer(0));
116            nominalActivityClosingCounts.put("sequenceNumber", new Integer(0));
117            nominalActivityClosingCounts.put("sequenceWriteCount", new Integer(0));
118            nominalActivityClosingCounts.put("sequenceCheckCount", new Integer(0));
119    
120            boolean nonFatalErrorFlag = false;
121    
122            //create files
123            File nominalClosingFile = new File(batchFileDirectoryName + File.separator + nominalClosingFileName);
124            PrintStream nominalClosingPs = null;
125            
126            try {
127                nominalClosingPs = new PrintStream(nominalClosingFile);
128            } catch (FileNotFoundException e) {
129                throw new RuntimeException("nominalClosingFile Files doesn't exist " + nominalClosingFileName);
130            }
131            
132            LedgerSummaryReport ledgerReport = new LedgerSummaryReport();
133            
134            while (balanceIterator.hasNext()) {
135    
136                Balance balance = balanceIterator.next();
137                balance.refreshReferenceObject("option");
138    
139                selectSw = true;
140    
141                try {
142                    if (LOG.isDebugEnabled()) {
143                        LOG.debug("Balance selected.");
144                    }
145                    if (balance.getAccountNumber().equals(accountNumberHold)) {
146                        incrementCount(nominalActivityClosingCounts, "sequenceNumber");
147                    }
148                    else {
149                        nominalActivityClosingCounts.put("sequenceNumber", new Integer(1));
150                    }
151                    incrementCount(nominalActivityClosingCounts, "globalSelectCount");
152                    OriginEntryFull activityEntry = closingHelper.generateActivityEntry(balance, new Integer(1));
153                    originEntryService.createEntry(activityEntry, nominalClosingPs);
154                    ledgerReport.summarizeEntry(activityEntry);
155                    incrementCount(nominalActivityClosingCounts, "sequenceWriteCount");
156                    nominalActivityClosingCounts.put("sequenceCheckCount", new Integer(nominalActivityClosingCounts.get("sequenceWriteCount").intValue()));
157                    if (0 == nominalActivityClosingCounts.get("sequenceCheckCount").intValue() % 1000) {
158                        LOG.info(new StringBuffer("  SEQUENTIAL RECORDS WRITTEN = ").append(nominalActivityClosingCounts.get("sequenceCheckCount")).toString());
159                    }
160                    OriginEntryFull offsetEntry = closingHelper.generateOffset(balance, new Integer(1));           
161                    originEntryService.createEntry(offsetEntry, nominalClosingPs);
162                    ledgerReport.summarizeEntry(offsetEntry);
163                    incrementCount(nominalActivityClosingCounts, "sequenceWriteCount");
164                    nominalActivityClosingCounts.put("sequenceCheckCount", new Integer(nominalActivityClosingCounts.get("sequenceWriteCount").intValue()));
165                    if (0 == nominalActivityClosingCounts.get("sequenceCheckCount").intValue() % 1000) {
166                        LOG.info(new StringBuffer(" ORIGIN ENTRIES INSERTED = ").append(nominalActivityClosingCounts.get("sequenceCheckCount")).toString());
167                    }
168                    if (nominalActivityClosingCounts.get("globalSelectCount").intValue() % 1000 == 0) {
169                        persistenceService.clearCache();
170                    }
171                    accountNumberHold = balance.getAccountNumber();
172                }
173                catch (FatalErrorException fee) {
174                    LOG.warn("Failed to create entry pair for balance.", fee);
175                }
176            }
177            nominalActivityClosingCounts.put("nonFatalCount", closingHelper.getNonFatalErrorCount());
178            nominalClosingPs.close();
179            
180            // now write parameters
181            for (Object jobParameterKeyAsObject : nominalClosingJobParameters.keySet()) {
182                if (jobParameterKeyAsObject != null) {
183                    final String jobParameterKey = jobParameterKeyAsObject.toString();
184                    getNominalActivityClosingReportWriterService().writeParameterLine("%32s %10s", jobParameterKey, nominalClosingJobParameters.get(jobParameterKey));
185                }
186            }
187            
188            // now write statistics
189            getNominalActivityClosingReportWriterService().writeStatisticLine("NUMBER OF GLBL RECORDS READ       %9d", nominalActivityClosingCounts.get("globalReadCount"));
190            getNominalActivityClosingReportWriterService().writeStatisticLine("NUMBER OF GLBL RECORDS SELECTED   %9d", nominalActivityClosingCounts.get("globalSelectCount"));
191            getNominalActivityClosingReportWriterService().writeStatisticLine("NUMBER OF SEQ RECORDS WRITTEN     %9d", nominalActivityClosingCounts.get("sequenceWriteCount"));
192            getNominalActivityClosingReportWriterService().pageBreak();
193            
194            // finally, put a header on the ledger report and write it
195            getNominalActivityClosingReportWriterService().writeSubTitle(configurationService.getPropertyString(KFSKeyConstants.MESSAGE_REPORT_YEAR_END_NOMINAL_ACTIVITY_CLOSING_LEDGER_TITLE_LINE));
196            ledgerReport.writeReport(getNominalActivityClosingReportWriterService());
197        }
198    
199        /**
200         * A method that increments a count within a Map by 1
201         * 
202         * @param counts a Map of count statistics
203         * @param countName the name of the specific count ot update
204         * @return the newly incremented amount
205         */
206        protected int incrementCount(Map<String, Integer> counts, String countName) {
207            Integer value = counts.get(countName);
208            int incremented = value.intValue() + 1;
209            counts.put(countName, new Integer(incremented));
210            return incremented;
211        }
212    
213        /**
214         * This method handles executing the loop over all balances, and generating reports on the balance forwarding process as a
215         * whole. This method delegates all of the specific logic in terms of what balances to forward, according to what criteria, how
216         * origin entries are generated, etc. This relationship makes YearEndServiceImpl and BalanceForwardRuleHelper heavily dependent
217         * upon one another in terms of expected behavior.
218         * 
219         * @param balanceForwardsUnclosedPriorYearAccountGroup the origin entry group to save balance forwarding origin entries with
220         *        open accounts
221         * @param balanceForwardsClosedPriorYearAccountGroup the origin entry group to save balance forwarding origin entries with
222         *        closed accounts
223         * @param balanceForwardRuleHelper the BalanceForwardRuleHelper which holds the important state - the job parameters and
224         *        statistics - for the job to run
225         */
226        public void forwardBalances(String balanceForwardsUnclosedFileName, String balanceForwardsclosedFileName, BalanceForwardRuleHelper balanceForwardRuleHelper) {
227            LOG.debug("forwardBalances() started");
228    
229            // The rule helper maintains the state of the overall processing of the entire
230            // set of year end balances. This state is available via balanceForwardRuleHelper.getState().
231            // The helper and this class (YearEndServiceImpl) are heavily dependent upon one
232            // another in terms of expected behavior and shared responsibilities.
233            balanceForwardRuleHelper.setPriorYearAccountService(priorYearAccountService);
234            balanceForwardRuleHelper.setSubFundGroupService(subFundGroupService);
235            balanceForwardRuleHelper.setOriginEntryService(originEntryService);
236            balanceForwardRuleHelper.getState().setGlobalReadCount(balanceService.countBalancesForFiscalYear(balanceForwardRuleHelper.getClosingFiscalYear()));
237    
238            Balance balance;
239    
240            //create files
241            File unclosedOutputFile = new File(batchFileDirectoryName + File.separator + balanceForwardsUnclosedFileName);
242            File closedOutputFile = new File(batchFileDirectoryName + File.separator + balanceForwardsclosedFileName);
243            PrintStream unclosedPs = null;
244            PrintStream closedPs = null;
245            
246            try {
247                unclosedPs = new PrintStream(unclosedOutputFile);
248                closedPs = new PrintStream(closedOutputFile);
249            } catch (FileNotFoundException e) {
250                throw new RuntimeException("balanceForwards Files don't exist " + balanceForwardsUnclosedFileName + " and " + balanceForwardsclosedFileName);
251            }
252            
253            // do the general forwards
254            Iterator<Balance> generalBalances = balanceService.findGeneralBalancesToForwardForFiscalYear(balanceForwardRuleHelper.getClosingFiscalYear());
255            while (generalBalances.hasNext()) {
256                balance = generalBalances.next();
257                balanceForwardRuleHelper.processGeneralForwardBalance(balance, closedPs, unclosedPs);
258                if (balanceForwardRuleHelper.getState().getGlobalSelectCount() % 1000 == 0) {
259                    persistenceService.clearCache();
260                }
261            }
262    
263            // do the cumulative forwards
264            Iterator<Balance> cumulativeBalances = balanceService.findCumulativeBalancesToForwardForFiscalYear(balanceForwardRuleHelper.getClosingFiscalYear());
265            while (cumulativeBalances.hasNext()) {
266                balance = cumulativeBalances.next();
267                balanceForwardRuleHelper.processCumulativeForwardBalance(balance, closedPs, unclosedPs);
268                if (balanceForwardRuleHelper.getState().getGlobalSelectCount() % 1000 == 0) {
269                    persistenceService.clearCache();
270                }
271            }
272    
273            // write parameters
274            getBalanceForwardReportWriterService().writeParameterLine("%32s %10s", GeneralLedgerConstants.ANNUAL_CLOSING_TRANSACTION_DATE_PARM, balanceForwardRuleHelper.getTransactionDate().toString());
275            getBalanceForwardReportWriterService().writeParameterLine("%32s %10s", GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM, balanceForwardRuleHelper.getClosingFiscalYear().toString());
276            getBalanceForwardReportWriterService().writeParameterLine("%32s %10s", KFSConstants.SystemGroupParameterNames.GL_ANNUAL_CLOSING_DOC_TYPE, balanceForwardRuleHelper.getAnnualClosingDocType());
277            getBalanceForwardReportWriterService().writeParameterLine("%32s %10s", KFSConstants.SystemGroupParameterNames.GL_ORIGINATION_CODE, balanceForwardRuleHelper.getGlOriginationCode());
278            
279            // write statistics
280            getBalanceForwardReportWriterService().writeStatisticLine("NUMBER OF GLBL RECORDS READ....: %10d", balanceForwardRuleHelper.getState().getGlobalReadCount());
281            getBalanceForwardReportWriterService().writeStatisticLine("NUMBER OF GLBL RECORDS SELECTED: %10d", balanceForwardRuleHelper.getState().getGlobalSelectCount());
282            getBalanceForwardReportWriterService().writeStatisticLine("NUMBER OF SEQ RECORDS WRITTEN..: %10d", balanceForwardRuleHelper.getState().getSequenceWriteCount());
283            getBalanceForwardReportWriterService().writeStatisticLine("RECORDS FOR CLOSED ACCOUNTS....: %10d", balanceForwardRuleHelper.getState().getSequenceClosedCount());
284            getBalanceForwardReportWriterService().pageBreak();
285            
286            // write ledger reports
287            getBalanceForwardReportWriterService().writeSubTitle(configurationService.getPropertyString(KFSKeyConstants.MESSAGE_REPORT_YEAR_END_BALANCE_FORWARD_OPEN_ACCOUNT_LEDGER_TITLE_LINE));
288            balanceForwardRuleHelper.writeOpenAccountBalanceForwardLedgerSummaryReport(getBalanceForwardReportWriterService());
289            getBalanceForwardReportWriterService().writeNewLines(4);
290            getBalanceForwardReportWriterService().writeSubTitle(configurationService.getPropertyString(KFSKeyConstants.MESSAGE_REPORT_YEAR_END_BALANCE_FORWARD_CLOSED_ACCOUNT_LEDGER_TITLE_LINE));
291            balanceForwardRuleHelper.writeClosedAccountBalanceForwardLedgerSummaryReport(getBalanceForwardReportWriterService());
292        }
293    
294        /**
295         * Create origin entries to carry forward all open encumbrances from the closing fiscal year into the opening fiscal year.
296         * 
297         * @param originEntryGroup the origin entry group where generated origin entries should be saved
298         * @param jobParameters the parameters necessary to run this job: the fiscal year to close and the university date the job was
299         *        run
300         * @param forwardEncumbrancesCounts the statistical counts generated by this job
301         */
302        public void forwardEncumbrances(String encumbranceForwardFileName, Map jobParameters, Map<String, Integer> counts) {
303            LOG.debug("forwardEncumbrances() started");
304    
305            // counters for the report
306            counts.put("encumbrancesRead", new Integer(0));
307            counts.put("encumbrancesSelected", new Integer(0));
308            counts.put("originEntriesWritten", new Integer(0));
309            
310            LedgerSummaryReport forwardEncumbranceLedgerReport = new LedgerSummaryReport();
311    
312            //create files
313            File encumbranceForwardFile = new File(batchFileDirectoryName + File.separator + encumbranceForwardFileName);
314            PrintStream encumbranceForwardPs = null;
315            
316            try {
317                encumbranceForwardPs = new PrintStream(encumbranceForwardFile);
318            } catch (FileNotFoundException e) {
319                throw new RuntimeException("nominalClosingFile Files doesn't exist " + encumbranceForwardFileName);
320            }
321    
322            // encumbranceDao will return all encumbrances for the fiscal year sorted properly by all of the appropriate keys.
323            Iterator encumbranceIterator = encumbranceDao.getEncumbrancesToClose((Integer) jobParameters.get(GeneralLedgerConstants.ColumnNames.UNIVERSITY_FISCAL_YEAR));
324            while (encumbranceIterator.hasNext()) {
325    
326                Encumbrance encumbrance = (Encumbrance) encumbranceIterator.next();
327                incrementCount(counts, "encumbrancesRead");
328                
329                // if the encumbrance is not completely relieved
330                if (getEncumbranceClosingOriginEntryGenerationService().shouldForwardEncumbrance(encumbrance)) {
331    
332                    incrementCount(counts, "encumbrancesSelected");
333    
334                    // build a pair of origin entries to carry forward the encumbrance.
335                    OriginEntryOffsetPair beginningBalanceEntryPair = getEncumbranceClosingOriginEntryGenerationService().createBeginningBalanceEntryOffsetPair(encumbrance, (Integer) jobParameters.get(GeneralLedgerConstants.ColumnNames.UNIVERSITY_FISCAL_YEAR), (Date) jobParameters.get(GeneralLedgerConstants.ColumnNames.UNIV_DT));
336    
337                    if (beginningBalanceEntryPair.isFatalErrorFlag()) {
338    
339                        continue;
340    
341                    }
342                    else {
343                        // save the entries.
344                        originEntryService.createEntry(beginningBalanceEntryPair.getEntry(), encumbranceForwardPs);
345                        forwardEncumbranceLedgerReport.summarizeEntry(beginningBalanceEntryPair.getEntry());
346                        originEntryService.createEntry(beginningBalanceEntryPair.getOffset(), encumbranceForwardPs);
347                        forwardEncumbranceLedgerReport.summarizeEntry(beginningBalanceEntryPair.getOffset());
348                        incrementCount(counts, "originEntriesWritten");
349                        incrementCount(counts, "originEntriesWritten");
350                        if (0 == counts.get("originEntriesWritten").intValue() % 1000) {
351                            LOG.info(new StringBuffer(" ORIGIN ENTRIES INSERTED = ").append(counts.get("originEntriesWritten")).toString());
352                        }
353                    }
354    
355                    // handle cost sharing if appropriate.
356                    boolean isEligibleForCostShare = false;
357                    try {
358                        isEligibleForCostShare = this.getEncumbranceClosingOriginEntryGenerationService().shouldForwardCostShareForEncumbrance(beginningBalanceEntryPair.getEntry(), beginningBalanceEntryPair.getOffset(), encumbrance, beginningBalanceEntryPair.getEntry().getFinancialObjectTypeCode());
359                    }
360                    catch (FatalErrorException fee) {
361                        LOG.info(fee.getMessage());
362                    }
363    
364                    if (isEligibleForCostShare) {
365                        // build and save an additional pair of origin entries to carry forward the encumbrance.
366                        OriginEntryOffsetPair costShareBeginningBalanceEntryPair = getEncumbranceClosingOriginEntryGenerationService().createCostShareBeginningBalanceEntryOffsetPair(encumbrance, (Date) jobParameters.get(GeneralLedgerConstants.ColumnNames.UNIV_DT));
367                        if (!costShareBeginningBalanceEntryPair.isFatalErrorFlag()) {
368                            // save the cost share entries.
369                            originEntryService.createEntry(costShareBeginningBalanceEntryPair.getEntry(), encumbranceForwardPs);
370                            forwardEncumbranceLedgerReport.summarizeEntry(costShareBeginningBalanceEntryPair.getEntry());
371                            originEntryService.createEntry(costShareBeginningBalanceEntryPair.getOffset(), encumbranceForwardPs);
372                            forwardEncumbranceLedgerReport.summarizeEntry(costShareBeginningBalanceEntryPair.getOffset());
373                            incrementCount(counts, "originEntriesWritten");
374                            incrementCount(counts, "originEntriesWritten");
375                            if (0 == counts.get("originEntriesWritten").intValue() % 1000) {
376                                LOG.info(new StringBuffer(" ORIGIN ENTRIES INSERTED = ").append(counts.get("originEntriesWritten")).toString());
377                            }
378                        }
379                    }
380                }
381                if (counts.get("encumbrancesSelected").intValue() % 1000 == 0) {
382                    persistenceService.clearCache();
383                }
384            }
385            encumbranceForwardPs.close();
386            
387            // write job parameters
388            for (Object jobParameterKeyAsObject : jobParameters.keySet()) {
389                if (jobParameterKeyAsObject != null) {
390                    final String jobParameterKey = jobParameterKeyAsObject.toString();
391                    getEncumbranceClosingReportWriterService().writeParameterLine("%32s %10s", jobParameterKey, jobParameters.get(jobParameterKey));
392                }
393            }
394            
395            // write statistics
396            getEncumbranceClosingReportWriterService().writeStatisticLine("NUMBER OF ENCUMBRANCE RECORDS READ:     %10d", counts.get("encumbrancesRead"));
397            getEncumbranceClosingReportWriterService().writeStatisticLine("NUMBER OF ENCUMBRANCE RECORDS SELECTED  %10d", counts.get("encumbrancesSelected"));
398            getEncumbranceClosingReportWriterService().writeStatisticLine("NUMBER OF SEQ RECORDS WRITTEN           %10d", counts.get("originEntriesWritten"));
399            getEncumbranceClosingReportWriterService().pageBreak();
400            
401            // write ledger summary report
402            getEncumbranceClosingReportWriterService().writeSubTitle(configurationService.getPropertyString(KFSKeyConstants.MESSAGE_REPORT_YEAR_END_ENCUMBRANCE_FORWARDS_LEDGER_TITLE_LINE));
403            forwardEncumbranceLedgerReport.writeReport(getEncumbranceClosingReportWriterService());
404        }
405    
406        /**
407         * @param balanceFiscalYear the fiscal year to find balances encumbrances for
408         * @see org.kuali.kfs.gl.batch.service.YearEndService#logAllMissingPriorYearAccounts(java.lang.Integer)
409         */
410        public void logAllMissingPriorYearAccounts(Integer fiscalYear) {
411            Set<Map<String, String>> missingPriorYearAccountKeys = yearEndDao.findKeysOfMissingPriorYearAccountsForBalances(fiscalYear);
412            missingPriorYearAccountKeys.addAll(yearEndDao.findKeysOfMissingPriorYearAccountsForOpenEncumbrances(fiscalYear));
413            for (Map<String, String> key : missingPriorYearAccountKeys) {
414                LOG.info("PRIOR YEAR ACCOUNT MISSING FOR " + key.get("chartOfAccountsCode") + "-" + key.get("accountNumber"));
415            }
416        }
417    
418        /**
419         * @param balanceFiscalYear the fiscal year to find balances encumbrances for
420         * @see org.kuali.kfs.gl.batch.service.YearEndService#logAllMissingSubFundGroups(java.lang.Integer)
421         */
422        public void logAllMissingSubFundGroups(Integer fiscalYear) {
423            Set missingSubFundGroupKeys = yearEndDao.findKeysOfMissingSubFundGroupsForBalances(fiscalYear);
424            missingSubFundGroupKeys.addAll(yearEndDao.findKeysOfMissingSubFundGroupsForOpenEncumbrances(fiscalYear));
425            for (Object key : missingSubFundGroupKeys) {
426                LOG.info("SUB FUND GROUP MISSING FOR " + (String) ((Map) key).get("subFundGroupCode"));
427            }
428    
429        }
430    
431        /**
432         * Sets the encumbranceDao attribute, allowing the injection of an implementation of the data access object that uses a specific
433         * O/R mechanism.
434         * 
435         * @param encumbranceDao the implementation of encumbranceDao to set
436         * @see org.kuali.kfs.gl.dataaccess.EncumbranceDao
437         */
438        public void setEncumbranceDao(EncumbranceDao encumbranceDao) {
439            this.encumbranceDao = encumbranceDao;
440        }
441    
442        /**
443         * Sets the originEntryService attribute, allowing the injection of an implementation of that service
444         * 
445         * @param originEntryService the implementation of originEntryService to set
446         * @see org.kuali.kfs.gl.service.OriginEntryService
447         */
448        public void setOriginEntryService(OriginEntryService originEntryService) {
449            this.originEntryService = originEntryService;
450        }
451    
452        public void setDateTimeService(DateTimeService dateTimeService) {
453            this.dateTimeService = dateTimeService;
454        }
455    
456        public void setOriginEntryGroupService(OriginEntryGroupService originEntryGroupService) {
457            this.originEntryGroupService = originEntryGroupService;
458        }
459    
460        public void setBalanceService(BalanceService balanceService) {
461            this.balanceService = balanceService;
462        }
463    
464        public void setBalanceTypeService(BalanceTypeService balanceTypeService) {
465            this.balanceTypeService = balanceTypeService;
466        }
467    
468        public void setObjectTypeService(ObjectTypeService objectTypeService) {
469            this.objectTypeService = objectTypeService;
470        }
471    
472    
473        public void setParameterService(ParameterService parameterService) {
474            this.parameterService = parameterService;
475        }
476    
477        public void setPriorYearAccountService(PriorYearAccountService priorYearAccountService) {
478            this.priorYearAccountService = priorYearAccountService;
479        }
480    
481        public void setSubFundGroupService(SubFundGroupService subFundGroupService) {
482            this.subFundGroupService = subFundGroupService;
483        }
484    
485        /**
486         * Sets the persistenceService attribute value.
487         * 
488         * @param persistenceService The persistenceService to set.
489         */
490        public void setPersistenceService(PersistenceService persistenceService) {
491            this.persistenceService = persistenceService;
492        }
493    
494        public void setYearEndDao(YearEndDao yearEndDao) {
495            this.yearEndDao = yearEndDao;
496        }
497    
498        public void setConfigurationService(KualiConfigurationService configurationService) {
499            this.configurationService = configurationService;
500        }
501    
502        public void setBatchFileDirectoryName(String batchFileDirectoryName) {
503            this.batchFileDirectoryName = batchFileDirectoryName;
504        }
505    
506        /**
507         * Gets the encumbranceClosingOriginEntryGenerationService attribute. 
508         * @return Returns the encumbranceClosingOriginEntryGenerationService.
509         */
510        public EncumbranceClosingOriginEntryGenerationService getEncumbranceClosingOriginEntryGenerationService() {
511            return encumbranceClosingOriginEntryGenerationService;
512        }
513    
514        /**
515         * Sets the encumbranceClosingOriginEntryGenerationService attribute value.
516         * @param encumbranceClosingOriginEntryGenerationService The encumbranceClosingOriginEntryGenerationService to set.
517         */
518        public void setEncumbranceClosingOriginEntryGenerationService(EncumbranceClosingOriginEntryGenerationService encumbranceClosingOriginEntryGenerationService) {
519            this.encumbranceClosingOriginEntryGenerationService = encumbranceClosingOriginEntryGenerationService;
520        }
521    
522        /**
523         * Gets the nominalActivityClosingReportWriterService attribute. 
524         * @return Returns the nominalActivityClosingReportWriterService.
525         */
526        public ReportWriterService getNominalActivityClosingReportWriterService() {
527            return nominalActivityClosingReportWriterService;
528        }
529    
530        /**
531         * Sets the nominalActivityClosingReportWriterService attribute value.
532         * @param nominalActivityClosingReportWriterService The nominalActivityClosingReportWriterService to set.
533         */
534        public void setNominalActivityClosingReportWriterService(ReportWriterService nominalActivityClosingReportWriterService) {
535            this.nominalActivityClosingReportWriterService = nominalActivityClosingReportWriterService;
536        }
537    
538        /**
539         * Gets the balanceForwardReportWriterService attribute. 
540         * @return Returns the balanceForwardReportWriterService.
541         */
542        public ReportWriterService getBalanceForwardReportWriterService() {
543            return balanceForwardReportWriterService;
544        }
545    
546        /**
547         * Sets the balanceForwardReportWriterService attribute value.
548         * @param balanceForwardReportWriterService The balanceForwardReportWriterService to set.
549         */
550        public void setBalanceForwardReportWriterService(ReportWriterService balanceForwardReportWriterService) {
551            this.balanceForwardReportWriterService = balanceForwardReportWriterService;
552        }
553    
554        /**
555         * Gets the encumbranceClosingReportWriterService attribute. 
556         * @return Returns the encumbranceClosingReportWriterService.
557         */
558        public ReportWriterService getEncumbranceClosingReportWriterService() {
559            return encumbranceClosingReportWriterService;
560        }
561    
562        /**
563         * Sets the encumbranceClosingReportWriterService attribute value.
564         * @param encumbranceClosingReportWriterService The encumbranceClosingReportWriterService to set.
565         */
566        public void setEncumbranceClosingReportWriterService(ReportWriterService encumbranceClosingReportWriterService) {
567            this.encumbranceClosingReportWriterService = encumbranceClosingReportWriterService;
568        }
569    }