1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.gl.businessobject;
17
18 import org.kuali.ole.sys.OLEConstants;
19 import org.kuali.rice.core.api.util.type.KualiDecimal;
20
21
22
23
24 public class LedgerEntry {
25
26 private String balanceType;
27 private String originCode;
28 private Integer fiscalYear;
29 private String period;
30 private int recordCount;
31 private KualiDecimal debitAmount;
32 private int debitCount;
33 private KualiDecimal creditAmount;
34 private int creditCount;
35 private KualiDecimal noDCAmount;
36 private int noDCCount;
37
38
39
40
41 public LedgerEntry() {
42 this(null, null, null, null);
43 }
44
45
46
47
48
49
50
51
52
53 public LedgerEntry(Integer fiscalYear, String period, String balanceType, String originCode) {
54 this.fiscalYear = fiscalYear;
55 this.period = period;
56 this.balanceType = balanceType;
57 this.originCode = originCode;
58
59 this.creditAmount = KualiDecimal.ZERO;
60 this.debitAmount = KualiDecimal.ZERO;
61 this.noDCAmount = KualiDecimal.ZERO;
62 }
63
64
65
66
67
68
69
70
71
72
73
74
75 public LedgerEntry(Integer fiscalYear, String period, String balanceType, String originCode, String debitCreditCode, KualiDecimal amount, int count) {
76 this.fiscalYear = fiscalYear;
77 this.period = period;
78 this.balanceType = balanceType;
79 this.originCode = originCode;
80
81 if (OLEConstants.GL_CREDIT_CODE.equals(debitCreditCode)) {
82 this.creditAmount = amount;
83 this.creditCount = count;
84 }
85 else if (OLEConstants.GL_DEBIT_CODE.equals(debitCreditCode)) {
86 this.debitAmount = amount;
87 this.debitCount = count;
88 }
89 else {
90 this.noDCAmount = amount;
91 this.noDCCount = count;
92 }
93
94 this.recordCount = count;
95 }
96
97
98
99
100
101
102 public void add(LedgerEntry addend) {
103 this.creditAmount = this.creditAmount.add(addend.getCreditAmount());
104 this.creditCount += addend.getCreditCount();
105
106 this.debitAmount = this.debitAmount.add(addend.getDebitAmount());
107 this.debitCount += addend.getDebitCount();
108
109 this.noDCAmount = this.noDCAmount.add(addend.getNoDCAmount());
110 this.noDCCount += addend.getNoDCCount();
111
112 this.recordCount = this.creditCount + this.debitCount + this.noDCCount;
113 }
114
115
116
117
118
119
120
121 public static LedgerEntry buildLedgerEntry(Object[] entrySummary) {
122
123 Object oFiscalYear = entrySummary[0];
124 Object oPeriodCode = entrySummary[1];
125 Object oBalanceType = entrySummary[2];
126 Object oOriginCode = entrySummary[3];
127 Object oDebitCreditCode = entrySummary[4];
128 Object oAmount = entrySummary[5];
129 Object oCount = entrySummary[6];
130
131 Integer fiscalYear = oFiscalYear != null ? new Integer(oFiscalYear.toString()) : null;
132 String periodCode = oPeriodCode != null ? oPeriodCode.toString() : " ";
133 String balanceType = oBalanceType != null ? oBalanceType.toString() : " ";
134 String originCode = oOriginCode != null ? oOriginCode.toString() : " ";
135 String debitCreditCode = oDebitCreditCode != null ? oDebitCreditCode.toString() : " ";
136 KualiDecimal amount = oAmount != null ? new KualiDecimal(oAmount.toString()) : KualiDecimal.ZERO;
137 int count = oCount != null ? Integer.parseInt(oCount.toString()) : 0;
138
139
140 LedgerEntry ledgerEntry = new LedgerEntry(fiscalYear, periodCode, balanceType, originCode);
141 if (OLEConstants.GL_CREDIT_CODE.equals(debitCreditCode)) {
142 ledgerEntry.setCreditAmount(amount);
143 ledgerEntry.setCreditCount(count);
144 }
145 else if (OLEConstants.GL_DEBIT_CODE.equals(debitCreditCode)) {
146 ledgerEntry.setDebitAmount(amount);
147 ledgerEntry.setDebitCount(count);
148 }
149 else {
150 ledgerEntry.setNoDCAmount(amount);
151 ledgerEntry.setNoDCCount(count);
152 }
153 ledgerEntry.setRecordCount(count);
154
155 return ledgerEntry;
156 }
157
158
159
160
161
162
163 public String getBalanceType() {
164 return balanceType;
165 }
166
167
168
169
170
171
172 public void setBalanceType(String balanceType) {
173 this.balanceType = balanceType;
174 }
175
176
177
178
179
180
181 public KualiDecimal getCreditAmount() {
182 return creditAmount;
183 }
184
185
186
187
188
189
190 public void setCreditAmount(KualiDecimal creditAmount) {
191 this.creditAmount = creditAmount;
192 }
193
194
195
196
197
198
199 public int getCreditCount() {
200 return creditCount;
201 }
202
203
204
205
206
207
208 public void setCreditCount(int creditCount) {
209 this.creditCount = creditCount;
210 }
211
212
213
214
215
216
217 public KualiDecimal getDebitAmount() {
218 return debitAmount;
219 }
220
221
222
223
224
225
226 public void setDebitAmount(KualiDecimal debitAmount) {
227 this.debitAmount = debitAmount;
228 }
229
230
231
232
233
234
235 public int getDebitCount() {
236 return debitCount;
237 }
238
239
240
241
242
243
244 public void setDebitCount(int debitCount) {
245 this.debitCount = debitCount;
246 }
247
248
249
250
251
252
253 public Integer getFiscalYear() {
254 return fiscalYear;
255 }
256
257
258
259
260
261
262 public void setFiscalYear(Integer fiscalYear) {
263 this.fiscalYear = fiscalYear;
264 }
265
266
267
268
269
270
271 public KualiDecimal getNoDCAmount() {
272 return noDCAmount;
273 }
274
275
276
277
278
279
280 public void setNoDCAmount(KualiDecimal noDCAmount) {
281 this.noDCAmount = noDCAmount;
282 }
283
284
285
286
287
288
289 public int getNoDCCount() {
290 return noDCCount;
291 }
292
293
294
295
296
297
298 public void setNoDCCount(int noDCCount) {
299 this.noDCCount = noDCCount;
300 }
301
302
303
304
305
306
307 public String getOriginCode() {
308 return originCode;
309 }
310
311
312
313
314
315
316 public void setOriginCode(String originCode) {
317 this.originCode = originCode;
318 }
319
320
321
322
323
324
325 public String getPeriod() {
326 return period;
327 }
328
329
330
331
332
333
334 public void setPeriod(String period) {
335 this.period = period;
336 }
337
338
339
340
341
342
343 public int getRecordCount() {
344 return recordCount;
345 }
346
347
348
349
350
351
352 public void setRecordCount(int recordCount) {
353 this.recordCount = recordCount;
354 }
355
356
357
358
359 public String toString() {
360 StringBuffer ledgerEntryDescription = new StringBuffer();
361
362 ledgerEntryDescription.append(fiscalYear + "\t");
363 ledgerEntryDescription.append(period + "\t");
364 ledgerEntryDescription.append(balanceType + "\t");
365 ledgerEntryDescription.append(originCode + "\t");
366 ledgerEntryDescription.append(recordCount + "\t");
367
368 ledgerEntryDescription.append(debitAmount + "\t\t");
369 ledgerEntryDescription.append(debitCount + "\t");
370
371 ledgerEntryDescription.append(creditAmount + "\t\t");
372 ledgerEntryDescription.append(creditCount + "\t");
373
374 ledgerEntryDescription.append(noDCAmount + "\t\t");
375 ledgerEntryDescription.append(noDCCount + "\t");
376
377 return ledgerEntryDescription.toString();
378 }
379 }