1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.businessobject;
17
18 import java.io.Serializable;
19
20 import org.kuali.ole.coa.businessobject.Account;
21 import org.kuali.ole.coa.businessobject.BalanceType;
22 import org.kuali.ole.coa.businessobject.ObjectCode;
23 import org.kuali.ole.coa.businessobject.ObjectType;
24 import org.kuali.ole.gl.businessobject.Transaction;
25 import org.kuali.ole.sys.OLEConstants;
26 import org.kuali.rice.core.api.util.type.KualiDecimal;
27
28
29
30
31 public class SufficientFundsItem implements Serializable, Comparable {
32 private SystemOptions year;
33 private Account account;
34 private ObjectCode financialObject;
35 private ObjectType financialObjectType;
36 private String sufficientFundsObjectCode;
37 private KualiDecimal amount;
38 private String documentTypeCode;
39 private BalanceType balanceTyp;
40
41 public BalanceType getBalanceTyp() {
42 return balanceTyp;
43 }
44
45 public void setBalanceTyp(BalanceType balanceTyp) {
46 this.balanceTyp = balanceTyp;
47 }
48
49 public SufficientFundsItem() {
50 amount = KualiDecimal.ZERO;
51 }
52
53
54
55
56
57
58
59 public SufficientFundsItem(SystemOptions universityFiscalYear, Transaction tran, String sufficientFundsObjectCode) {
60
61 amount = KualiDecimal.ZERO;
62 year = universityFiscalYear;
63 account = tran.getAccount();
64 financialObject = tran.getFinancialObject();
65 financialObjectType = tran.getObjectType();
66 this.sufficientFundsObjectCode = sufficientFundsObjectCode;
67 this.balanceTyp = tran.getBalanceType();
68
69 add(tran);
70 }
71
72
73
74
75
76
77
78 public SufficientFundsItem(SystemOptions universityFiscalYear, AccountingLine accountLine, String sufficientFundsObjectCode) {
79
80 amount = KualiDecimal.ZERO;
81 year = universityFiscalYear;
82 account = accountLine.getAccount();
83 financialObject = accountLine.getObjectCode();
84 financialObjectType = accountLine.getObjectType();
85 this.sufficientFundsObjectCode = sufficientFundsObjectCode;
86 this.balanceTyp = accountLine.getBalanceTyp();
87
88 add(accountLine);
89 }
90
91
92
93
94
95 public void add(AccountingLine a) {
96 if (a.getObjectType().getFinObjectTypeDebitcreditCd().equals(a.getDebitCreditCode()) || OLEConstants.EMPTY_STRING.equals(a.getDebitCreditCode())) {
97 amount = amount.add(a.getAmount());
98 }
99 else {
100 amount = amount.subtract(a.getAmount());
101 }
102 }
103
104
105
106
107
108 public void add(Transaction t) {
109 if (t.getObjectType().getFinObjectTypeDebitcreditCd().equals(t.getTransactionDebitCreditCode()) || OLEConstants.EMPTY_STRING.equals(t.getTransactionDebitCreditCode())) {
110 amount = amount.add(t.getTransactionLedgerEntryAmount());
111 }
112 else {
113 amount = amount.subtract(t.getTransactionLedgerEntryAmount());
114 }
115 }
116
117
118
119
120
121
122 public int compareTo(Object arg0) {
123 SufficientFundsItem item = (SufficientFundsItem) arg0;
124 return getKey().compareTo(item.getKey());
125 }
126
127
128
129
130
131
132 public String getKey() {
133 return year.getUniversityFiscalYear() + account.getChartOfAccountsCode() + account.getAccountNumber() + financialObjectType.getCode() + sufficientFundsObjectCode + balanceTyp.getCode();
134 }
135
136 public String getDocumentTypeCode() {
137 return documentTypeCode;
138 }
139
140 public void setDocumentTypeCode(String documentTypeCode) {
141 this.documentTypeCode = documentTypeCode;
142 }
143
144 public String getAccountSufficientFundsCode() {
145 return account.getAccountSufficientFundsCode();
146 }
147
148 public ObjectType getFinancialObjectType() {
149 return financialObjectType;
150 }
151
152 public void setFinancialObjectType(ObjectType financialObjectType) {
153 this.financialObjectType = financialObjectType;
154 }
155
156 @Override
157 public String toString() {
158 return year.getUniversityFiscalYear() + "-" + account.getChartOfAccountsCode() + "-" + account.getAccountNumber() + "-" + financialObject.getFinancialObjectCode() + "-" + account.getAccountSufficientFundsCode() + "-" + sufficientFundsObjectCode + "-" + amount.toString();
159 }
160
161 public Account getAccount() {
162 return account;
163 }
164
165 public void setAccount(Account account) {
166 this.account = account;
167 }
168
169 public KualiDecimal getAmount() {
170 return amount;
171 }
172
173 public void setAmount(KualiDecimal amount) {
174 this.amount = amount;
175 }
176
177 public ObjectCode getFinancialObject() {
178 return financialObject;
179 }
180
181 public void setFinancialObject(ObjectCode financialObject) {
182 this.financialObject = financialObject;
183 }
184
185 public String getSufficientFundsObjectCode() {
186 return sufficientFundsObjectCode;
187 }
188
189 public void setSufficientFundsObjectCode(String sufficientFundsObjectCode) {
190 this.sufficientFundsObjectCode = sufficientFundsObjectCode;
191 }
192
193 public SystemOptions getYear() {
194 return year;
195 }
196
197 public void setYear(SystemOptions year) {
198 this.year = year;
199 }
200
201
202 }