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.util.LinkedHashMap;
19 import java.util.List;
20
21 import org.apache.commons.lang.ArrayUtils;
22 import org.kuali.ole.coa.service.ObjectTypeService;
23 import org.kuali.ole.sys.OLEConstants;
24 import org.kuali.ole.sys.OLEKeyConstants;
25 import org.kuali.ole.sys.context.SpringContext;
26 import org.kuali.rice.core.api.config.property.ConfigurationService;
27 import org.kuali.rice.core.api.util.type.KualiDecimal;
28 import org.kuali.rice.krad.bo.TransientBusinessObjectBase;
29
30 public class PosterOutputSummaryTotal extends TransientBusinessObjectBase implements PosterOutputSummaryAmountHolder {
31 private KualiDecimal creditAmount;
32 private KualiDecimal debitAmount;
33 private KualiDecimal budgetAmount;
34 private KualiDecimal netAmount;
35
36 private String objectTypeCode;
37
38 private final String[] assetExpenseObjectTypeCodes;
39
40 public PosterOutputSummaryTotal() {
41 creditAmount = KualiDecimal.ZERO;
42 debitAmount = KualiDecimal.ZERO;
43 budgetAmount = KualiDecimal.ZERO;
44 netAmount = KualiDecimal.ZERO;
45
46 ObjectTypeService objectTypeService = (ObjectTypeService) SpringContext.getBean(ObjectTypeService.class);
47 List<String> objectTypes = objectTypeService.getCurrentYearExpenseObjectTypes();
48 objectTypes.add(objectTypeService.getCurrentYearAssetObjectType());
49
50 assetExpenseObjectTypeCodes = objectTypes.toArray(new String[0]);
51 }
52
53
54
55
56
57
58
59
60 public void addAmount(String debitCreditCode, String objectTypeCode, KualiDecimal amount) {
61
62 if (OLEConstants.GL_CREDIT_CODE.equals(debitCreditCode)) {
63 creditAmount = creditAmount.add(amount);
64 if (ArrayUtils.contains(assetExpenseObjectTypeCodes, objectTypeCode)) {
65 netAmount = netAmount.subtract(amount);
66 }
67 else {
68 netAmount = netAmount.add(amount);
69 }
70 }
71 else if (OLEConstants.GL_DEBIT_CODE.equals(debitCreditCode)) {
72 debitAmount = debitAmount.add(amount);
73 if (ArrayUtils.contains(assetExpenseObjectTypeCodes, objectTypeCode)) {
74 netAmount = netAmount.add(amount);
75 }
76 else {
77 netAmount = netAmount.subtract(amount);
78 }
79 }
80 else {
81 netAmount = netAmount.add(amount);
82 budgetAmount = budgetAmount.add(amount);
83 }
84 }
85
86
87
88
89
90 public void addAmount(PosterOutputSummaryEntry entry) {
91 debitAmount = debitAmount.add(entry.getDebitAmount());
92 creditAmount = creditAmount.add(entry.getCreditAmount());
93 budgetAmount = budgetAmount.add(entry.getBudgetAmount());
94 netAmount = netAmount.add(entry.getNetAmount());
95 }
96
97 public KualiDecimal getBudgetAmount() {
98 return budgetAmount;
99 }
100
101 public KualiDecimal getCreditAmount() {
102 return creditAmount;
103 }
104
105 public KualiDecimal getDebitAmount() {
106 return debitAmount;
107 }
108
109 public KualiDecimal getNetAmount() {
110 return netAmount;
111 }
112
113 public String getObjectTypeCode() {
114 return objectTypeCode;
115 }
116
117 public void setObjectTypeCode(String objectTypeCode) {
118 this.objectTypeCode = objectTypeCode;
119 }
120
121
122
123
124 public String getSummary() {
125 return SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(OLEKeyConstants.MESSAGE_REPORT_POSTER_OUTPUT_SUMMARY_TOTAL);
126 }
127
128
129
130
131
132
133 protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
134 LinkedHashMap pks = new LinkedHashMap<String, Object>();
135 pks.put("objectTypeCode",this.getObjectTypeCode());
136 pks.put("creditAmount",this.getCreditAmount());
137 pks.put("debitAmount",this.getDebitAmount());
138 pks.put("budgetAmount",this.getBudgetAmount());
139 pks.put("netAmount",this.getNetAmount());
140 return pks;
141 }
142
143 }