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.util.LinkedHashMap; 020 021 import org.kuali.kfs.module.endow.EndowConstants; 022 import org.kuali.rice.kns.bo.TransientBusinessObjectBase; 023 024 public class GLCombinedTransactionArchive extends TransientBusinessObjectBase { 025 026 private long combinedEntryCount = 0; 027 028 private BigDecimal incomeAmount; 029 private BigDecimal principalAmount; 030 private BigDecimal holdingAmount; 031 private BigDecimal longTermAmount; 032 private BigDecimal shortTermAmount; 033 private String documentNumber; 034 private int lineNumber; 035 private String lineTypeCode; 036 private String typeCode; 037 private String subTypeCode; 038 private String kemid; 039 private String incomePrincipalIndicatorCode; 040 041 //KEMIDGeneralLinkTable... 042 private String chartCode; 043 private String accountNumber; 044 private String objectCode; 045 private String nonCashOffsetObjectCode; 046 047 public GLCombinedTransactionArchive() { 048 chartCode = null; 049 accountNumber = null; 050 objectCode = null; 051 nonCashOffsetObjectCode = null; 052 053 lineTypeCode = null; 054 subTypeCode = null; 055 typeCode = null; 056 incomePrincipalIndicatorCode = null; 057 kemid = null; 058 documentNumber = null; 059 060 this.initializeAmounts(); 061 } 062 063 /** 064 * gets documentNumber 065 * @return documentNumber 066 */ 067 public String getDocumentNumber() { 068 return documentNumber; 069 } 070 071 /** 072 * sets documentNumber attribute 073 * @param documentNumber 074 */ 075 public void setDocumentNumber(String documentNumber) { 076 this.documentNumber = documentNumber; 077 } 078 079 /** 080 * gets lineNumber 081 * @return lineNumber 082 */ 083 public int getLineNumber() { 084 return lineNumber; 085 } 086 087 /** 088 * sets lineNumber attribute 089 * @param lineNumber 090 */ 091 public void setLineNumber(int lineNumber) { 092 this.lineNumber = lineNumber; 093 } 094 095 /** 096 * gets lineTypeCode 097 * @return lineTypeCode 098 */ 099 public String getLineTypeCode() { 100 return lineTypeCode; 101 } 102 103 /** 104 * sets lineTypeCode attribute 105 * @param lineTypeCode 106 */ 107 public void setLineTypeCode(String lineTypeCode) { 108 this.lineTypeCode = lineTypeCode; 109 } 110 111 /** 112 * gets typeCode 113 * @return typeCode 114 */ 115 public String getTypeCode() { 116 return typeCode; 117 } 118 119 /** 120 * sets typeCode attribute 121 * @param typeCode 122 */ 123 public void setTypeCode(String typeCode) { 124 this.typeCode = typeCode; 125 } 126 127 /** 128 * gets subTypeCode 129 * @return subTypeCode 130 */ 131 public String getSubTypeCode() { 132 return subTypeCode; 133 } 134 135 /** 136 * sets subTypeCode attribute 137 * @param subTypeCode 138 */ 139 public void setSubTypeCode(String subTypeCode) { 140 this.subTypeCode = subTypeCode; 141 } 142 143 /** 144 * gets incomePrincipalIndicatorCode 145 * @return incomePrincipalIndicatorCode 146 */ 147 public String getIncomePrincipalIndicatorCode() { 148 return incomePrincipalIndicatorCode; 149 } 150 151 /** 152 * sets incomePrincipalIndicatorCode attribute 153 * @param incomePrincipalIndicatorCode 154 */ 155 public void setIncomePrincipalIndicatorCode(String incomePrincipalIndicatorCode) { 156 this.incomePrincipalIndicatorCode = incomePrincipalIndicatorCode; 157 } 158 159 /** 160 * gets holdingAmount 161 * @return holdingAmount 162 */ 163 public BigDecimal getHoldingAmount() { 164 return holdingAmount; 165 } 166 167 /** 168 * sets holdingAmount attribute 169 * @param holdingAmount 170 */ 171 public void setHoldingAmount(BigDecimal holdingAmount) { 172 this.holdingAmount = holdingAmount; 173 } 174 175 /** 176 * Gets the longTermAmount attribute. 177 * @return Returns the longTermAmount. 178 */ 179 public BigDecimal getLongTermAmount() { 180 return longTermAmount; 181 } 182 183 /** 184 * Sets the longTermAmount attribute value. 185 * @param longTermAmount The longTermAmount to set. 186 */ 187 public void setLongTermAmount(BigDecimal longTermAmount) { 188 this.longTermAmount = longTermAmount; 189 } 190 191 /** 192 * Gets the shortTermAmount attribute. 193 * @return Returns the shortTermAmount. 194 */ 195 public BigDecimal getShortTermAmount() { 196 return shortTermAmount; 197 } 198 199 /** 200 * Sets the shortTermAmount attribute value. 201 * @param shortTermAmount The shortTermGainLoss to set. 202 */ 203 public void setShortTermAmount(BigDecimal shortTermAmount) { 204 this.shortTermAmount = shortTermAmount; 205 } 206 207 /** 208 * gets chartCode 209 * @return chartCode 210 */ 211 public String getChartCode() { 212 return chartCode; 213 } 214 215 /** 216 * sets chartCode attribute 217 * @param chartCode 218 */ 219 public void setChartCode(String chartCode) { 220 this.chartCode = chartCode; 221 } 222 223 /** 224 * gets accountNumber 225 * @return accountNumber 226 */ 227 public String getAccountNumber() { 228 return accountNumber; 229 } 230 231 /** 232 * sets documentNumber attribute 233 * @param documentNumber 234 */ 235 public void setAccountNumber(String accountNumber) { 236 this.accountNumber = accountNumber; 237 } 238 239 /** 240 * gets objectCode 241 * @return objectCode 242 */ 243 public String getObjectCode() { 244 return objectCode; 245 } 246 247 /** 248 * sets objectCode attribute 249 * @param objectCode 250 */ 251 public void setObjectCode(String objectCode) { 252 this.objectCode = objectCode; 253 } 254 255 /** 256 * gets kemid attribute 257 * @return kemid; 258 */ 259 public String getKemid() { 260 return kemid; 261 } 262 263 /** 264 * set kemid attribute 265 * @param kemid 266 */ 267 public void setKemid(String kemid) { 268 this.kemid = kemid; 269 } 270 271 /** 272 * method to initialize the amount fields... 273 */ 274 public void initializeAmounts() { 275 combinedEntryCount = 0; 276 277 incomeAmount = BigDecimal.ZERO; 278 principalAmount = BigDecimal.ZERO; 279 holdingAmount = BigDecimal.ZERO; 280 longTermAmount = BigDecimal.ZERO; 281 shortTermAmount = BigDecimal.ZERO; 282 } 283 284 /** 285 * gets attribute combinedEntryCount 286 * @return combinedEntryCount 287 */ 288 public long getCombinedEntryCount() { 289 return combinedEntryCount; 290 } 291 292 /** 293 * sets attribute combinedEntryCount 294 */ 295 public void setCombinedEntryCount(long combinedEntryCount) { 296 this.combinedEntryCount = combinedEntryCount; 297 } 298 299 /** 300 * gets attribute incomeAmount 301 * @return incomeAmount 302 */ 303 public BigDecimal getIncomeAmount() { 304 return incomeAmount; 305 } 306 307 /** 308 * sets attribute incomeAmount 309 */ 310 public void setIncomeAmount(BigDecimal incomeAmount) { 311 this.incomeAmount = incomeAmount; 312 } 313 314 /** 315 * gets attribute principalAmount 316 * @return principalAmount 317 */ 318 public BigDecimal getPrincipalAmount() { 319 return principalAmount; 320 } 321 322 /** 323 * sets attribute principalAmount 324 */ 325 public void setPrincipalAmount(BigDecimal principalAmount) { 326 this.principalAmount = principalAmount; 327 } 328 329 /** 330 * method to increment combinedEntryCount 331 */ 332 public void incrementCombinedEntryCount() { 333 this.combinedEntryCount++; 334 } 335 336 /** 337 * method to copy values from archive transaction to properties in the transient 338 * business object so they can be copied to the combined transaction archive line later 339 * The amounts from single transaction archive are added to the property variables and 340 * will be copied to the combined archive record. 341 * 342 * @param kemArchiveTransaction 343 * @param cashType 344 */ 345 public void copyKemArchiveTransactionValues(GlInterfaceBatchProcessKemLine kemArchiveTransaction, boolean cashType) { 346 347 lineNumber = kemArchiveTransaction.getLineNumber(); 348 lineTypeCode = kemArchiveTransaction.getLineTypeCode(); 349 subTypeCode = kemArchiveTransaction.getSubTypeCode(); 350 typeCode = kemArchiveTransaction.getTypeCode(); 351 incomePrincipalIndicatorCode = kemArchiveTransaction.getIncomePrincipalIndicatorCode(); 352 kemid = kemArchiveTransaction.getKemid(); 353 documentNumber = kemArchiveTransaction.getDocumentNumber(); 354 nonCashOffsetObjectCode = kemArchiveTransaction.getNonCashOffsetObjectCode(); 355 356 if (cashType) { 357 incomeAmount = incomeAmount.add(kemArchiveTransaction.getTransactionArchiveIncomeAmount()); 358 principalAmount = principalAmount.add(kemArchiveTransaction.getTransactionArchivePrincipalAmount()); 359 if (EndowConstants.DocumentTypeNames.ENDOWMENT_ASSET_DECREASE.equalsIgnoreCase(kemArchiveTransaction.getTypeCode())) { 360 holdingAmount = holdingAmount.add(kemArchiveTransaction.getHoldingCost()); 361 shortTermAmount = shortTermAmount.add(kemArchiveTransaction.getShortTermGainLoss()); 362 longTermAmount = longTermAmount.add(kemArchiveTransaction.getLongTermGainLoss()); 363 } 364 } 365 else { 366 holdingAmount = holdingAmount.add(kemArchiveTransaction.getHoldingCost()); 367 shortTermAmount = shortTermAmount.add(kemArchiveTransaction.getShortTermGainLoss()); 368 longTermAmount = longTermAmount.add(kemArchiveTransaction.getLongTermGainLoss()); 369 } 370 } 371 372 /** 373 * method to copy values from transaction archive into chart, account number, and object code 374 * @param kemArchiveTransaction 375 */ 376 public void copyChartAndAccountNumberAndObjectCodeValues(GlInterfaceBatchProcessKemLine kemArchiveTransaction) { 377 this.setChartCode(kemArchiveTransaction.getChartCode()); 378 this.setAccountNumber(kemArchiveTransaction.getAccountNumber()); 379 this.setObjectCode(kemArchiveTransaction.getObjectCode()); 380 } 381 382 /** 383 * method to copy the values stored in the bo to the combined transaction archive record 384 * @param cashType 385 */ 386 public GlInterfaceBatchProcessKemLine copyValuesToCombinedTransactionArchive(boolean cashType) { 387 GlInterfaceBatchProcessKemLine glKemLine = new GlInterfaceBatchProcessKemLine(); 388 389 if (combinedEntryCount > 1) { 390 glKemLine.setDocumentNumber("Summary"); 391 glKemLine.setKemid("Summary"); 392 } 393 else { 394 glKemLine.setDocumentNumber(documentNumber); 395 glKemLine.setKemid(kemid); 396 } 397 glKemLine.setLineNumber(lineNumber); 398 glKemLine.setLineTypeCode(lineTypeCode); 399 glKemLine.setSubTypeCode(subTypeCode); 400 glKemLine.setTypeCode(typeCode); 401 glKemLine.setIncomePrincipalIndicatorCode(incomePrincipalIndicatorCode); 402 glKemLine.setObjectCode(objectCode); 403 glKemLine.setNonCashOffsetObjectCode(nonCashOffsetObjectCode); 404 405 //get transaction amount.... 406 if (cashType) { 407 glKemLine.setTransactionArchiveIncomeAmount(incomeAmount); 408 glKemLine.setTransactionArchivePrincipalAmount(principalAmount); 409 glKemLine.setHoldingCost(BigDecimal.ZERO); 410 glKemLine.setLongTermGainLoss(BigDecimal.ZERO); 411 glKemLine.setShortTermGainLoss(BigDecimal.ZERO); 412 if (glKemLine.getTypeCode().equalsIgnoreCase(EndowConstants.DocumentTypeNames.ENDOWMENT_ASSET_DECREASE)) { 413 glKemLine.setHoldingCost(holdingAmount); 414 glKemLine.setShortTermGainLoss(shortTermAmount); 415 glKemLine.setLongTermGainLoss(longTermAmount); 416 } 417 } 418 else { 419 glKemLine.setTransactionArchiveIncomeAmount(BigDecimal.ZERO); 420 glKemLine.setTransactionArchivePrincipalAmount(BigDecimal.ZERO); 421 glKemLine.setHoldingCost(holdingAmount); 422 glKemLine.setShortTermGainLoss(shortTermAmount); 423 glKemLine.setLongTermGainLoss(longTermAmount); 424 } 425 426 glKemLine.setChartCode(chartCode); 427 glKemLine.setAccountNumber(accountNumber); 428 429 return glKemLine; 430 } 431 432 /** 433 * gets attribute nonCashOffsetObjectCode 434 * @return nonCashOffsetObjectCode 435 */ 436 public String getNonCashOffsetObjectCode() { 437 return nonCashOffsetObjectCode; 438 } 439 440 /** 441 * sets attribute nonCashOffsetObjectCode 442 */ 443 public void setNonCashOffsetObjectCode(String nonCashOffsetObjectCode) { 444 this.nonCashOffsetObjectCode = nonCashOffsetObjectCode; 445 } 446 447 /** 448 * A map of the "keys" of this transient business object 449 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper() 450 */ 451 @Override 452 protected LinkedHashMap toStringMapper() { 453 LinkedHashMap pks = new LinkedHashMap<String, Object>(); 454 455 pks.put("documentNumber", this.getDocumentNumber()); 456 pks.put("lineNumber", this.getLineNumber()); 457 pks.put("lineTypeCode", this.getLineTypeCode()); 458 pks.put("typeCode", this.getTypeCode()); 459 pks.put("kemid", this.getKemid()); 460 pks.put("subTypeCode", this.getSubTypeCode()); 461 pks.put("incomePrincipalIndicatorCode", this.getIncomePrincipalIndicatorCode()); 462 pks.put("holdingAmount", this.getHoldingAmount()); 463 pks.put(longTermAmount, this.getLongTermAmount()); 464 pks.put("shortTermAmount", this.getShortTermAmount()); 465 pks.put("chartCode", this.getChartCode()); 466 pks.put("objectCode", this.getObjectCode()); 467 pks.put("accountNumber", this.getAccountNumber()); 468 pks.put("nonCashOffsetObjectCode", this.getNonCashOffsetObjectCode()); 469 470 return pks; 471 } 472 }