1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.gl.report;
17
18 import java.util.Iterator;
19
20 import org.kuali.ole.gl.businessobject.Transaction;
21 import org.kuali.ole.sys.OLEConstants;
22 import org.kuali.ole.sys.service.ReportWriterService;
23 import org.kuali.rice.core.api.util.type.KualiDecimal;
24
25
26
27
28
29
30 public class TransactionListingReport {
31 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(TransactionListingReport.class);
32
33 protected int transactionCount;
34 protected KualiDecimal debitTotal;
35 protected KualiDecimal creditTotal;
36 protected KualiDecimal budgetTotal;
37
38 public TransactionListingReport() {
39 super();
40
41 transactionCount = 0;
42 debitTotal = KualiDecimal.ZERO;
43 creditTotal = KualiDecimal.ZERO;
44 budgetTotal = KualiDecimal.ZERO;
45 }
46
47
48
49
50
51
52
53
54 public void generateReport(ReportWriterService reportWriterService, Transaction transaction) {
55 LOG.debug("generateReport() started");
56
57 if (transaction != null) {
58 if (transactionCount == 0) {
59 reportWriterService.writeTableHeader(transaction);
60 }
61
62 reportWriterService.writeTableRow(transaction);
63
64 if (OLEConstants.GL_DEBIT_CODE.equals(transaction.getTransactionDebitCreditCode())) {
65 debitTotal = debitTotal.add(transaction.getTransactionLedgerEntryAmount());
66 }
67 if (OLEConstants.GL_CREDIT_CODE.equals(transaction.getTransactionDebitCreditCode())) {
68 creditTotal = creditTotal.add(transaction.getTransactionLedgerEntryAmount());
69 }
70 if (!OLEConstants.GL_CREDIT_CODE.equals(transaction.getTransactionDebitCreditCode()) && !OLEConstants.GL_DEBIT_CODE.equals(transaction.getTransactionDebitCreditCode())) {
71 budgetTotal = budgetTotal.add(transaction.getTransactionLedgerEntryAmount());
72 }
73 transactionCount++;
74 }
75 }
76
77
78
79
80
81
82 public void generateStatistics(ReportWriterService reportWriterService) {
83 LOG.debug("generateStatistics() started");
84
85 reportWriterService.writeStatisticLine("Total Transactions %,9d", transactionCount);
86 reportWriterService.writeStatisticLine("Total Debit Amount %,9.2f", debitTotal.doubleValue());
87 reportWriterService.writeStatisticLine("Total Credit Amount %,9.2f", creditTotal.doubleValue());
88 reportWriterService.writeStatisticLine("Total Budget Amount %,9.2f", budgetTotal.doubleValue());
89 }
90
91
92
93
94
95
96
97 public void generateReport(ReportWriterService reportWriterService, Iterator<? extends Transaction> transactions) {
98 LOG.debug("generateReport() started");
99
100 if (transactions != null) {
101 while (transactions.hasNext()) {
102 Transaction tran = (Transaction) transactions.next();
103
104 this.generateReport(reportWriterService, tran);
105 }
106 }
107
108 this.generateStatistics(reportWriterService);
109 }
110 }