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 java.math.BigDecimal;
19 import java.sql.Date;
20 import java.util.LinkedHashMap;
21 import java.util.Map;
22
23 import org.kuali.ole.coa.businessobject.A21SubAccount;
24 import org.kuali.ole.coa.businessobject.Account;
25 import org.kuali.ole.coa.businessobject.Chart;
26 import org.kuali.ole.coa.businessobject.ObjectCode;
27 import org.kuali.ole.coa.businessobject.SubAccount;
28 import org.kuali.ole.coa.businessobject.SubObjectCode;
29 import org.kuali.ole.gl.GeneralLedgerConstants;
30 import org.kuali.ole.sys.OLEPropertyConstants;
31 import org.kuali.ole.sys.businessobject.ReportBusinessObject;
32 import org.kuali.ole.sys.businessobject.SystemOptions;
33 import org.kuali.ole.sys.context.SpringContext;
34 import org.kuali.rice.core.api.util.type.KualiDecimal;
35 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
36 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
37 import org.kuali.rice.krad.util.ObjectUtils;
38
39
40
41
42
43 public class AccountBalance extends PersistableBusinessObjectBase implements ReportBusinessObject{
44 static final long serialVersionUID = 6873573726961704771L;
45
46 private Integer universityFiscalYear;
47 private String chartOfAccountsCode;
48 private String accountNumber;
49 private String subAccountNumber;
50 private String objectCode;
51 private String subObjectCode;
52 private KualiDecimal currentBudgetLineBalanceAmount;
53 private KualiDecimal accountLineActualsBalanceAmount;
54 private KualiDecimal accountLineEncumbranceBalanceAmount;
55 private Date timestamp;
56
57 private Chart chart;
58 private Account account;
59 private SubAccount subAccount;
60 private ObjectCode financialObject;
61 private SubObjectCode financialSubObject;
62 private A21SubAccount a21SubAccount;
63 private TransientBalanceInquiryAttributes dummyBusinessObject;
64 private SystemOptions option;
65 private String title;
66
67 public static final String TYPE_CONSOLIDATION = "Consolidation";
68 public static final String TYPE_LEVEL = "Level";
69 public static final String TYPE_OBJECT = "Object";
70
71 public AccountBalance() {
72 super();
73 this.dummyBusinessObject = new TransientBalanceInquiryAttributes();
74 this.financialObject = new ObjectCode();
75 }
76
77 public AccountBalance(Transaction t) {
78 this();
79 universityFiscalYear = t.getUniversityFiscalYear();
80 chartOfAccountsCode = t.getChartOfAccountsCode();
81 accountNumber = t.getAccountNumber();
82 subAccountNumber = t.getSubAccountNumber();
83 objectCode = t.getFinancialObjectCode();
84 subObjectCode = t.getFinancialSubObjectCode();
85 currentBudgetLineBalanceAmount = KualiDecimal.ZERO;
86 accountLineActualsBalanceAmount = KualiDecimal.ZERO;
87 accountLineEncumbranceBalanceAmount = KualiDecimal.ZERO;
88 }
89
90 public AccountBalance(String type, Map data, Integer universityFiscalYear, String chartOfAccountsCode, String accountNumber) {
91 this();
92
93 this.universityFiscalYear = universityFiscalYear;
94 this.chartOfAccountsCode = chartOfAccountsCode;
95 this.accountNumber = accountNumber;
96 subAccountNumber = (String) data.get(GeneralLedgerConstants.ColumnNames.SUB_ACCOUNT_NUMBER);
97
98 currentBudgetLineBalanceAmount = new KualiDecimal((BigDecimal) data.get(GeneralLedgerConstants.ColumnNames.CURRENT_BDLN_BALANCE_AMOUNT));
99 accountLineActualsBalanceAmount = new KualiDecimal((BigDecimal) data.get(GeneralLedgerConstants.ColumnNames.ACCOUNTING_LINE_ACTUALS_BALANCE_AMOUNT));
100 accountLineEncumbranceBalanceAmount = new KualiDecimal((BigDecimal) data.get(GeneralLedgerConstants.ColumnNames.ACCOUNTING_LINE_ENCUMBRANCE_BALANCE_AMOUNT));
101
102 financialObject.getFinancialObjectLevel().setFinancialConsolidationObjectCode((String) data.get(GeneralLedgerConstants.ColumnNames.CONSOLIDATION_OBJECT_CODE));
103 financialObject.getFinancialObjectLevel().getFinancialConsolidationObject().setFinConsolidationObjectCode((String) data.get(GeneralLedgerConstants.ColumnNames.CONSOLIDATION_OBJECT_CODE));
104
105 if (TYPE_CONSOLIDATION.equals(type)) {
106 financialObject.getFinancialObjectType().setFinancialReportingSortCode((String) data.get(GeneralLedgerConstants.ColumnNames.REPORT_SORT_CODE));
107 financialObject.getFinancialObjectLevel().getFinancialConsolidationObject().setFinancialReportingSortCode((String) data.get(GeneralLedgerConstants.ColumnNames.CONSOLIDATION_REPORT_SORT_CODE));
108
109 financialObject.getFinancialObjectType().setBasicAccountingCategoryCode((String) data.get(GeneralLedgerConstants.ColumnNames.ACCTG_CTGRY_CD));
110 fixVariance();
111 }
112 else if (TYPE_LEVEL.equals(type)) {
113 financialObject.getFinancialObjectLevel().setFinancialReportingSortCode((String) data.get(GeneralLedgerConstants.ColumnNames.REPORT_SORT_CODE));
114 financialObject.setFinancialObjectLevelCode((String) data.get(GeneralLedgerConstants.ColumnNames.OBJECT_LEVEL_CODE2));
115 financialObject.getFinancialObjectLevel().setFinancialObjectLevelCode((String) data.get(GeneralLedgerConstants.ColumnNames.OBJECT_LEVEL_CODE2));
116
117
118 financialObject.getFinancialObjectType().setBasicAccountingCategoryCode((String) data.get(GeneralLedgerConstants.ColumnNames.ACCTG_CTGRY_CD));
119 fixVariance();
120 }
121 else if (TYPE_OBJECT.equals(type)) {
122 objectCode = (String) data.get(GeneralLedgerConstants.ColumnNames.OBJECT_CODE);
123 financialObject.setFinancialObjectLevelCode((String) data.get(GeneralLedgerConstants.ColumnNames.OBJECT_LEVEL_CODE));
124 financialObject.getFinancialObjectLevel().setFinancialObjectLevelCode((String) data.get(GeneralLedgerConstants.ColumnNames.OBJECT_LEVEL_CODE));
125
126
127 financialObject.getFinancialObjectType().setBasicAccountingCategoryCode((String) data.get(GeneralLedgerConstants.ColumnNames.ACCTG_CTGRY_CD));
128 fixVariance();
129 }
130 else {
131 throw new RuntimeException("Unknown type: " + type);
132 }
133 }
134
135
136
137
138
139
140
141
142
143
144
145 @Override
146 public void refreshNonUpdateableForReport() {
147
148 ObjectCode origfinancialObject = getFinancialObject();
149 super.refreshNonUpdateableReferences();
150
151 if (ObjectUtils.isNull(financialObject)){
152
153 setFinancialObject(origfinancialObject);
154 }else{
155
156
157
158 if (ObjectUtils.isNull(financialObject.getFinancialObjectLevel()) || ObjectUtils.isNull(financialObject.getFinancialObjectLevel().getFinancialObjectLevelCode())){
159 financialObject.setFinancialObjectLevel(origfinancialObject.getFinancialObjectLevel());
160 financialObject.setFinancialObjectLevelCode(origfinancialObject.getFinancialObjectCode());
161 }
162
163 if (ObjectUtils.isNull(financialObject.getFinancialObjectType().getCode()) || ObjectUtils.isNull(financialObject.getFinancialObjectType())){
164 financialObject.setFinancialObjectType(origfinancialObject.getFinancialObjectType());
165 }
166 }
167 }
168
169
170
171
172
173
174 public String getAccountingCategoryExpenseCode(){
175 ParameterService parameterService = SpringContext.getBean(ParameterService.class);
176 String accountingCategoryExpenseCode = parameterService.getParameterValueAsString(AccountBalanceByConsolidation.class, GeneralLedgerConstants.BASIC_ACCOUNTING_CATEGORY_REPRESENTING_EXPENSES);
177 return accountingCategoryExpenseCode;
178 }
179
180 public AccountBalance(String title) {
181 this();
182 this.title = title;
183
184 currentBudgetLineBalanceAmount = KualiDecimal.ZERO;
185 accountLineActualsBalanceAmount = KualiDecimal.ZERO;
186 accountLineEncumbranceBalanceAmount = KualiDecimal.ZERO;
187 }
188
189
190
191
192
193 public AccountBalance(AccountBalanceHistory accountBalanceHistory) {
194 universityFiscalYear = accountBalanceHistory.getUniversityFiscalYear();
195 chartOfAccountsCode = accountBalanceHistory.getChartOfAccountsCode();
196 accountNumber = accountBalanceHistory.getAccountNumber();
197 subAccountNumber = accountBalanceHistory.getSubAccountNumber();
198 objectCode = accountBalanceHistory.getObjectCode();
199 subObjectCode = accountBalanceHistory.getSubObjectCode();
200 }
201
202 public void fixVariance() {
203 dummyBusinessObject.setGenericAmount(getVariance());
204 }
205
206 public KualiDecimal getVariance() {
207
208 KualiDecimal variance = KualiDecimal.ZERO;
209
210
211 if (getAccountingCategoryExpenseCode().equals(financialObject.getFinancialObjectType().getBasicAccountingCategoryCode())) {
212 variance = currentBudgetLineBalanceAmount.subtract(accountLineActualsBalanceAmount);
213 variance = variance.subtract(accountLineEncumbranceBalanceAmount);
214 }
215 else {
216 variance = accountLineActualsBalanceAmount.subtract(currentBudgetLineBalanceAmount);
217 }
218 return variance;
219 }
220
221 public void add(AccountBalance ab) {
222 currentBudgetLineBalanceAmount = currentBudgetLineBalanceAmount.add(ab.currentBudgetLineBalanceAmount);
223 accountLineActualsBalanceAmount = accountLineActualsBalanceAmount.add(ab.accountLineActualsBalanceAmount);
224 accountLineEncumbranceBalanceAmount = accountLineEncumbranceBalanceAmount.add(ab.accountLineEncumbranceBalanceAmount);
225 }
226
227
228
229
230
231
232 protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
233
234 LinkedHashMap map = new LinkedHashMap();
235 map.put(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, getUniversityFiscalYear());
236 map.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, getChartOfAccountsCode());
237 map.put(OLEPropertyConstants.ACCOUNT_NUMBER, getAccountNumber());
238 map.put(OLEPropertyConstants.SUB_ACCOUNT_NUMBER, getSubAccountNumber());
239 map.put(OLEPropertyConstants.OBJECT_CODE, getObjectCode());
240 map.put(OLEPropertyConstants.SUB_OBJECT_CODE, getSubObjectCode());
241 return map;
242 }
243
244 public String getTitle() {
245 return title;
246 }
247
248 public A21SubAccount getA21SubAccount() {
249 return a21SubAccount;
250 }
251
252 public void setA21SubAccount(A21SubAccount subAccount) {
253 a21SubAccount = subAccount;
254 }
255
256 public SystemOptions getOption() {
257 return option;
258 }
259
260 public void setOption(SystemOptions option) {
261 this.option = option;
262 }
263
264 public KualiDecimal getAccountLineActualsBalanceAmount() {
265 return accountLineActualsBalanceAmount;
266 }
267
268 public void setAccountLineActualsBalanceAmount(KualiDecimal accountLineActualsBalanceAmount) {
269 this.accountLineActualsBalanceAmount = accountLineActualsBalanceAmount;
270 }
271
272 public KualiDecimal getAccountLineEncumbranceBalanceAmount() {
273 return accountLineEncumbranceBalanceAmount;
274 }
275
276 public void setAccountLineEncumbranceBalanceAmount(KualiDecimal accountLineEncumbranceBalanceAmount) {
277 this.accountLineEncumbranceBalanceAmount = accountLineEncumbranceBalanceAmount;
278 }
279
280 public String getAccountNumber() {
281 return accountNumber;
282 }
283
284 public void setAccountNumber(String accountNumber) {
285 this.accountNumber = accountNumber;
286 }
287
288 public String getChartOfAccountsCode() {
289 return chartOfAccountsCode;
290 }
291
292 public void setChartOfAccountsCode(String chartOfAccountsCode) {
293 this.chartOfAccountsCode = chartOfAccountsCode;
294 }
295
296 public KualiDecimal getCurrentBudgetLineBalanceAmount() {
297 return currentBudgetLineBalanceAmount;
298 }
299
300 public void setCurrentBudgetLineBalanceAmount(KualiDecimal currentBudgetLineBalanceAmount) {
301 this.currentBudgetLineBalanceAmount = currentBudgetLineBalanceAmount;
302 }
303
304 public String getObjectCode() {
305 return objectCode;
306 }
307
308 public void setObjectCode(String objectCode) {
309 this.objectCode = objectCode;
310 }
311
312 public String getSubAccountNumber() {
313 return subAccountNumber;
314 }
315
316 public void setSubAccountNumber(String subAccountNumber) {
317 this.subAccountNumber = subAccountNumber;
318 }
319
320 public String getSubObjectCode() {
321 return subObjectCode;
322 }
323
324 public void setSubObjectCode(String subObjectCode) {
325 this.subObjectCode = subObjectCode;
326 }
327
328 public Date getTimestamp() {
329 return timestamp;
330 }
331
332 public void setTimestamp(Date timestamp) {
333 this.timestamp = timestamp;
334 }
335
336 public Integer getUniversityFiscalYear() {
337 return universityFiscalYear;
338 }
339
340 public void setUniversityFiscalYear(Integer universityFiscalYear) {
341 this.universityFiscalYear = universityFiscalYear;
342 }
343
344
345
346
347
348
349 public Account getAccount() {
350 return account;
351 }
352
353
354
355
356
357
358 public void setAccount(Account account) {
359 this.account = account;
360 }
361
362
363
364
365
366
367 public Chart getChart() {
368 return chart;
369 }
370
371
372
373
374
375
376 public void setChart(Chart chart) {
377 this.chart = chart;
378 }
379
380
381
382
383
384
385 public ObjectCode getFinancialObject() {
386 return financialObject;
387 }
388
389
390
391
392
393
394 public void setFinancialObject(ObjectCode financialObject) {
395 this.financialObject = financialObject;
396 }
397
398
399
400
401
402
403 public TransientBalanceInquiryAttributes getDummyBusinessObject() {
404 return dummyBusinessObject;
405 }
406
407
408
409
410
411
412 public void setDummyBusinessObject(TransientBalanceInquiryAttributes dummyBusinessObject) {
413 this.dummyBusinessObject = dummyBusinessObject;
414 }
415
416
417
418
419
420
421 public SubAccount getSubAccount() {
422 return subAccount;
423 }
424
425
426
427
428
429
430 public void setSubAccount(SubAccount subAccount) {
431 this.subAccount = subAccount;
432 }
433
434
435
436
437
438
439 public SubObjectCode getFinancialSubObject() {
440 return financialSubObject;
441 }
442
443
444
445
446
447
448 public void setFinancialSubObject(SubObjectCode financialSubObject) {
449 this.financialSubObject = financialSubObject;
450 }
451
452 }