1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kfs.coa.businessobject;
17
18 import java.sql.Date;
19 import java.util.Calendar;
20 import java.util.LinkedHashMap;
21 import java.util.List;
22
23 import org.apache.commons.lang.StringUtils;
24 import org.apache.commons.lang.time.DateUtils;
25 import org.kuali.rice.core.api.mo.common.active.Inactivatable;
26 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
27
28
29
30
31 public class Account extends PersistableBusinessObjectBase implements Inactivatable {
32 protected static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(Account.class);
33
34 private String chartOfAccountsCode;
35 private String accountNumber;
36 private String accountName;
37 private Date accountCreateDate;
38 private Date accountEffectiveDate;
39 private Date accountExpirationDate;
40 private boolean active;
41 private String organizationCode;
42
43
44 public String getOrganizationCode() {
45 return organizationCode;
46 }
47
48 public void setOrganizationCode(String organizationCode) {
49 this.organizationCode = organizationCode;
50 }
51
52
53 private Chart chartOfAccounts;
54 private Organization organization;
55
56 private List subAccounts;
57
58
59
60
61 public Account() {
62 active = true;
63 }
64
65
66
67
68
69
70
71 public String getAccountNumber() {
72 return accountNumber;
73 }
74
75
76
77
78
79
80 public void setAccountNumber(String accountNumber) {
81 this.accountNumber = accountNumber;
82 }
83
84
85
86
87
88
89 public String getAccountName() {
90 return accountName;
91 }
92
93
94
95
96
97
98 public void setAccountName(String accountName) {
99 this.accountName = accountName;
100 }
101
102
103
104
105
106
107 public Date getAccountCreateDate() {
108 return accountCreateDate;
109 }
110
111
112
113
114
115
116 public void setAccountCreateDate(Date accountCreateDate) {
117 this.accountCreateDate = accountCreateDate;
118 }
119
120
121
122
123
124
125 public Date getAccountEffectiveDate() {
126 return accountEffectiveDate;
127 }
128
129
130
131
132
133
134 public void setAccountEffectiveDate(Date accountEffectiveDate) {
135 this.accountEffectiveDate = accountEffectiveDate;
136 }
137
138
139
140
141
142
143 public Date getAccountExpirationDate() {
144 return accountExpirationDate;
145 }
146
147
148
149
150
151
152 public void setAccountExpirationDate(Date accountExpirationDate) {
153 this.accountExpirationDate = accountExpirationDate;
154 }
155
156
157
158
159
160
161
162
163
164
165
166 public boolean isExpired(Calendar testDate) {
167 if (LOG.isDebugEnabled()) {
168 LOG.debug("entering isExpired(" + testDate + ")");
169 }
170
171
172 if (this.accountExpirationDate == null) {
173 return false;
174 }
175
176
177 testDate = DateUtils.truncate(testDate, Calendar.DAY_OF_MONTH);
178
179
180
181 Calendar acctDate = Calendar.getInstance();
182 acctDate.setTime(this.accountExpirationDate);
183 acctDate = DateUtils.truncate(acctDate, Calendar.DAY_OF_MONTH);
184
185
186 if (acctDate.before(testDate)) {
187 return true;
188 }
189 else {
190 return false;
191 }
192 }
193
194
195
196
197
198
199
200
201
202
203
204 public boolean isExpired(Date testDate) {
205
206
207 if (this.accountExpirationDate == null) {
208 return false;
209 }
210
211 Calendar acctDate = Calendar.getInstance();
212 acctDate.setTime(testDate);
213 return isExpired(acctDate);
214 }
215
216
217
218
219
220
221 public boolean isActive() {
222 return active;
223 }
224
225
226
227
228
229
230 public void setActive(boolean active) {
231 this.active = active;
232 }
233
234
235
236
237
238
239 public boolean isClosed() {
240 return !active;
241 }
242
243
244
245
246
247
248 public void setClosed(boolean closed) {
249 this.active = !closed;
250 }
251
252
253
254
255
256
257 public Chart getChartOfAccounts() {
258 return chartOfAccounts;
259 }
260
261
262
263
264
265
266
267 public void setChartOfAccounts(Chart chartOfAccounts) {
268 this.chartOfAccounts = chartOfAccounts;
269 }
270
271
272
273
274
275
276 public Organization getOrganization() {
277 return organization;
278 }
279
280
281
282
283
284
285
286 public void setOrganization(Organization organization) {
287 this.organization = organization;
288 }
289
290
291
292
293 public List getSubAccounts() {
294 return subAccounts;
295 }
296
297
298
299
300
301 public void setSubAccounts(List subAccounts) {
302 this.subAccounts = subAccounts;
303 }
304
305
306
307
308
309 public String getChartOfAccountsCode() {
310 return chartOfAccountsCode;
311 }
312
313
314
315
316
317 public void setChartOfAccountsCode(String chartOfAccountsCode) {
318 this.chartOfAccountsCode = chartOfAccountsCode;
319 }
320
321
322
323
324 protected LinkedHashMap toStringMapper() {
325 LinkedHashMap m = new LinkedHashMap();
326
327 m.put("chartCode", this.chartOfAccountsCode);
328 m.put("accountNumber", this.accountNumber);
329
330 return m;
331 }
332
333
334
335
336
337
338
339 public boolean equals(Object obj) {
340 boolean equal = false;
341
342 if (obj != null) {
343 if (this.getClass().equals(obj.getClass())) {
344 Account other = (Account) obj;
345
346 if (StringUtils.equals(this.getChartOfAccountsCode(), other.getChartOfAccountsCode())) {
347 if (StringUtils.equals(this.getAccountNumber(), other.getAccountNumber())) {
348 equal = true;
349 }
350 }
351 }
352 }
353
354 return equal;
355 }
356
357
358
359
360
361
362
363
364 public int hashCode() {
365 String hashString = getChartOfAccountsCode() + "|" + getAccountNumber();
366
367 return hashString.hashCode();
368 }
369
370
371
372
373
374
375
376
377 public String getAccountKey() {
378 String key = getChartOfAccountsCode() + ":" + getAccountNumber();
379 return key;
380 }
381 }
382