001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.kfs.module.endow.businessobject;
017
018 import java.math.BigDecimal;
019 import java.sql.Date;
020 import java.util.LinkedHashMap;
021
022 import org.kuali.kfs.module.endow.EndowPropertyConstants;
023 import org.kuali.kfs.module.endow.document.service.KEMService;
024 import org.kuali.kfs.sys.context.SpringContext;
025 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
026 import org.kuali.rice.kns.util.KualiInteger;
027
028 /**
029 * Business Object for Holding Tax Lot table
030 */
031 public class HoldingTaxLot extends PersistableBusinessObjectBase {
032
033 private String kemid;
034 private String securityId;
035 private String registrationCode;
036 private KualiInteger lotNumber;
037 private String incomePrincipalIndicator;
038 private Date acquiredDate;
039 private BigDecimal units = BigDecimal.ZERO;
040 private BigDecimal cost = BigDecimal.ZERO;
041 private BigDecimal currentAccrual = BigDecimal.ZERO;
042 private BigDecimal priorAccrual = BigDecimal.ZERO;
043 private Date lastTransactionDate;
044
045 private KEMID kemidObj;
046 private Security security;
047 private IncomePrincipalIndicator incomePrincipal;
048 private RegistrationCode registration;
049
050 /**
051 * Constructs a HoldingTaxLot.java.
052 */
053 public HoldingTaxLot() {
054 super();
055 }
056
057 /**
058 * Gets the incomePrincipal.
059 *
060 * @return incomePrincipal
061 */
062 public IncomePrincipalIndicator getIncomePrincipal() {
063 return incomePrincipal;
064 }
065
066 /**
067 * Sets the incomePrincipal.
068 *
069 * @param incomePrincipal
070 */
071 public void setIncomePrincipal(IncomePrincipalIndicator incomePrincipal) {
072 this.incomePrincipal = incomePrincipal;
073 }
074
075 /**
076 * Gets the security
077 *
078 * @return security
079 */
080 public Security getSecurity() {
081 return security;
082 }
083
084 /**
085 * Sets the security.
086 *
087 * @param security
088 */
089 public void setSecurity(Security security) {
090 this.security = security;
091 }
092
093 /**
094 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
095 */
096 @Override
097 protected LinkedHashMap toStringMapper() {
098 LinkedHashMap m = new LinkedHashMap();
099 m.put(EndowPropertyConstants.HOLDING_TAX_LOT_KEMID, this.kemid);
100 m.put(EndowPropertyConstants.HOLDING_TAX_LOT_SECURITY_ID, this.securityId);
101 m.put(EndowPropertyConstants.HOLDING_TAX_LOT_REGISTRATION_CODE, this.registrationCode);
102 m.put(EndowPropertyConstants.HOLDING_TAX_LOT_INCOME_PRINCIPAL_INDICATOR, this.incomePrincipalIndicator);
103 return m;
104 }
105
106 /**
107 * Gets the acquiredDate.
108 *
109 * @return acquiredDate
110 */
111 public Date getAcquiredDate() {
112 return acquiredDate;
113 }
114
115 /**
116 * Sets the acquiredDate.
117 *
118 * @param acquiredDate
119 */
120 public void setAcquiredDate(Date acquiredDate) {
121 this.acquiredDate = acquiredDate;
122 }
123
124 /**
125 * Gets the cost.
126 *
127 * @return cost
128 */
129 public BigDecimal getCost() {
130 return cost;
131 }
132
133 /**
134 * Sets the cost.
135 *
136 * @param cost
137 */
138 public void setCost(BigDecimal cost) {
139 this.cost = cost;
140 }
141
142 /**
143 * Gets the currentAccrual.
144 *
145 * @return currentAccrual
146 */
147 public BigDecimal getCurrentAccrual() {
148 return currentAccrual;
149 }
150
151 /**
152 * Sets the currentAccrual.
153 *
154 * @param currentAccrual
155 */
156 public void setCurrentAccrual(BigDecimal currentAccrual) {
157 this.currentAccrual = currentAccrual;
158 }
159
160 /**
161 * Gets the incomePrincipalIndicator.
162 *
163 * @return incomePrincipalIndicator
164 */
165 public String getIncomePrincipalIndicator() {
166 return incomePrincipalIndicator;
167 }
168
169 /**
170 * Sets the incomePrincipalIndicator.
171 *
172 * @param incomePrincipalIndicator
173 */
174 public void setIncomePrincipalIndicator(String incomePrincipalIndicator) {
175 this.incomePrincipalIndicator = incomePrincipalIndicator;
176 }
177
178 /**
179 * Gets the kemid.
180 *
181 * @return kemid
182 */
183 public String getKemid() {
184 return kemid;
185 }
186
187 /**
188 * Sets the kemid.
189 *
190 * @param kemid
191 */
192 public void setKemid(String kemid) {
193 this.kemid = kemid;
194 }
195
196 /**
197 * Gets the lastTransactionDate.
198 *
199 * @return lastTransactionDate
200 */
201 public Date getLastTransactionDate() {
202 return lastTransactionDate;
203 }
204
205 /**
206 * Sets the lastTransactionDate.
207 *
208 * @param lastTransactionDate
209 */
210 public void setLastTransactionDate(Date lastTransactionDate) {
211 this.lastTransactionDate = lastTransactionDate;
212 }
213
214 /**
215 * Gets the lotNumber.
216 *
217 * @return lotNumber
218 */
219 public KualiInteger getLotNumber() {
220 return lotNumber;
221 }
222
223 /**
224 * Sets the lotNumber.
225 *
226 * @param lotNumber
227 */
228 public void setLotNumber(KualiInteger lotNumber) {
229 this.lotNumber = lotNumber;
230 }
231
232 /**
233 * Gets the priorAccrual.
234 *
235 * @return priorAccrual
236 */
237 public BigDecimal getPriorAccrual() {
238 return priorAccrual;
239 }
240
241 /**
242 * Sets the priorAccrual.
243 *
244 * @param priorAccrual
245 */
246 public void setPriorAccrual(BigDecimal priorAccrual) {
247 this.priorAccrual = priorAccrual;
248 }
249
250 /**
251 * Gets the registrationCode.
252 *
253 * @return registrationCode
254 */
255 public String getRegistrationCode() {
256 return registrationCode;
257 }
258
259 /**
260 * Sets the registrationCode.
261 *
262 * @param registrationCode
263 */
264 public void setRegistrationCode(String registrationCode) {
265 this.registrationCode = registrationCode;
266 }
267
268 /**
269 * Gets the securityId.
270 *
271 * @return securityId
272 */
273 public String getSecurityId() {
274 return securityId;
275 }
276
277 /**
278 * Sets the securityId.
279 *
280 * @param securityId
281 */
282 public void setSecurityId(String securityId) {
283 this.securityId = securityId;
284 }
285
286 /**
287 * Gets the units.
288 *
289 * @return units
290 */
291 public BigDecimal getUnits() {
292 return units;
293 }
294
295 /**
296 * Sets the units.
297 *
298 * @param units
299 */
300 public void setUnits(BigDecimal units) {
301 this.units = units;
302 }
303
304 /**
305 * Gets the market value.
306 *
307 * @return the market value
308 */
309 public BigDecimal getMarketValue() {
310
311 KEMService kemService = SpringContext.getBean(KEMService.class);
312 BigDecimal marketValue = kemService.getMarketValue(this.getKemid(), this.getSecurityId(), this.getRegistrationCode(), this.getLotNumber(), this.getIncomePrincipalIndicator());
313
314 return marketValue;
315 }
316
317 /**
318 * Gets the Balance Date which is the Current System/Process date
319 *
320 * @return the Balance Date
321 */
322 public Date getBalanceDate() {
323
324 return SpringContext.getBean(KEMService.class).getCurrentDate();
325 }
326
327 /**
328 * Gets the registration.
329 *
330 * @return registration
331 */
332 public RegistrationCode getRegistration() {
333 return registration;
334 }
335
336 /**
337 * Sets the registration
338 *
339 * @param registration
340 */
341 public void setRegistration(RegistrationCode registration) {
342 this.registration = registration;
343 }
344
345 /**
346 * Gets the kemidObj.
347 *
348 * @return kemidObj
349 */
350 public KEMID getKemidObj() {
351 return kemidObj;
352 }
353
354 /**
355 * Sets the kemidObj.
356 *
357 * @param kemidObj
358 */
359 @Deprecated
360 public void setKemidObj(KEMID kemidObj) {
361 this.kemidObj = kemidObj;
362 }
363
364 /**
365 * @see java.lang.Object#hashCode()
366 */
367 @Override
368 public int hashCode() {
369 final int prime = 31;
370 int result = 1;
371 result = prime * result + ((incomePrincipalIndicator == null) ? 0 : incomePrincipalIndicator.hashCode());
372 result = prime * result + ((kemid == null) ? 0 : kemid.hashCode());
373 result = prime * result + ((lotNumber == null) ? 0 : lotNumber.hashCode());
374 result = prime * result + ((registrationCode == null) ? 0 : registrationCode.hashCode());
375 result = prime * result + ((securityId == null) ? 0 : securityId.hashCode());
376 return result;
377 }
378
379 /**
380 * @see java.lang.Object#equals(java.lang.Object)
381 */
382 @Override
383 public boolean equals(Object obj) {
384 if (this == obj)
385 return true;
386 if (obj == null)
387 return false;
388 if (getClass() != obj.getClass())
389 return false;
390 HoldingTaxLot other = (HoldingTaxLot) obj;
391 if (incomePrincipalIndicator == null) {
392 if (other.incomePrincipalIndicator != null)
393 return false;
394 }
395 else if (!incomePrincipalIndicator.equals(other.incomePrincipalIndicator))
396 return false;
397 if (kemid == null) {
398 if (other.kemid != null)
399 return false;
400 }
401 else if (!kemid.equals(other.kemid))
402 return false;
403 if (lotNumber == null) {
404 if (other.lotNumber != null)
405 return false;
406 }
407 else if (!lotNumber.equals(other.lotNumber))
408 return false;
409 if (registrationCode == null) {
410 if (other.registrationCode != null)
411 return false;
412 }
413 else if (!registrationCode.equals(other.registrationCode))
414 return false;
415 if (securityId == null) {
416 if (other.securityId != null)
417 return false;
418 }
419 else if (!securityId.equals(other.securityId))
420 return false;
421 return true;
422 }
423
424 }