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.math.BigInteger; 020 import java.sql.Date; 021 import java.util.LinkedHashMap; 022 import java.util.List; 023 024 import org.apache.commons.lang.StringUtils; 025 import org.kuali.kfs.module.endow.EndowPropertyConstants; 026 import org.kuali.kfs.sys.KFSConstants; 027 import org.kuali.kfs.sys.context.SpringContext; 028 import org.kuali.rice.kew.doctype.bo.DocumentType; 029 import org.kuali.rice.kew.doctype.service.DocumentTypeService; 030 import org.kuali.rice.kns.bo.DocumentHeader; 031 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; 032 import org.kuali.rice.kns.util.ObjectUtils; 033 import org.kuali.rice.kns.util.TypedArrayList; 034 035 /** 036 * Business Object for Holding Tax Lot table 037 */ 038 public class TransactionArchive extends PersistableBusinessObjectBase { 039 040 // Composite keys: 041 private String documentNumber; 042 private Integer lineNumber; 043 private String lineTypeCode; 044 045 // Other fields: 046 private String description; 047 private String typeCode; 048 private String subTypeCode; 049 private String srcTypeCode; 050 private String kemid; 051 private String etranCode; 052 private String lineDescription; 053 private String incomePrincipalIndicatorCode; 054 private BigDecimal principalCashAmount; 055 private BigDecimal incomeCashAmount; 056 private boolean corpusIndicator; 057 private BigDecimal corpusAmount; 058 private Date postedDate; 059 060 // Reference objects: 061 protected List<TransactionArchiveSecurity> archiveSecurities; 062 protected EndowmentTransactionCode etranObj; 063 protected DocumentHeader documentHeader; 064 protected KEMID kemidObj; 065 066 // Transient members: 067 private transient BigDecimal greaterAmount; 068 private transient BigDecimal lessAmount; 069 070 public TransactionArchive() 071 { 072 archiveSecurities = new TypedArrayList(TransactionArchiveSecurity.class); 073 principalCashAmount = new BigDecimal(BigInteger.ZERO, 2); 074 incomeCashAmount = new BigDecimal(BigInteger.ZERO, 2); 075 corpusAmount = new BigDecimal(BigInteger.ZERO, 2); 076 } 077 078 /** 079 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper() 080 */ 081 @Override 082 protected LinkedHashMap<String, Object> toStringMapper() { 083 LinkedHashMap<String, Object> m = new LinkedHashMap<String, Object>(); 084 m.put(EndowPropertyConstants.TRANSACTION_ARCHIVE_DOCUMENT_NUMBER, this.documentNumber); 085 m.put(EndowPropertyConstants.TRANSACTION_ARCHIVE_LINE_NUMBER, this.lineNumber); 086 m.put(EndowPropertyConstants.TRANSACTION_ARCHIVE_LINE_TYPE_CODE, this.lineTypeCode); 087 088 return m; 089 } 090 091 /** 092 * 093 * This method returns a multi-line field. 094 * @return 095 */ 096 public String getKemidResults() { 097 StringBuilder result = new StringBuilder(); 098 if (ObjectUtils.isNotNull(kemidObj)) { 099 result.append("[" + kemid + "," + " ,"); 100 result.append(kemidObj.getShortTitle() + "]"); 101 } 102 103 return result.toString(); 104 } 105 106 /** 107 * 108 * This method returns a multi-line field. 109 * @return 110 */ 111 public String getEtranCodeResults() { 112 StringBuilder result = new StringBuilder(); 113 if (ObjectUtils.isNotNull(etranObj)) { 114 result.append("[" + etranCode + "," + " ,"); 115 result.append(etranObj.getName() + "]"); 116 } 117 118 return result.toString(); 119 } 120 121 /** 122 * 123 * This method returns a multi-line field. 124 * @return 125 */ 126 public String getSecurityResults() { 127 StringBuilder result = new StringBuilder(); 128 TransactionArchiveSecurity archiveSecurity = getArchiveSecurity(); 129 if (ObjectUtils.isNotNull(archiveSecurity)) { 130 result.append("[" + archiveSecurity.getSecurityId() + "," + " ,"); 131 result.append(archiveSecurity.getSecurity().getDescription() + "]"); 132 } 133 134 return result.toString(); 135 } 136 137 /** 138 * 139 * Data for the transaction document type results column. 140 * 141 * @return 142 */ 143 public String getDocumentTypeResults() { 144 145 DocumentTypeService documentTypeService = SpringContext.getBean(DocumentTypeService.class); 146 DocumentType documentType = documentTypeService.findByName(typeCode); 147 148 StringBuilder result = new StringBuilder(); 149 result.append("[" + typeCode + "," + " ,"); 150 151 if (documentType != null) { 152 result.append(documentType.getLabel()); 153 } 154 result.append("]"); 155 156 return result.toString(); 157 } 158 159 /** 160 * Gets the documentHeader attribute. 161 * @return Returns the documentHeader. 162 */ 163 public DocumentHeader getDocumentHeader() { 164 return documentHeader; 165 } 166 167 /** 168 * Sets the documentHeader attribute value. 169 * @param documentHeader The documentHeader to set. 170 */ 171 public void setDocumentHeader(DocumentHeader documentHeader) { 172 this.documentHeader = documentHeader; 173 } 174 175 /** 176 * 177 * This method... 178 * @return 179 */ 180 public String getTransactionArchiveViewer() { 181 return "View Detail"; 182 } 183 184 /** 185 * Gets the etranObj attribute. 186 * @return Returns the etranObj. 187 */ 188 public EndowmentTransactionCode getEtranObj() { 189 return etranObj; 190 } 191 192 /** 193 * Sets the etranObj attribute value. 194 * @param etranObj The etranObj to set. 195 */ 196 public void setEtranObj(EndowmentTransactionCode etranObj) { 197 this.etranObj = etranObj; 198 } 199 200 /** 201 * Gets the kemidObj attribute. 202 * @return Returns the kemidObj. 203 */ 204 public KEMID getKemidObj() { 205 return kemidObj; 206 } 207 208 /** 209 * Sets the kemidObj attribute value. 210 * @param kemidObj The kemidObj to set. 211 */ 212 public void setKemidObj(KEMID kemidObj) { 213 this.kemidObj = kemidObj; 214 } 215 216 /** 217 * Gets the greaterAmount attribute. 218 * @return Returns the greaterAmount. 219 */ 220 public BigDecimal getGreaterAmount() { 221 return greaterAmount; 222 } 223 224 /** 225 * Sets the greaterAmount attribute value. 226 * @param greaterAmount The greaterAmount to set. 227 */ 228 public void setGreaterAmount(BigDecimal greaterAmount) { 229 this.greaterAmount = greaterAmount; 230 } 231 232 /** 233 * Gets the lessAmount attribute. 234 * @return Returns the lessAmount. 235 */ 236 public BigDecimal getLessAmount() { 237 return lessAmount; 238 } 239 240 /** 241 * Sets the lessAmount attribute value. 242 * @param lessAmount The lessAmount to set. 243 */ 244 public void setLessAmount(BigDecimal lessAmount) { 245 this.lessAmount = lessAmount; 246 } 247 248 /** 249 * Gets the archiveSecurity attribute. 250 * @return Returns the archiveSecurity. 251 */ 252 public TransactionArchiveSecurity getArchiveSecurity() { 253 return !archiveSecurities.isEmpty() ? archiveSecurities.get(0) 254 : new TransactionArchiveSecurity(); 255 } 256 257 /** 258 * Gets the documentNumber attribute. 259 * @return Returns the documentNumber. 260 */ 261 public String getDocumentNumber() { 262 return documentNumber; 263 } 264 265 /** 266 * Sets the documentNumber attribute value. 267 * @param documentNumber The documentNumber to set. 268 */ 269 public void setDocumentNumber(String documentNumber) { 270 this.documentNumber = documentNumber; 271 } 272 273 /** 274 * Gets the lineNumber attribute. 275 * @return Returns the lineNumber. 276 */ 277 public Integer getLineNumber() { 278 return lineNumber; 279 } 280 281 /** 282 * Sets the lineNumber attribute value. 283 * @param lineNumber The lineNumber to set. 284 */ 285 public void setLineNumber(Integer lineNumber) { 286 this.lineNumber = lineNumber; 287 } 288 289 /** 290 * Gets the lineTypeCode attribute. 291 * @return Returns the lineTypeCode. 292 */ 293 public String getLineTypeCode() { 294 return lineTypeCode; 295 } 296 297 /** 298 * Sets the lineTypeCode attribute value. 299 * @param lineTypeCode The lineTypeCode to set. 300 */ 301 public void setLineTypeCode(String lineTypeCode) { 302 this.lineTypeCode = lineTypeCode; 303 } 304 305 /** 306 * Gets the description attribute. 307 * @return Returns the description. 308 */ 309 public String getDescription() { 310 return description; 311 } 312 313 /** 314 * Sets the description attribute value. 315 * @param description The description to set. 316 */ 317 public void setDescription(String description) { 318 this.description = description; 319 } 320 321 /** 322 * Gets the typeCode attribute. 323 * @return Returns the typeCode. 324 */ 325 public String getTypeCode() { 326 return typeCode; 327 } 328 329 /** 330 * Sets the typeCode attribute value. 331 * @param typeCode The typeCode to set. 332 */ 333 public void setTypeCode(String typeCode) { 334 this.typeCode = typeCode; 335 } 336 337 /** 338 * Gets the subTypeCode attribute. 339 * @return Returns the subTypeCode. 340 */ 341 public String getSubTypeCode() { 342 return subTypeCode; 343 } 344 345 /** 346 * Sets the subTypeCode attribute value. 347 * @param subTypeCode The subTypeCode to set. 348 */ 349 public void setSubTypeCode(String subTypeCode) { 350 this.subTypeCode = subTypeCode; 351 } 352 353 /** 354 * Gets the srcTypeCode attribute. 355 * @return Returns the srcTypeCode. 356 */ 357 public String getSrcTypeCode() { 358 return srcTypeCode; 359 } 360 361 /** 362 * Sets the srcTypeCode attribute value. 363 * @param srcTypeCode The srcTypeCode to set. 364 */ 365 public void setSrcTypeCode(String srcTypeCode) { 366 this.srcTypeCode = srcTypeCode; 367 } 368 369 /** 370 * Gets the kemid attribute. 371 * @return Returns the kemid. 372 */ 373 public String getKemid() { 374 return kemid; 375 } 376 377 /** 378 * Sets the kemid attribute value. 379 * @param kemid The kemid to set. 380 */ 381 public void setKemid(String kemid) { 382 this.kemid = kemid; 383 } 384 385 /** 386 * Gets the etranCode attribute. 387 * @return Returns the etranCode. 388 */ 389 public String getEtranCode() { 390 return etranCode; 391 } 392 393 /** 394 * Sets the etranCode attribute value. 395 * @param etranCode The etranCode to set. 396 */ 397 public void setEtranCode(String etranCode) { 398 this.etranCode = etranCode; 399 } 400 401 /** 402 * Gets the lineDescription attribute. 403 * @return Returns the lineDescription. 404 */ 405 public String getLineDescription() { 406 return lineDescription; 407 } 408 409 /** 410 * Sets the lineDescription attribute value. 411 * @param lineDescription The lineDescription to set. 412 */ 413 public void setLineDescription(String lineDescription) { 414 this.lineDescription = lineDescription; 415 } 416 417 /** 418 * Gets the incomePrincipalIndicatorCode attribute. 419 * @return Returns the incomePrincipalIndicatorCode. 420 */ 421 public String getIncomePrincipalIndicatorCode() { 422 return incomePrincipalIndicatorCode; 423 } 424 425 /** 426 * Sets the incomePrincipalIndicatorCode attribute value. 427 * @param incomePrincipalIndicatorCode The incomePrincipalIndicatorCode to set. 428 */ 429 public void setIncomePrincipalIndicatorCode(String incomePrincipalIndicatorCode) { 430 this.incomePrincipalIndicatorCode = incomePrincipalIndicatorCode; 431 } 432 433 /** 434 * Gets the principalCashAmount attribute. 435 * @return Returns the principalCashAmount. 436 */ 437 public BigDecimal getPrincipalCashAmount() { 438 return principalCashAmount; 439 } 440 441 /** 442 * Sets the principalCashAmount attribute value. 443 * @param principalCashAmount The principalCashAmount to set. 444 */ 445 public void setPrincipalCashAmount(BigDecimal principalCashAmount) { 446 this.principalCashAmount = principalCashAmount; 447 } 448 449 /** 450 * Gets the incomeCashAmount attribute. 451 * @return Returns the incomeCashAmount. 452 */ 453 public BigDecimal getIncomeCashAmount() { 454 return incomeCashAmount; 455 } 456 457 /** 458 * Sets the incomeCashAmount attribute value. 459 * @param incomeCashAmount The incomeCashAmount to set. 460 */ 461 public void setIncomeCashAmount(BigDecimal incomeCashAmount) { 462 this.incomeCashAmount = incomeCashAmount; 463 } 464 465 /** 466 * Gets the corpusIndicator attribute. 467 * @return Returns the corpusIndicator. 468 */ 469 public boolean getCorpusIndicator() { 470 return corpusIndicator; 471 } 472 473 /** 474 * Sets the corpusIndicator attribute value. 475 * @param corpusIndicator The corpusIndicator to set. 476 */ 477 public void setCorpusIndicator(boolean corpusIndicator) { 478 this.corpusIndicator = corpusIndicator; 479 } 480 481 /** 482 * Gets the corpusAmount attribute. 483 * @return Returns the corpusAmount. 484 */ 485 public BigDecimal getCorpusAmount() { 486 return corpusAmount; 487 } 488 489 /** 490 * Sets the corpusAmount attribute value. 491 * @param corpusAmount The corpusAmount to set. 492 */ 493 public void setCorpusAmount(BigDecimal corpusAmount) { 494 this.corpusAmount = corpusAmount; 495 } 496 497 /** 498 * Gets the postedDate attribute. 499 * @return Returns the postedDate. 500 */ 501 public Date getPostedDate() { 502 return postedDate; 503 } 504 505 /** 506 * Sets the postedDate attribute value. 507 * @param postedDate The postedDate to set. 508 */ 509 public void setPostedDate(Date postedDate) { 510 this.postedDate = postedDate; 511 } 512 513 /** 514 * Gets the archiveSecurities attribute. 515 * @return Returns the archiveSecurities. 516 */ 517 public List<TransactionArchiveSecurity> getArchiveSecurities() { 518 return archiveSecurities; 519 } 520 521 /** 522 * Sets the archiveSecurities attribute value. 523 * @param archiveSecurities The archiveSecurities to set. 524 */ 525 public void setArchiveSecurities(List<TransactionArchiveSecurity> archiveSecurities) { 526 this.archiveSecurities = archiveSecurities; 527 } 528 /** 529 * Gets the code and description 530 * @return Returns code + " - " + description 531 */ 532 public String getCodeAndDescription() { 533 if (StringUtils.isEmpty(typeCode)) { 534 return KFSConstants.EMPTY_STRING; 535 } 536 return typeCode + " - " + description; 537 } 538 539 /** 540 * Sets the codeAndDescription attribute value. 541 * @param set codeAndDescription 542 */ 543 public void setCodeAndDescription(String codeAndDescription) {} 544 545 }