Source Code Cross Referenced for ReportServiceImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » gl » service » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » org.kuali.module.gl.service.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright 2006-2007 The Kuali Foundation.
0003:         * 
0004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
0005:         * you may not use this file except in compliance with the License.
0006:         * You may obtain a copy of the License at
0007:         * 
0008:         * http://www.opensource.org/licenses/ecl1.php
0009:         * 
0010:         * Unless required by applicable law or agreed to in writing, software
0011:         * distributed under the License is distributed on an "AS IS" BASIS,
0012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013:         * See the License for the specific language governing permissions and
0014:         * limitations under the License.
0015:         */
0016:        package org.kuali.module.gl.service.impl;
0017:
0018:        import java.io.FileOutputStream;
0019:        import java.text.DecimalFormat;
0020:        import java.text.SimpleDateFormat;
0021:        import java.util.ArrayList;
0022:        import java.util.Collection;
0023:        import java.util.Collections;
0024:        import java.util.Comparator;
0025:        import java.util.Date;
0026:        import java.util.HashMap;
0027:        import java.util.Iterator;
0028:        import java.util.List;
0029:        import java.util.Map;
0030:
0031:        import org.kuali.core.service.DateTimeService;
0032:        import org.kuali.core.service.KualiConfigurationService;
0033:        import org.kuali.core.service.PersistenceService;
0034:        import org.kuali.kfs.KFSConstants;
0035:        import org.kuali.kfs.bo.Options;
0036:        import org.kuali.kfs.service.OptionsService;
0037:        import org.kuali.module.gl.batch.poster.PostTransaction;
0038:        import org.kuali.module.gl.bo.CorrectionChange;
0039:        import org.kuali.module.gl.bo.CorrectionChangeGroup;
0040:        import org.kuali.module.gl.bo.CorrectionCriteria;
0041:        import org.kuali.module.gl.bo.ExpenditureTransaction;
0042:        import org.kuali.module.gl.bo.OriginEntryGroup;
0043:        import org.kuali.module.gl.bo.SufficientFundRebuild;
0044:        import org.kuali.module.gl.bo.Transaction;
0045:        import org.kuali.module.gl.document.CorrectionDocument;
0046:        import org.kuali.module.gl.service.BalanceService;
0047:        import org.kuali.module.gl.service.CorrectionDocumentService;
0048:        import org.kuali.module.gl.service.OriginEntryGroupService;
0049:        import org.kuali.module.gl.service.OriginEntryService;
0050:        import org.kuali.module.gl.service.PosterService;
0051:        import org.kuali.module.gl.service.ReportService;
0052:        import org.kuali.module.gl.service.ReversalService;
0053:        import org.kuali.module.gl.service.impl.scrubber.DemergerReportData;
0054:        import org.kuali.module.gl.service.impl.scrubber.ScrubberReportData;
0055:        import org.kuali.module.gl.util.BalanceEncumbranceReport;
0056:        import org.kuali.module.gl.util.BalanceReport;
0057:        import org.kuali.module.gl.util.ExpenditureTransactionReport;
0058:        import org.kuali.module.gl.util.GeneralLedgerPendingEntryReport;
0059:        import org.kuali.module.gl.util.LedgerEntryHolder;
0060:        import org.kuali.module.gl.util.LedgerReport;
0061:        import org.kuali.module.gl.util.Message;
0062:        import org.kuali.module.gl.util.PosterOutputSummaryReport;
0063:        import org.kuali.module.gl.util.Summary;
0064:        import org.kuali.module.gl.util.TransactionListingReport;
0065:        import org.kuali.module.gl.util.TransactionReport;
0066:        import org.kuali.module.gl.util.YearEndTransactionReport;
0067:        import org.kuali.module.gl.web.optionfinder.SearchOperatorsFinder;
0068:        import org.springframework.transaction.annotation.Transactional;
0069:
0070:        import com.lowagie.text.Document;
0071:        import com.lowagie.text.ExceptionConverter;
0072:        import com.lowagie.text.Font;
0073:        import com.lowagie.text.FontFactory;
0074:        import com.lowagie.text.PageSize;
0075:        import com.lowagie.text.Phrase;
0076:        import com.lowagie.text.Rectangle;
0077:        import com.lowagie.text.pdf.PdfPCell;
0078:        import com.lowagie.text.pdf.PdfPTable;
0079:        import com.lowagie.text.pdf.PdfPageEventHelper;
0080:        import com.lowagie.text.pdf.PdfWriter;
0081:
0082:        /**
0083:         * The base implementation of ReportService
0084:         */
0085:        @Transactional
0086:        public class ReportServiceImpl implements  ReportService {
0087:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
0088:                    .getLogger(ReportServiceImpl.class);
0089:
0090:            String reportsDirectory;
0091:            private OriginEntryService originEntryService;
0092:            private OriginEntryGroupService originEntryGroupService;
0093:            private DateTimeService dateTimeService;
0094:            private BalanceService balanceService;
0095:            private OptionsService optionsService;
0096:            private ReversalService reversalService;
0097:            private KualiConfigurationService kualiConfigurationService;
0098:            private PersistenceService persistenceService;
0099:
0100:            public static final String DATE_FORMAT_STRING = "yyyyMMdd_HHmmss";
0101:
0102:            /**
0103:             * Constructs a ReportServiceImpl instance
0104:             */
0105:            public ReportServiceImpl() {
0106:                super ();
0107:            }
0108:
0109:            /**
0110:             * initializes this service
0111:             */
0112:            public void init() {
0113:                reportsDirectory = kualiConfigurationService
0114:                        .getPropertyString(KFSConstants.REPORTS_DIRECTORY_KEY);
0115:            }
0116:
0117:            /**
0118:             * Generates a ledger summary of pending entries, created by NightlyOut
0119:             * 
0120:             * @param runDate the date this nightly out process was run on
0121:             * @param group the group of origin entries copied from pending entries
0122:             * @see org.kuali.module.gl.service.ReportService#generatePendingEntryReport(java.util.Date)
0123:             */
0124:            public void generatePendingEntryReport(Date runDate,
0125:                    OriginEntryGroup group) {
0126:                LOG.debug("generatePendingEntryReport() started");
0127:
0128:                GeneralLedgerPendingEntryReport glper = new GeneralLedgerPendingEntryReport();
0129:                SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_STRING);
0130:                glper.generateReport(runDate, reportsDirectory, sdf,
0131:                        originEntryService.getEntriesByGroupReportOrder(group));
0132:            }
0133:
0134:            /**
0135:             * Generates a report on all pending entries, created by Nightly out
0136:             * 
0137:             * @param runDate the date this nightly out process was run on
0138:             * @param group the group of origin entries copied from pending entries
0139:             * @see org.kuali.module.gl.service.ReportService#generatePendingEntryLedgerSummaryReport(java.util.Date,
0140:             *      org.kuali.module.gl.bo.OriginEntryGroup)
0141:             */
0142:            public void generatePendingEntryLedgerSummaryReport(Date runDate,
0143:                    OriginEntryGroup group) {
0144:                LOG.debug("generatePendingEntryLedgerSummaryReport() started");
0145:
0146:                LedgerReport ledgerReport = new LedgerReport();
0147:                LedgerEntryHolder ledgerEntries = new LedgerEntryHolder();
0148:
0149:                Collection g = new ArrayList();
0150:                g.add(group);
0151:
0152:                ledgerEntries = originEntryService.getSummaryByGroupId(g);
0153:
0154:                ledgerReport.generateReport(ledgerEntries, runDate,
0155:                        "GLPE Statistics Report", "glpe_ledger",
0156:                        reportsDirectory);
0157:            }
0158:
0159:            /**
0160:             * Generates the Sufficient Funds Summary Report
0161:             * 
0162:             * @param reportErrors the errors generated during the sufficient funds process
0163:             * @param reportSummary a List of summary data generated by the sufficient funds
0164:             * @param runDate the date of the sufficient funds rebuild process that is being reported
0165:             * @param mode not really used
0166:             * @see org.kuali.module.gl.service.ReportService#generateSufficientFundsReport(java.util.Map, java.util.List, java.util.Date,
0167:             *      int)
0168:             */
0169:            public void generateSufficientFundsReport(Map reportErrors,
0170:                    List reportSummary, Date runDate, int mode) {
0171:                LOG.debug("generateSufficientFundsReport() started");
0172:
0173:                String title = "Sufficient Funds Report ";
0174:                String fileprefix = "sufficientFunds";
0175:
0176:                Font headerFont = FontFactory.getFont(FontFactory.COURIER, 8,
0177:                        Font.BOLD);
0178:                Font textFont = FontFactory.getFont(FontFactory.COURIER, 8,
0179:                        Font.NORMAL);
0180:
0181:                Document document = new Document(PageSize.A4.rotate());
0182:
0183:                SfPageHelper helper = new SfPageHelper();
0184:                helper.runDate = runDate;
0185:                helper.headerFont = headerFont;
0186:                helper.title = title;
0187:
0188:                try {
0189:                    String filename = reportsDirectory + "/" + fileprefix + "_";
0190:                    SimpleDateFormat sdf = new SimpleDateFormat(
0191:                            DATE_FORMAT_STRING);
0192:
0193:                    filename = filename + sdf.format(runDate);
0194:                    filename = filename + ".pdf";
0195:                    PdfWriter writer = PdfWriter.getInstance(document,
0196:                            new FileOutputStream(filename));
0197:                    writer.setPageEvent(helper);
0198:
0199:                    document.open();
0200:
0201:                    // Sort what we get
0202:                    Collections.sort(reportSummary);
0203:
0204:                    float[] summaryWidths = { 90, 10 };
0205:                    PdfPTable summary = new PdfPTable(summaryWidths);
0206:                    summary.setWidthPercentage(40);
0207:                    PdfPCell cell = new PdfPCell(new Phrase(
0208:                            "S T A T I S T I C S", headerFont));
0209:                    cell.setColspan(2);
0210:                    cell.setBorder(Rectangle.NO_BORDER);
0211:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
0212:                    summary.addCell(cell);
0213:
0214:                    for (Iterator iter = reportSummary.iterator(); iter
0215:                            .hasNext();) {
0216:                        Summary s = (Summary) iter.next();
0217:
0218:                        cell = new PdfPCell(new Phrase(s.getDescription(),
0219:                                textFont));
0220:                        cell.setBorder(Rectangle.NO_BORDER);
0221:                        summary.addCell(cell);
0222:
0223:                        if ("".equals(s.getDescription())) {
0224:                            cell = new PdfPCell(new Phrase("", textFont));
0225:                            cell.setBorder(Rectangle.NO_BORDER);
0226:                            summary.addCell(cell);
0227:                        } else {
0228:                            DecimalFormat nf = new DecimalFormat("###,###,##0");
0229:                            cell = new PdfPCell(new Phrase(nf.format(s
0230:                                    .getCount()), textFont));
0231:                            cell.setBorder(Rectangle.NO_BORDER);
0232:                            cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
0233:                            summary.addCell(cell);
0234:                        }
0235:                    }
0236:                    cell = new PdfPCell(new Phrase(""));
0237:                    cell.setColspan(2);
0238:                    cell.setBorder(Rectangle.NO_BORDER);
0239:                    summary.addCell(cell);
0240:
0241:                    document.add(summary);
0242:
0243:                    if (reportErrors != null && reportErrors.size() > 0) {
0244:                        float[] warningWidths = { 5, 12, 12, 53 };
0245:                        PdfPTable warnings = new PdfPTable(warningWidths);
0246:                        warnings.setHeaderRows(2);
0247:                        warnings.setWidthPercentage(100);
0248:                        cell = new PdfPCell(new Phrase("W A R N I N G S",
0249:                                headerFont));
0250:                        cell.setColspan(4);
0251:                        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
0252:                        warnings.addCell(cell);
0253:
0254:                        // Add headers
0255:                        cell = new PdfPCell(new Phrase("COA", headerFont));
0256:                        warnings.addCell(cell);
0257:                        cell = new PdfPCell(new Phrase("Account/Object Code",
0258:                                headerFont));
0259:                        warnings.addCell(cell);
0260:                        cell = new PdfPCell(new Phrase("Account/Object Type",
0261:                                headerFont));
0262:                        warnings.addCell(cell);
0263:                        cell = new PdfPCell(new Phrase("Warning", headerFont));
0264:                        warnings.addCell(cell);
0265:
0266:                        for (Iterator errorIter = reportErrors.keySet()
0267:                                .iterator(); errorIter.hasNext();) {
0268:                            SufficientFundRebuild sfrb = (SufficientFundRebuild) errorIter
0269:                                    .next();
0270:                            boolean first = true;
0271:
0272:                            List errors = (List) reportErrors.get(sfrb);
0273:                            for (Iterator listIter = errors.iterator(); listIter
0274:                                    .hasNext();) {
0275:                                String msg = (String) listIter.next();
0276:
0277:                                if (first) {
0278:                                    first = false;
0279:                                    cell = new PdfPCell(
0280:                                            new Phrase(sfrb
0281:                                                    .getChartOfAccountsCode(),
0282:                                                    textFont));
0283:                                    warnings.addCell(cell);
0284:                                    cell = new PdfPCell(
0285:                                            new Phrase(
0286:                                                    sfrb
0287:                                                            .getAccountNumberFinancialObjectCode(),
0288:                                                    textFont));
0289:                                    warnings.addCell(cell);
0290:                                    cell = new PdfPCell(
0291:                                            new Phrase(
0292:                                                    sfrb
0293:                                                            .getAccountFinancialObjectTypeCode(),
0294:                                                    textFont));
0295:                                    warnings.addCell(cell);
0296:                                } else {
0297:                                    cell = new PdfPCell(
0298:                                            new Phrase("", textFont));
0299:                                    cell.setColspan(3);
0300:                                    warnings.addCell(cell);
0301:                                }
0302:                                cell = new PdfPCell(new Phrase(msg, textFont));
0303:                                warnings.addCell(cell);
0304:                            }
0305:                        }
0306:                        document.add(warnings);
0307:                    }
0308:                } catch (Exception de) {
0309:                    LOG.error("generateReport() Error creating PDF report", de);
0310:                    throw new RuntimeException("Report Generation Failed");
0311:                }
0312:
0313:                document.close();
0314:            }
0315:
0316:            /**
0317:             * Generates the Poster Statistics report
0318:             * 
0319:             * @param executionDate the actual time of poster execution
0320:             * @param runDate the time assumed by the poster (sometimes the poster can use a transaction date back
0321:             * @param reportSummary a Map of statistical counts generated by the poster run being reported on
0322:             * @param transactionPosters the list of posting algorithms used during the poster run
0323:             * @param reportErrors a Map of transactions that caused errors during the process
0324:             * @param mode the mode the poster was being run in
0325:             * @see org.kuali.module.gl.service.ReportService#generatePosterStatisticsReport(java.util.Date, java.util.Map, java.util.Map,
0326:             *      int)
0327:             */
0328:            public void generatePosterStatisticsReport(Date executionDate,
0329:                    Date runDate, Map<String, Integer> reportSummary,
0330:                    List<PostTransaction> transactionPosters,
0331:                    Map<Transaction, List<Message>> reportErrors, int mode) {
0332:                LOG.debug("generatePosterStatisticsReport() started");
0333:
0334:                // Convert our summary to a list of items for the report
0335:                List summary = new ArrayList();
0336:                if (mode == PosterService.MODE_REVERSAL) {
0337:                    summary.add(new Summary(1,
0338:                            "Number of GL_REVERSAL_T records selected:",
0339:                            (Integer) reportSummary.get("GL_REVERSAL_T,S")));
0340:                } else {
0341:                    summary
0342:                            .add(new Summary(
0343:                                    1,
0344:                                    "Number of GL_ORIGIN_ENTRY_T records selected:",
0345:                                    (Integer) reportSummary
0346:                                            .get("GL_ORIGIN_ENTRY_T,S")));
0347:                }
0348:                summary.add(new Summary(2, "", 0));
0349:
0350:                int count = 10;
0351:                for (Iterator posterIter = transactionPosters.iterator(); posterIter
0352:                        .hasNext();) {
0353:                    PostTransaction poster = (PostTransaction) posterIter
0354:                            .next();
0355:                    String table = poster.getDestinationName();
0356:                    summary.add(new Summary(count++, "Number of " + table
0357:                            + " records deleted:", (Integer) reportSummary
0358:                            .get(table + ",D")));
0359:                    summary.add(new Summary(count++, "Number of " + table
0360:                            + " records inserted:", (Integer) reportSummary
0361:                            .get(table + ",I")));
0362:                    summary.add(new Summary(count++, "Number of " + table
0363:                            + " records updated:", (Integer) reportSummary
0364:                            .get(table + ",U")));
0365:                    summary.add(new Summary(count++, "", 0));
0366:                }
0367:
0368:                summary.add(new Summary(10000, "", 0));
0369:                summary.add(new Summary(10001,
0370:                        "Number of WARNING records selected:",
0371:                        (Integer) reportSummary.get("WARNING,S")));
0372:
0373:                TransactionReport tr = new TransactionReport();
0374:
0375:                String title = "Poster Report ";
0376:                String filename;
0377:                if (mode == PosterService.MODE_ENTRIES) {
0378:                    title = title + "(Post pending entries)";
0379:                    filename = "poster_main";
0380:                } else if (mode == PosterService.MODE_ICR) {
0381:                    title = title + "(Post ICR entries)";
0382:                    filename = "poster_icr";
0383:                } else {
0384:                    title = title + "(Post reversal entries)";
0385:                    filename = "poster_reversal";
0386:                }
0387:
0388:                tr.generateReport(reportErrors, summary, executionDate, title,
0389:                        filename, reportsDirectory);
0390:            }
0391:
0392:            /**
0393:             * Generates the ICR Encumbrance Statistics report
0394:             * 
0395:             * @param runDate the date when the poster process was run
0396:             * @param totalOfIcrEncumbrances the number of ICR encumbrances processed
0397:             * @param totalOfEntriesGenerated the number of origin entries generated by this step of the process
0398:             * @see org.kuali.module.gl.service.ReportService#generateIcrEncumrbanceStatisticsReport(java.util.Date, int, int)
0399:             */
0400:            public void generateIcrEncumbranceStatisticsReport(Date runDate,
0401:                    int totalOfIcrEncumbrances, int totalOfEntriesGenerated) {
0402:                LOG.debug("generateIcrEncumrbanceStatisticsReport() started");
0403:
0404:                List reportSummaryList = new ArrayList();
0405:                reportSummaryList.add(new Summary(1,
0406:                        "Number of ICR Encumbrances retrived:",
0407:                        totalOfIcrEncumbrances));
0408:                reportSummaryList.add(new Summary(2,
0409:                        "Number of Origin Entries generated:",
0410:                        totalOfEntriesGenerated));
0411:
0412:                Map<Transaction, List<Message>> errors = new HashMap<Transaction, List<Message>>();
0413:
0414:                TransactionReport tr = new TransactionReport();
0415:                tr.generateReport(errors, reportSummaryList, runDate,
0416:                        "ICR Encumbrance Report", "icr_encumbrance",
0417:                        reportsDirectory);
0418:            }
0419:
0420:            /**
0421:             * Generates the Poster ICR Statistics report
0422:             * 
0423:             * @param executionDate the actual time of poster execution
0424:             * @param runDate the time assumed by the poster (sometimes the poster can use a transaction date back
0425:             * @param reportErrors a Map of expenditure transactions that caused errors during the process
0426:             * @param reportExpendTranRetrieved the number of expenditure transactions read by the poster during the ICR run
0427:             * @param reportExpendTranDeleted the number of expenditure transactions deleted by the poster during the ICR run
0428:             * @param reportExpendTranKept the number of expenditure transactions saved by the poster during the ICR run
0429:             * @param reportOriginEntryGenerated the number of origin entry records generated by the process
0430:             * @see org.kuali.module.gl.service.ReportService#generatePosterIcrStatisticsReport(java.util.Date, java.util.Date,
0431:             *      java.util.Map, int, int, int, int)
0432:             */
0433:            public void generatePosterIcrStatisticsReport(Date executionDate,
0434:                    Date runDate,
0435:                    Map<ExpenditureTransaction, List<Message>> reportErrors,
0436:                    int reportExpendTranRetrieved, int reportExpendTranDeleted,
0437:                    int reportExpendTranKept, int reportOriginEntryGenerated) {
0438:                LOG.debug("generatePosterIcrStatisticsReport() started");
0439:
0440:                List<Summary> summary = new ArrayList();
0441:                summary.add(new Summary(1,
0442:                        "Number of GL_EXPEND_TRAN_T records retrieved:",
0443:                        reportExpendTranRetrieved));
0444:                summary.add(new Summary(2,
0445:                        "Number of GL_EXPEND_TRAN_T records deleted:",
0446:                        reportExpendTranDeleted));
0447:                summary
0448:                        .add(new Summary(
0449:                                3,
0450:                                "Number of GL_EXPEND_TRAN_T records kept due to errors:",
0451:                                reportExpendTranKept));
0452:                summary.add(new Summary(4, "", 0));
0453:                summary.add(new Summary(3,
0454:                        "Number of GL_ORIGIN_ENTRY_T records generated:",
0455:                        reportOriginEntryGenerated));
0456:
0457:                ExpenditureTransactionReport etr = new ExpenditureTransactionReport();
0458:                etr.generateReport(reportErrors, summary, executionDate,
0459:                        "ICR Generation Report", "icr_generation",
0460:                        reportsDirectory);
0461:            }
0462:
0463:            /**
0464:             * Generates Scrubber General Ledger Transaction Summary report as a PDF
0465:             * 
0466:             * @param runDate Run date of the report
0467:             * @param groups Groups to summarize for the report
0468:             * @see org.kuali.module.gl.service.ReportService#generateScrubberLedgerSummaryReportBatch(java.util.Date, java.util.Collection)
0469:             */
0470:            public void generateScrubberLedgerSummaryReportBatch(Date runDate,
0471:                    Collection groups) {
0472:                LOG.debug("generateScrubberLedgerSummaryReport() started");
0473:
0474:                LedgerReport ledgerReport = new LedgerReport();
0475:                LedgerEntryHolder ledgerEntries = new LedgerEntryHolder();
0476:                if (groups.size() > 0) {
0477:                    ledgerEntries = originEntryService
0478:                            .getSummaryByGroupId(groups);
0479:                }
0480:
0481:                ledgerReport.generateReport(ledgerEntries, runDate,
0482:                        "Ledger Report", "scrubber_ledger", reportsDirectory);
0483:            }
0484:
0485:            /**
0486:             * Generates the Scrubber General Ledger Transaction Summary report for online viewing
0487:             * 
0488:             * @param runDate Run date of the report
0489:             * @param group Group to summarize for the report
0490:             * @see org.kuali.module.gl.service.ReportService#generateScrubberLedgerSummaryReportOnline(java.util.Date,
0491:             *      org.kuali.module.gl.bo.OriginEntryGroup)
0492:             */
0493:            public void generateScrubberLedgerSummaryReportOnline(Date runDate,
0494:                    OriginEntryGroup group, String documentNumber) {
0495:                LOG.debug("generateScrubberLedgerSummaryReport() started");
0496:
0497:                LedgerReport ledgerReport = new LedgerReport();
0498:                LedgerEntryHolder ledgerEntries = new LedgerEntryHolder();
0499:
0500:                Collection g = new ArrayList();
0501:                g.add(group);
0502:
0503:                ledgerEntries = originEntryService.getSummaryByGroupId(g);
0504:
0505:                ledgerReport.generateReport(ledgerEntries, runDate,
0506:                        "Ledger Report", "scrubber_ledger_" + documentNumber,
0507:                        reportsDirectory);
0508:            }
0509:
0510:            /**
0511:             * Generates the crubber Statistics report for batch reports (saves reports as PDFs)
0512:             * 
0513:             * @param runDate Run date of the report
0514:             * @param scrubberReport Summary information
0515:             * @param scrubberReportErrors Map of transactions with errors or warnings
0516:             * @see org.kuali.module.gl.service.ReportService#generateScrubberStatisticsReport(java.util.Date,
0517:             *      org.kuali.module.gl.service.impl.scrubber.ScrubberReportData, java.util.Map)
0518:             */
0519:            public void generateBatchScrubberStatisticsReport(Date runDate,
0520:                    ScrubberReportData scrubberReport,
0521:                    Map<Transaction, List<Message>> scrubberReportErrors) {
0522:                LOG.debug("generateScrubberStatisticsReport() started");
0523:
0524:                List tranKeys = new ArrayList();
0525:                tranKeys.addAll(scrubberReportErrors.keySet());
0526:
0527:                Collections.sort(tranKeys, new Comparator<Transaction>() {
0528:                    public int compare(Transaction t1, Transaction t2) {
0529:                        StringBuffer sb1 = new StringBuffer();
0530:                        sb1.append(t1.getFinancialDocumentTypeCode());
0531:                        sb1.append(t1.getFinancialSystemOriginationCode());
0532:                        sb1.append(t1.getDocumentNumber());
0533:                        sb1.append(t1.getChartOfAccountsCode());
0534:                        sb1.append(t1.getAccountNumber());
0535:                        sb1.append(t1.getSubAccountNumber());
0536:                        sb1.append(t1.getFinancialBalanceTypeCode());
0537:
0538:                        StringBuffer sb2 = new StringBuffer();
0539:                        sb2.append(t2.getFinancialDocumentTypeCode());
0540:                        sb2.append(t2.getFinancialSystemOriginationCode());
0541:                        sb2.append(t2.getDocumentNumber());
0542:                        sb2.append(t2.getChartOfAccountsCode());
0543:                        sb2.append(t2.getAccountNumber());
0544:                        sb2.append(t2.getSubAccountNumber());
0545:                        sb2.append(t2.getFinancialBalanceTypeCode());
0546:                        return sb1.toString().compareTo(sb2.toString());
0547:                    }
0548:                });
0549:
0550:                List summary = buildScrubberReportSummary(scrubberReport);
0551:
0552:                TransactionReport transactionReport = new TransactionReport();
0553:                transactionReport.generateReport(tranKeys,
0554:                        scrubberReportErrors, summary, runDate,
0555:                        "Scrubber Report ", "scrubber", reportsDirectory);
0556:            }
0557:
0558:            /**
0559:             * Generates Scrubber Statistics report for online reports
0560:             * 
0561:             * @param runDate Run date of the report
0562:             * @param scrubberReport Summary information
0563:             * @param scrubberReportErrors Map of transactions with errors or warnings
0564:             * @see org.kuali.module.gl.service.ReportService#generateScrubberStatisticsReport(java.util.Date,
0565:             *      org.kuali.module.gl.service.impl.scrubber.ScrubberReportData, java.util.Map)
0566:             */
0567:            public void generateOnlineScrubberStatisticsReport(Integer groupId,
0568:                    Date runDate, ScrubberReportData scrubberReport,
0569:                    Map<Transaction, List<Message>> scrubberReportErrors,
0570:                    String documentNumber) {
0571:                LOG.debug("generateScrubberStatisticsReport() started");
0572:
0573:                List summary = buildScrubberReportSummary(scrubberReport);
0574:
0575:                TransactionReport transactionReport = new TransactionReport();
0576:                transactionReport.generateReport(scrubberReportErrors, summary,
0577:                        runDate, "Scrubber Report ", "scrubber_"
0578:                                + documentNumber, reportsDirectory);
0579:            }
0580:
0581:            /**
0582:             * Generates the Scrubber Demerger Statistics report
0583:             * 
0584:             * @param runDate Run date of the report
0585:             * @param demergerReport Summary information
0586:             * @see org.kuali.module.gl.service.ReportService#generateScrubberDemergerStatisticsReports(java.util.Date,
0587:             *      org.kuali.module.gl.service.impl.scrubber.DemergerReportData)
0588:             */
0589:            public void generateScrubberDemergerStatisticsReports(Date runDate,
0590:                    DemergerReportData demergerReport) {
0591:                LOG
0592:                        .debug("generateScrubberDemergerStatisticsReports() started");
0593:
0594:                List summary = buildDemergerReportSummary(demergerReport);
0595:
0596:                Map<Transaction, List<Message>> empty = new HashMap<Transaction, List<Message>>();
0597:
0598:                TransactionReport transactionReport = new TransactionReport();
0599:                transactionReport.generateReport(empty, summary, runDate,
0600:                        "Demerger Report ", "demerger", reportsDirectory);
0601:            }
0602:
0603:            /**
0604:             * Generates the Scrubber Bad Balance listing report
0605:             * 
0606:             * @param runDate Run date of the report
0607:             * @param groups Groups to summarize for the report
0608:             * @see org.kuali.module.gl.service.ReportService#generateScrubberBadBalanceTypeListingReport(java.util.Date,
0609:             *      java.util.Collection)
0610:             */
0611:            public void generateScrubberBadBalanceTypeListingReport(
0612:                    Date runDate, Collection groups) {
0613:                LOG
0614:                        .debug("generateScrubberBadBalanceTypeListingReport() started");
0615:
0616:                Iterator i = null;
0617:                if (groups.size() > 0) {
0618:                    i = originEntryService.getBadBalanceEntries(groups);
0619:                }
0620:
0621:                TransactionListingReport rept = new TransactionListingReport();
0622:                rept.generateReport(i, runDate,
0623:                        "Scrubber Input Transactions with Blank Balance Types",
0624:                        "scrubber_badbal", reportsDirectory);
0625:            }
0626:
0627:            /**
0628:             * Generates Scrubber Transaction Listing report for online viewing
0629:             * 
0630:             * @param runDate Run date of the report
0631:             * @param validGroup Group with transactions
0632:             * @see org.kuali.module.gl.service.ReportService#generateScrubberTransactionsOnline(java.util.Date, org.kuali.module.gl.bo.OriginEntryGroup, java.lang.String)
0633:             */
0634:            public void generateScrubberTransactionsOnline(Date runDate,
0635:                    OriginEntryGroup validGroup, String documentNumber) {
0636:                LOG.debug("generateScrubberTransactionsOnline() started");
0637:
0638:                Iterator ti = originEntryService
0639:                        .getEntriesByGroupAccountOrder(validGroup);
0640:
0641:                TransactionListingReport rept = new TransactionListingReport();
0642:                rept.generateReport(ti, runDate,
0643:                        "Output Transaction Listing From the Scrubber",
0644:                        "scrubber_listing_" + documentNumber, reportsDirectory);
0645:            }
0646:
0647:            /**
0648:             * Generates the Scrubber Removed Transactions report
0649:             * 
0650:             * @param runDate Run date of the report
0651:             * @param errorGroup Group with error transactions
0652:             * @see org.kuali.module.gl.service.ReportService#generateScrubberRemovedTransactions(java.util.Date,
0653:             *      org.kuali.module.gl.bo.OriginEntryGroup)
0654:             */
0655:            public void generateScrubberRemovedTransactions(Date runDate,
0656:                    OriginEntryGroup errorGroup) {
0657:                LOG.debug("generateScrubberRemovedTransactions() started");
0658:
0659:                Iterator ti = originEntryService
0660:                        .getEntriesByGroupListingReportOrder(errorGroup);
0661:
0662:                TransactionListingReport rept = new TransactionListingReport();
0663:                rept
0664:                        .generateReport(
0665:                                ti,
0666:                                runDate,
0667:                                "Error Listing - Transactions Removed From the Scrubber",
0668:                                "scrubber_errors", reportsDirectory);
0669:            }
0670:
0671:            /**
0672:             * Generates the GL Summary report
0673:             * 
0674:             * @param runDate the run date of the poster service that should be reported
0675:             * @param options the options of the fiscal year the poster was run
0676:             * @param reportType the type of the report that should be generated
0677:             * @see org.kuali.module.gl.service.ReportService#generateGlSummary(java.util.Date, int, java.util.List)
0678:             */
0679:            public void generateGlSummary(Date runDate, Options year,
0680:                    String reportType) {
0681:                LOG.debug("generateGlSummary() started");
0682:
0683:                List balanceTypeCodes = new ArrayList();
0684:                if ("act".equals(reportType)) {
0685:                    balanceTypeCodes
0686:                            .add(year.getActualFinancialBalanceTypeCd());
0687:                } else {
0688:                    balanceTypeCodes.add(year.getBudgetCheckingBalanceTypeCd());
0689:                    balanceTypeCodes.add(year
0690:                            .getBaseBudgetFinancialBalanceTypeCd());
0691:                    balanceTypeCodes.add(year
0692:                            .getMonthlyBudgetFinancialBalanceTypeCd());
0693:                }
0694:
0695:                List balances = balanceService.getGlSummary(year
0696:                        .getUniversityFiscalYear(), balanceTypeCodes);
0697:
0698:                BalanceReport rept = new BalanceReport();
0699:                rept.generateReport(runDate, balances, year
0700:                        .getUniversityFiscalYearName(), balanceTypeCodes,
0701:                        "glsummary_" + year.getUniversityFiscalYear() + "_"
0702:                                + reportType, reportsDirectory);
0703:            }
0704:
0705:            /**
0706:             * Generates GL Encumbrance Summary report
0707:             * 
0708:             * @param runDate the run date of the poster service that should be reported
0709:             * @param options the options of the fiscal year the poster was run
0710:             * @param reportType the type of the report that should be generated
0711:             * @see org.kuali.module.gl.service.ReportService#generateGlEncumbranceSummary(java.util.Date, int, java.util.List,
0712:             *      java.lang.String)
0713:             */
0714:            public void generateGlEncumbranceSummary(Date runDate,
0715:                    Options year, String reportType) {
0716:                LOG.debug("generateGlEncumbranceSummary() started");
0717:
0718:                List balanceTypeCodes = new ArrayList();
0719:                balanceTypeCodes.add(year.getExtrnlEncumFinBalanceTypCd());
0720:                balanceTypeCodes.add(year.getIntrnlEncumFinBalanceTypCd());
0721:                balanceTypeCodes.add(year.getPreencumbranceFinBalTypeCd());
0722:                balanceTypeCodes.add(year
0723:                        .getCostShareEncumbranceBalanceTypeCd());
0724:
0725:                List balances = balanceService.getGlSummary(year
0726:                        .getUniversityFiscalYear(), balanceTypeCodes);
0727:
0728:                BalanceEncumbranceReport rept = new BalanceEncumbranceReport();
0729:                rept.generateReport(runDate, balances, year
0730:                        .getUniversityFiscalYearName(), balanceTypeCodes,
0731:                        "glsummary_" + year.getUniversityFiscalYear() + "_"
0732:                                + reportType, reportsDirectory);
0733:            }
0734:
0735:            /**
0736:             * Generates Main Poster Input Transaction Report
0737:             * 
0738:             * @param executionDate the actual time of poster execution
0739:             * @param runDate the time assumed by the poster (sometimes the poster can use a transaction date back in time to redo a failed
0740:             *        poster run)
0741:             * @param groups origin entry groups produced by the poster to be reported on
0742:             * @see org.kuali.module.gl.service.ReportService#generatePosterMainLedgerSummaryReport(java.util.Date, java.util.Date,
0743:             *      java.util.Collection)
0744:             */
0745:            public void generatePosterMainLedgerSummaryReport(
0746:                    Date executionDate, Date runDate, Collection groups) {
0747:                LOG.debug("generatePosterMainLedgerSummaryReport() started");
0748:
0749:                LedgerEntryHolder ledgerEntries = new LedgerEntryHolder();
0750:                if (groups.size() > 0) {
0751:                    ledgerEntries = originEntryService
0752:                            .getSummaryByGroupId(groups);
0753:                }
0754:
0755:                LedgerReport ledgerReport = new LedgerReport();
0756:                ledgerReport.generateReport(ledgerEntries, executionDate,
0757:                        "Main Poster Input Transactions", "poster_main_ledger",
0758:                        reportsDirectory);
0759:            }
0760:
0761:            /**
0762:             * Generates the Icr Poster Input Transaction Report
0763:             * 
0764:             * @param executionDate the actual time of poster execution
0765:             * @param runDate the time assumed by the poster (sometimes the poster can use a transaction date back in time to redo a failed
0766:             *        poster run)
0767:             * @param groups entry groups produced by the poster to be reported on
0768:             * @see org.kuali.module.gl.service.ReportService#generatePosterIcrLedgerSummaryReport(java.util.Date, java.util.Date,
0769:             *      java.util.Collection)
0770:             */
0771:            public void generatePosterIcrLedgerSummaryReport(
0772:                    Date executionDate, Date runDate, Collection groups) {
0773:                LOG.debug("generatePosterIcrLedgerSummaryReport() started");
0774:
0775:                LedgerEntryHolder ledgerEntries = new LedgerEntryHolder();
0776:                if (groups.size() > 0) {
0777:                    ledgerEntries = originEntryService
0778:                            .getSummaryByGroupId(groups);
0779:                }
0780:
0781:                LedgerReport ledgerReport = new LedgerReport();
0782:                ledgerReport.generateReport(ledgerEntries, executionDate,
0783:                        "ICR Poster Input Transactions", "poster_icr_ledger",
0784:                        reportsDirectory);
0785:            }
0786:
0787:            /**
0788:             * NOTE: the implementation of this method only determines whether an iterator has a next element (using hasNext()). It does not
0789:             * iterate through the array.
0790:             * @param executionDate the actual time of poster execution
0791:             * @param runDate the time assumed by the poster (sometimes the poster can use a transaction date back in time to redo a failed
0792:             *        poster run)
0793:             * @param groups groups produced by the poster to be reported on
0794:             * @see org.kuali.module.gl.service.ReportService#generatePosterReversalLedgerSummaryReport(java.util.Date, java.util.Date,
0795:             *      java.util.Iterator)
0796:             */
0797:            public void generatePosterReversalLedgerSummaryReport(
0798:                    Date executionDate, Date runDate, Iterator reversals) {
0799:                LOG
0800:                        .debug("generatePosterReversalLedgerSummaryReport() started");
0801:
0802:                LedgerEntryHolder ledgerEntries = new LedgerEntryHolder();
0803:                if (reversals.hasNext()) {
0804:                    ledgerEntries = reversalService.getSummaryByDate(runDate);
0805:                }
0806:
0807:                LedgerReport ledgerReport = new LedgerReport();
0808:                ledgerReport.generateReport(ledgerEntries, executionDate,
0809:                        "Reversal Poster Input Transactions",
0810:                        "poster_reversal_ledger", reportsDirectory);
0811:            }
0812:
0813:            /**
0814:             * Generates the Balance Forward Year-End job Report
0815:             * 
0816:             * @param reportSummary a List of summarized statistics to report
0817:             * @param runDate the date of the balance forward run
0818:             * @param openAccountOriginEntryGroup the origin entry group with balance forwarding origin entries with open accounts
0819:             * @param closedAccountOriginEntryGroup the origin entry group with balance forwarding origin entries with closed accounts
0820:             * @see org.kuali.module.gl.service.ReportService#generateBalanceForwardStatisticsReport(java.util.List, java.util.Date)
0821:             */
0822:            public void generateBalanceForwardStatisticsReport(
0823:                    List reportSummary, Date runDate,
0824:                    OriginEntryGroup openAccountOriginEntryGroup,
0825:                    OriginEntryGroup closedAccountOriginEntryGroup) {
0826:                LOG.debug("generateBalanceForwardStatisticsReport() started");
0827:
0828:                YearEndTransactionReport transactionReport = new YearEndTransactionReport(
0829:                        YearEndTransactionReport.YearEndReportType.FORWARD_BALANCES_REPORT);
0830:                String title = "Balance Forward Report ";
0831:                transactionReport
0832:                        .generateReport(
0833:                                new HashMap(),
0834:                                new HashMap(),
0835:                                reportSummary,
0836:                                runDate,
0837:                                title,
0838:                                "year_end_balance_forward",
0839:                                reportsDirectory,
0840:                                new Object[] {
0841:                                        new Object[] {
0842:                                                openAccountOriginEntryGroup,
0843:                                                "Open Account Balance Forwards Statistics" },
0844:                                        new Object[] {
0845:                                                closedAccountOriginEntryGroup,
0846:                                                "Closed Account Balance Fowards Statistics" } });
0847:            }
0848:
0849:            /**
0850:             * Generates the encumbrance foward year end job report
0851:             * 
0852:             * @param jobParameters the parameters that were used by the encumbrance forward job
0853:             * @param reportSummary a List of summarized statistics to report
0854:             * @param runDate the date of the encumbrance forward run
0855:             * @param originEntryGroup the origin entry group that the job placed encumbrance forwarding origin entries into
0856:             * @see org.kuali.module.gl.service.ReportService#generateEncumbranceClosingStatisticsReport(java.util.List, java.util.Date)
0857:             */
0858:            public void generateEncumbranceClosingStatisticsReport(
0859:                    Map jobParameters, List reportSummary, Date runDate,
0860:                    OriginEntryGroup originEntryGroup) {
0861:                LOG
0862:                        .debug("generateEncumbranceForwardStatisticsReport() started");
0863:
0864:                YearEndTransactionReport transactionReport = new YearEndTransactionReport(
0865:                        YearEndTransactionReport.YearEndReportType.FORWARD_ENCUMBERANCES_REPORT);
0866:                String title = "Encumbrance Closing Report ";
0867:                transactionReport.generateReport(jobParameters, new HashMap(),
0868:                        reportSummary, runDate, title,
0869:                        "year_end_encumbrance_closing", reportsDirectory,
0870:                        new Object[] { new Object[] { originEntryGroup,
0871:                                "Encumbrance Forwards Statistics" } });
0872:            }
0873:
0874:            /**
0875:             * Generates the Nominal Activity Closing Report
0876:             * 
0877:             * @param jobParameters the parameters that were used by the nominal activity closing job
0878:             * @param reportSummary a List of summarized statistics to report
0879:             * @param runDate the date of the nominal activity closing job run
0880:             * @param originEntryGroup the origin entry group that the job placed nominal activity closing origin entries into
0881:             * @see org.kuali.module.gl.service.ReportService#generateNominalActivityClosingStatisticsReport(java.util.Map, java.util.List,
0882:             *      java.util.Date)
0883:             */
0884:            public void generateNominalActivityClosingStatisticsReport(
0885:                    Map jobParameters, List reportSummary, Date runDate,
0886:                    OriginEntryGroup originEntryGroup) {
0887:                LOG
0888:                        .debug("generateNominalActivityClosingStatisticsReport() started");
0889:
0890:                YearEndTransactionReport transactionReport = new YearEndTransactionReport(
0891:                        YearEndTransactionReport.YearEndReportType.NOMINAL_ACTIVITY_CLOSE_REPORT);
0892:                String title = "Nominal Activity Closing Report ";
0893:                transactionReport.generateReport(jobParameters, null,
0894:                        reportSummary, runDate, title,
0895:                        "year_end_nominal_activity_closing", reportsDirectory,
0896:                        new Object[] { new Object[] { originEntryGroup,
0897:                                "Nominal Activity Closing Statistics" } });
0898:            }
0899:
0900:            /**
0901:             * This method generates the statistics report of the organization reversion process.
0902:             * 
0903:             * @param jobParameters the parameters the org reversion process was run with
0904:             * @param reportSummary a list of various counts the job went through
0905:             * @param runDate the date the report was run
0906:             * @param orgReversionOriginEntryGroup the origin entry group that contains the reversion origin entries
0907:             * @see org.kuali.module.gl.service.ReportService#generateOrgReversionStatisticsReport(java.util.Map, java.util.List,
0908:             *      java.util.Date, org.kuali.module.gl.bo.OriginEntryGroup)
0909:             */
0910:            public void generateOrgReversionStatisticsReport(Map jobParameters,
0911:                    List reportSummary, Date runDate,
0912:                    OriginEntryGroup orgReversionOriginEntryGroup) {
0913:                LOG.debug("generateOrgReversionStatisticsReport() started");
0914:
0915:                YearEndTransactionReport transactionReport = new YearEndTransactionReport(
0916:                        YearEndTransactionReport.YearEndReportType.ORGANIZATION_REVERSION_PROCESS_REPORT);
0917:                String title = "Organization Reversion Process Report ";
0918:                transactionReport.generateReport(jobParameters, null,
0919:                        reportSummary, runDate, title,
0920:                        "year_end_org_reversion_process", reportsDirectory,
0921:                        new Object[] { new Object[] {
0922:                                orgReversionOriginEntryGroup,
0923:                                "Organization Reversion Statistics" } });
0924:            }
0925:
0926:            /**
0927:             * Generate the header for the scrubber status report.
0928:             * 
0929:             * @param scrubberReport data about the scrubber run to turn into summaries
0930:             * @return list of report summaries to be printed
0931:             */
0932:            private List<Summary> buildScrubberReportSummary(
0933:                    ScrubberReportData scrubberReport) {
0934:                List<Summary> reportSummary = new ArrayList<Summary>();
0935:
0936:                reportSummary.add(new Summary(2, "UNSCRUBBED RECORDS READ",
0937:                        new Integer(scrubberReport
0938:                                .getNumberOfUnscrubbedRecordsRead())));
0939:                reportSummary.add(new Summary(3, "SCRUBBED RECORDS WRITTEN",
0940:                        new Integer(scrubberReport
0941:                                .getNumberOfScrubbedRecordsWritten())));
0942:                reportSummary.add(new Summary(4, "ERROR RECORDS WRITTEN",
0943:                        new Integer(scrubberReport
0944:                                .getNumberOfErrorRecordsWritten())));
0945:                reportSummary.add(new Summary(5, "OFFSET ENTRIES GENERATED",
0946:                        new Integer(scrubberReport
0947:                                .getNumberOfOffsetEntriesGenerated())));
0948:                reportSummary.add(new Summary(6,
0949:                        "CAPITALIZATION ENTRIES GENERATED",
0950:                        new Integer(scrubberReport
0951:                                .getNumberOfCapitalizationEntriesGenerated())));
0952:                reportSummary.add(new Summary(7, "LIABILITY ENTRIES GENERATED",
0953:                        new Integer(scrubberReport
0954:                                .getNumberOfLiabilityEntriesGenerated())));
0955:                reportSummary
0956:                        .add(new Summary(
0957:                                8,
0958:                                "PLANT INDEBTEDNESS ENTRIES GENERATED",
0959:                                new Integer(
0960:                                        scrubberReport
0961:                                                .getNumberOfPlantIndebtednessEntriesGenerated())));
0962:                reportSummary.add(new Summary(9,
0963:                        "COST SHARE ENTRIES GENERATED",
0964:                        new Integer(scrubberReport
0965:                                .getNumberOfCostShareEntriesGenerated())));
0966:                reportSummary.add(new Summary(10,
0967:                        "COST SHARE ENC ENTRIES GENERATED",
0968:                        new Integer(scrubberReport
0969:                                .getNumberOfCostShareEncumbrancesGenerated())));
0970:                reportSummary.add(new Summary(11,
0971:                        "TOTAL OUTPUT RECORDS WRITTEN",
0972:                        new Integer(scrubberReport
0973:                                .getTotalNumberOfRecordsWritten())));
0974:                reportSummary.add(new Summary(12, "EXPIRED ACCOUNTS FOUND",
0975:                        new Integer(scrubberReport
0976:                                .getNumberOfExpiredAccountsFound())));
0977:
0978:                return reportSummary;
0979:            }
0980:
0981:            /**
0982:             * Generate the header for the demerger status report.
0983:             * 
0984:             * @param demergerReport data about the demerger run that needs to be turned into summaries
0985:             * @return list of report summaries to be printed
0986:             */
0987:            private List<Summary> buildDemergerReportSummary(
0988:                    DemergerReportData demergerReport) {
0989:                List<Summary> reportSummary = new ArrayList<Summary>();
0990:
0991:                reportSummary.add(new Summary(1,
0992:                        "SCRUBBER ERROR TRANSACTIONS READ", new Integer(
0993:                                demergerReport.getErrorTransactionsRead())));
0994:                reportSummary
0995:                        .add(new Summary(3, "DEMERGER ERRORS SAVED",
0996:                                new Integer(demergerReport
0997:                                        .getErrorTransactionsSaved())));
0998:                reportSummary.add(new Summary(4,
0999:                        "DEMERGER VALID TRANSACTIONS SAVED", new Integer(
1000:                                demergerReport.getValidTransactionsSaved())));
1001:                reportSummary
1002:                        .add(new Summary(5, "OFFSET TRANSACTIONS BYPASSED",
1003:                                new Integer(demergerReport
1004:                                        .getOffsetTransactionsBypassed())));
1005:                reportSummary.add(new Summary(6,
1006:                        "CAPITALIZATION TRANSACTIONS BYPASSED",
1007:                        new Integer(demergerReport
1008:                                .getCapitalizationTransactionsBypassed())));
1009:                reportSummary.add(new Summary(7,
1010:                        "LIABILITY TRANSACTIONS BYPASSED", new Integer(
1011:                                demergerReport
1012:                                        .getLiabilityTransactionsBypassed())));
1013:                reportSummary.add(new Summary(8,
1014:                        "TRANSFER TRANSACTIONS BYPASSED", new Integer(
1015:                                demergerReport
1016:                                        .getTransferTransactionsBypassed())));
1017:                reportSummary.add(new Summary(9,
1018:                        "COST SHARE TRANSACTIONS BYPASSED", new Integer(
1019:                                demergerReport
1020:                                        .getCostShareTransactionsBypassed())));
1021:                reportSummary
1022:                        .add(new Summary(
1023:                                10,
1024:                                "COST SHARE ENC TRANSACTIONS BYPASSED",
1025:                                new Integer(
1026:                                        demergerReport
1027:                                                .getCostShareEncumbranceTransactionsBypassed())));
1028:
1029:                return reportSummary;
1030:            }
1031:
1032:            /**
1033:             * A class that helps format a PDF document
1034:             */
1035:            class SfPageHelper extends PdfPageEventHelper {
1036:                public Date runDate;
1037:                public Font headerFont;
1038:                public String title;
1039:
1040:                /**
1041:                 * Writes information to the last page in the document
1042:                 * @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document)
1043:                 */
1044:                public void onEndPage(PdfWriter writer, Document document) {
1045:                    try {
1046:                        Rectangle page = document.getPageSize();
1047:                        PdfPTable head = new PdfPTable(3);
1048:                        SimpleDateFormat sdf = new SimpleDateFormat(
1049:                                "MM/dd/yyyy HH:mm:ss");
1050:                        PdfPCell cell = new PdfPCell(new Phrase(sdf
1051:                                .format(runDate), headerFont));
1052:                        cell.setBorder(Rectangle.NO_BORDER);
1053:                        head.addCell(cell);
1054:
1055:                        cell = new PdfPCell(new Phrase(title, headerFont));
1056:                        cell.setBorder(Rectangle.NO_BORDER);
1057:                        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
1058:                        head.addCell(cell);
1059:
1060:                        cell = new PdfPCell(new Phrase("Page: "
1061:                                + new Integer(writer.getPageNumber()),
1062:                                headerFont));
1063:                        cell.setBorder(Rectangle.NO_BORDER);
1064:                        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
1065:                        head.addCell(cell);
1066:
1067:                        head.setTotalWidth(page.width() - document.leftMargin()
1068:                                - document.rightMargin());
1069:                        head.writeSelectedRows(0, -1, document.leftMargin(),
1070:                                page.height() - document.topMargin()
1071:                                        + head.getTotalHeight(), writer
1072:                                        .getDirectContent());
1073:                    } catch (Exception e) {
1074:                        throw new ExceptionConverter(e);
1075:                    }
1076:                }
1077:            }
1078:
1079:            /**
1080:             * Generates the Poster Reversal Transactions Listing
1081:             * 
1082:             * @param executionDate the actual time of poster execution
1083:             * @param runDate the time assumed by the poster (sometimes the poster can use a transaction date back in time to redo a failed
1084:             *        poster run)
1085:             * @param group Group with valid transactions
1086:             * @see org.kuali.module.gl.service.ReportService#generatePosterReversalTransactionsListing(java.util.Date, java.util.Date,
1087:             *      org.kuali.module.gl.bo.OriginEntryGroup)
1088:             */
1089:            public void generatePosterReversalTransactionsListing(
1090:                    Date executionDate, Date runDate,
1091:                    OriginEntryGroup originGroup) {
1092:                LOG
1093:                        .debug("generatePosterReversalTransactionsListing() started");
1094:
1095:                Iterator ti = originEntryService
1096:                        .getEntriesByGroupAccountOrder(originGroup);
1097:
1098:                TransactionListingReport report = new TransactionListingReport();
1099:                report.generateReport(ti, executionDate,
1100:                        "Reversal Poster Transaction Listing",
1101:                        "poster_reversal_list", reportsDirectory);
1102:            }
1103:
1104:            /**
1105:             * Generates the Poster Error transaction listing
1106:             * 
1107:             * @param executionDate the actual time of poster execution
1108:             * @param runDate the time assumed by the poster (sometimes the poster can use a transaction date back in time to redo a failed
1109:             *        poster run)
1110:             * @param group Group with error transactions
1111:             * @param posterMode Mode the poster is running
1112:             * @see org.kuali.module.gl.service.ReportService#generatePosterErrorTransactionListing(java.util.Date,
1113:             *      org.kuali.module.gl.bo.OriginEntryGroup, int)
1114:             */
1115:            public void generatePosterErrorTransactionListing(
1116:                    Date executionDate, Date runDate, OriginEntryGroup group,
1117:                    int posterMode) {
1118:                LOG.debug("generatePosterErrorTransactionListing() started");
1119:
1120:                Iterator ti = originEntryService
1121:                        .getEntriesByGroupAccountOrder(group);
1122:
1123:                TransactionListingReport report = new TransactionListingReport();
1124:                if (posterMode == PosterService.MODE_ENTRIES) {
1125:                    report.generateReport(ti, executionDate,
1126:                            "Main Poster Error Transaction Listing",
1127:                            "poster_main_error_list", reportsDirectory);
1128:                } else if (posterMode == PosterService.MODE_ICR) {
1129:                    report.generateReport(ti, executionDate,
1130:                            "ICR Poster Error Transaction Listing",
1131:                            "poster_icr_error_list", reportsDirectory);
1132:                } else if (posterMode == PosterService.MODE_REVERSAL) {
1133:                    report.generateReport(ti, executionDate,
1134:                            "Reversal Poster Error Transaction Listing",
1135:                            "poster_reversal_error_list", reportsDirectory);
1136:                }
1137:            }
1138:
1139:            /**
1140:             * Generates the on-line GLCP document info report
1141:             * 
1142:             * @param cDocument the GLCP document to report on
1143:             * @param runDate the date the GLCP was created
1144:             * @see org.kuali.module.gl.service.ReportService#correctionOnlineReport(org.kuali.module.gl.document.CorrectionDocument, java.util.Date)
1145:             */
1146:            public void correctionOnlineReport(CorrectionDocument cDocument,
1147:                    Date runDate) {
1148:                LOG.debug("correctionOnlineReport() started");
1149:
1150:                Font headerFont = FontFactory.getFont(FontFactory.COURIER, 10,
1151:                        Font.BOLD);
1152:                Font sectionFont = FontFactory.getFont(FontFactory.COURIER, 10,
1153:                        Font.BOLD);
1154:                Font textFont = FontFactory.getFont(FontFactory.COURIER, 8,
1155:                        Font.NORMAL);
1156:                Font boldTextFont = FontFactory.getFont(FontFactory.COURIER, 8,
1157:                        Font.BOLD);
1158:
1159:                Document document = new Document(PageSize.A4.rotate());
1160:
1161:                SfPageHelper helper = new SfPageHelper();
1162:                helper.runDate = runDate;
1163:                helper.headerFont = headerFont;
1164:                helper.title = "General Ledger Correction Process Report "
1165:                        + cDocument.getDocumentNumber();
1166:
1167:                try {
1168:                    String filename = reportsDirectory + "/glcp_"
1169:                            + cDocument.getDocumentNumber() + "_";
1170:                    SimpleDateFormat sdf = new SimpleDateFormat(
1171:                            DATE_FORMAT_STRING);
1172:
1173:                    filename = filename + sdf.format(runDate);
1174:                    filename = filename + ".pdf";
1175:                    PdfWriter writer = PdfWriter.getInstance(document,
1176:                            new FileOutputStream(filename));
1177:                    writer.setPageEvent(helper);
1178:
1179:                    document.open();
1180:
1181:                    float[] summaryWidths = { 90, 10 };
1182:                    PdfPTable summary = new PdfPTable(summaryWidths);
1183:
1184:                    PdfPCell cell;
1185:                    cell = new PdfPCell(new Phrase(" ", sectionFont));
1186:                    cell.setColspan(2);
1187:                    cell.setBorder(Rectangle.NO_BORDER);
1188:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1189:                    summary.addCell(cell);
1190:
1191:                    cell = new PdfPCell(new Phrase("Summary of Input Group",
1192:                            sectionFont));
1193:                    cell.setColspan(2);
1194:                    cell.setBorder(Rectangle.NO_BORDER);
1195:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1196:                    summary.addCell(cell);
1197:
1198:                    cell = new PdfPCell(new Phrase("Total Debits: "
1199:                            + cDocument.getCorrectionDebitTotalAmount()
1200:                                    .toString(), textFont));
1201:                    cell.setColspan(2);
1202:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1203:                    summary.addCell(cell);
1204:
1205:                    cell = new PdfPCell(new Phrase("Total Credits: "
1206:                            + cDocument.getCorrectionCreditTotalAmount()
1207:                                    .toString(), textFont));
1208:                    cell.setColspan(2);
1209:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1210:                    summary.addCell(cell);
1211:
1212:                    cell = new PdfPCell(new Phrase("Total No DB/CR: "
1213:                            + cDocument.getCorrectionBudgetTotalAmount()
1214:                                    .toString(), textFont));
1215:                    cell.setColspan(2);
1216:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1217:                    summary.addCell(cell);
1218:
1219:                    cell = new PdfPCell(new Phrase("Row Count: "
1220:                            + cDocument.getCorrectionRowCount(), textFont));
1221:                    cell.setColspan(2);
1222:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1223:                    summary.addCell(cell);
1224:
1225:                    cell = new PdfPCell(new Phrase("System and Edit Method",
1226:                            sectionFont));
1227:                    cell.setColspan(2);
1228:                    cell.setBorder(Rectangle.NO_BORDER);
1229:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1230:                    summary.addCell(cell);
1231:
1232:                    cell = new PdfPCell(new Phrase("System: "
1233:                            + cDocument.getSystem(), textFont));
1234:                    cell.setColspan(2);
1235:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1236:                    summary.addCell(cell);
1237:
1238:                    cell = new PdfPCell(new Phrase("Edit Method: "
1239:                            + cDocument.getMethod(), textFont));
1240:                    cell.setColspan(2);
1241:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1242:                    summary.addCell(cell);
1243:
1244:                    cell = new PdfPCell(new Phrase("Input and Output File",
1245:                            sectionFont));
1246:                    cell.setColspan(2);
1247:                    cell.setBorder(Rectangle.NO_BORDER);
1248:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1249:                    summary.addCell(cell);
1250:
1251:                    cell = new PdfPCell(new Phrase("Input Group ID:"
1252:                            + cDocument.getCorrectionInputGroupId().toString(),
1253:                            textFont));
1254:                    cell.setColspan(2);
1255:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1256:                    summary.addCell(cell);
1257:
1258:                    cell = new PdfPCell(new Phrase(
1259:                            "Output Group ID: "
1260:                                    + cDocument.getCorrectionOutputGroupId()
1261:                                            .toString(), textFont));
1262:                    cell.setColspan(2);
1263:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1264:                    summary.addCell(cell);
1265:
1266:                    if (cDocument.getCorrectionInputFileName() != null) {
1267:                        cell = new PdfPCell(new Phrase("Input File Name: "
1268:                                + cDocument.getCorrectionInputFileName(),
1269:                                textFont));
1270:                        cell.setColspan(2);
1271:                        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1272:                        summary.addCell(cell);
1273:                    }
1274:
1275:                    cell = new PdfPCell(new Phrase("Edit Options and Action",
1276:                            sectionFont));
1277:                    cell.setColspan(2);
1278:                    cell.setBorder(Rectangle.NO_BORDER);
1279:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1280:                    summary.addCell(cell);
1281:
1282:                    String processBatch;
1283:                    String outputOnly;
1284:
1285:                    if (cDocument.getCorrectionFileDelete()) {
1286:                        processBatch = "No";
1287:                    } else {
1288:                        processBatch = "Yes";
1289:                    }
1290:
1291:                    if (cDocument.getCorrectionSelection()) {
1292:                        outputOnly = "Yes";
1293:                    } else {
1294:                        outputOnly = "No";
1295:                    }
1296:
1297:                    cell = new PdfPCell(new Phrase("Process In Batch: "
1298:                            + processBatch, textFont));
1299:                    cell.setColspan(2);
1300:                    // cell.setBorder(Rectangle.NO_BORDER);
1301:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1302:                    summary.addCell(cell);
1303:
1304:                    cell = new PdfPCell(new Phrase(
1305:                            "Output only records which match criteria? "
1306:                                    + outputOnly, textFont));
1307:                    cell.setColspan(2);
1308:                    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1309:                    summary.addCell(cell);
1310:
1311:                    if (cDocument.getCorrectionTypeCode().equals(
1312:                            CorrectionDocumentService.CORRECTION_TYPE_CRITERIA)) {
1313:                        cell = new PdfPCell(new Phrase(
1314:                                "Search Criteria and Modification Criteria",
1315:                                sectionFont));
1316:                        cell.setColspan(2);
1317:                        cell.setBorder(Rectangle.NO_BORDER);
1318:                        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1319:                        summary.addCell(cell);
1320:
1321:                        SearchOperatorsFinder sof = new SearchOperatorsFinder();
1322:
1323:                        for (Iterator ccgi = cDocument
1324:                                .getCorrectionChangeGroup().iterator(); ccgi
1325:                                .hasNext();) {
1326:                            CorrectionChangeGroup ccg = (CorrectionChangeGroup) ccgi
1327:                                    .next();
1328:
1329:                            cell = new PdfPCell(new Phrase("Group",
1330:                                    boldTextFont));
1331:                            cell.setColspan(2);
1332:                            cell.setBorder(Rectangle.NO_BORDER);
1333:                            cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1334:                            summary.addCell(cell);
1335:
1336:                            cell = new PdfPCell(new Phrase("Search Criteria",
1337:                                    boldTextFont));
1338:                            cell.setColspan(2);
1339:                            cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1340:                            summary.addCell(cell);
1341:
1342:                            for (Iterator ccri = ccg.getCorrectionCriteria()
1343:                                    .iterator(); ccri.hasNext();) {
1344:                                CorrectionCriteria cc = (CorrectionCriteria) ccri
1345:                                        .next();
1346:
1347:                                cell = new PdfPCell(new Phrase("Field: "
1348:                                        + cc.getCorrectionFieldName()
1349:                                        + " operator: "
1350:                                        + sof.getKeyLabelMap().get(
1351:                                                cc.getCorrectionOperatorCode())
1352:                                        + " value: "
1353:                                        + cc.getCorrectionFieldValue(),
1354:                                        textFont));
1355:                                cell.setColspan(2);
1356:                                cell
1357:                                        .setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1358:                                summary.addCell(cell);
1359:                            }
1360:
1361:                            cell = new PdfPCell(new Phrase(
1362:                                    "Modification Criteria", boldTextFont));
1363:                            cell.setColspan(2);
1364:                            cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1365:                            summary.addCell(cell);
1366:
1367:                            for (Iterator cchi = ccg.getCorrectionChange()
1368:                                    .iterator(); cchi.hasNext();) {
1369:                                CorrectionChange cc = (CorrectionChange) cchi
1370:                                        .next();
1371:
1372:                                cell = new PdfPCell(new Phrase("Field: "
1373:                                        + cc.getCorrectionFieldName()
1374:                                        + " Replacement Value: "
1375:                                        + cc.getCorrectionFieldValue(),
1376:                                        textFont));
1377:                                cell.setColspan(2);
1378:                                cell
1379:                                        .setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
1380:                                summary.addCell(cell);
1381:                            }
1382:                        }
1383:                    }
1384:                    document.add(summary);
1385:
1386:                } catch (Exception de) {
1387:                    LOG.error("generateReport() Error creating PDF report", de);
1388:                    throw new RuntimeException("Report Generation Failed");
1389:                } finally {
1390:                    document.close();
1391:                }
1392:            }
1393:
1394:            /**
1395:             * Poster output Summary Report: a summary of the three poster runs (pulling in the transactions from the main, reversal, and
1396:             * ICR posters) which we use for balancing.
1397:             * 
1398:             * @param runDate the date the poster run that is being reported on occurred
1399:             * @param groups the origin entry groups created by the poster during its run
1400:             * @see org.kuali.module.gl.service.ReportService#generatePosterInputTransactionSummaryReport(java.util.Date,
1401:             *      java.util.Collection)
1402:             */
1403:            public void generatePosterOutputTransactionSummaryReport(
1404:                    Date runDate, Collection groups) {
1405:                LOG
1406:                        .debug("generatePosterInputTransactionSummaryReport() started");
1407:
1408:                if (groups.size() <= 0) {
1409:                    return;
1410:                }
1411:
1412:                PosterOutputSummaryReport posterInputSummaryReport = new PosterOutputSummaryReport();
1413:                posterInputSummaryReport.generateReport(originEntryService
1414:                        .getPosterOutputSummaryByGroupId(groups), runDate,
1415:                        "Poster Output Summary", "poster_output_summary",
1416:                        reportsDirectory);
1417:            }
1418:
1419:            public void setOriginEntryService(
1420:                    OriginEntryService originEntryService) {
1421:                this .originEntryService = originEntryService;
1422:            }
1423:
1424:            public void setBalanceService(BalanceService bs) {
1425:                balanceService = bs;
1426:            }
1427:
1428:            public void setOptionsService(OptionsService os) {
1429:                optionsService = os;
1430:            }
1431:
1432:            public void setDateTimeService(DateTimeService dts) {
1433:                dateTimeService = dts;
1434:            }
1435:
1436:            public void setKualiConfigurationService(
1437:                    KualiConfigurationService kcs) {
1438:                kualiConfigurationService = kcs;
1439:            }
1440:
1441:            public void setOriginEntryGroupService(
1442:                    OriginEntryGroupService originEntryGroupService) {
1443:                this .originEntryGroupService = originEntryGroupService;
1444:            }
1445:
1446:            public void setReversalService(ReversalService rs) {
1447:                reversalService = rs;
1448:            }
1449:
1450:            public void setPersistenceService(
1451:                    PersistenceService persistenceService) {
1452:                this.persistenceService = persistenceService;
1453:            }
1454:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.