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.coa.businessobject; 017 018 import java.util.LinkedHashMap; 019 020 import org.apache.commons.lang.StringUtils; 021 import org.kuali.kfs.coa.service.ChartService; 022 import org.kuali.kfs.sys.context.SpringContext; 023 import org.kuali.rice.kim.bo.Person; 024 import org.kuali.rice.kim.service.PersonService; 025 import org.kuali.rice.kns.bo.Inactivateable; 026 import org.kuali.rice.kns.bo.KualiCode; 027 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; 028 029 /** 030 * 031 */ 032 public class Chart extends PersistableBusinessObjectBase implements KualiCode { 033 034 private static final long serialVersionUID = 4129020803214027609L; 035 036 private String finChartOfAccountDescription; 037 private boolean active; 038 private String finCoaManagerPrincipalId; 039 private String reportsToChartOfAccountsCode; 040 private String chartOfAccountsCode; 041 private String finAccountsPayableObjectCode; 042 private String finExternalEncumbranceObjCd; 043 private String finPreEncumbranceObjectCode; 044 private String financialCashObjectCode; 045 private String icrIncomeFinancialObjectCode; 046 private String finAccountsReceivableObjCode; 047 private String finInternalEncumbranceObjCd; 048 private String icrExpenseFinancialObjectCd; 049 private String incBdgtEliminationsFinObjCd; 050 private String expBdgtEliminationsFinObjCd; 051 private String fundBalanceObjectCode; 052 053 private ObjectCode incBdgtEliminationsFinObj; 054 private ObjectCode expBdgtEliminationsFinObj; 055 private ObjectCode finAccountsPayableObject; 056 private ObjectCode finExternalEncumbranceObj; 057 private ObjectCode finPreEncumbranceObject; 058 private ObjectCode financialCashObject; 059 private ObjectCode icrIncomeFinancialObject; 060 private ObjectCode finAccountsReceivableObj; 061 private ObjectCode finInternalEncumbranceObj; 062 private ObjectCode icrExpenseFinancialObject; 063 private ObjectCode fundBalanceObject; 064 private Person finCoaManager; 065 private Chart reportsToChartOfAccounts; 066 067 068 /** 069 * Default no-arg constructor. 070 */ 071 public Chart() { 072 } 073 074 /** 075 * Gets the finChartOfAccountDescription attribute. 076 * 077 * @return Returns the finChartOfAccountDescription 078 */ 079 public String getFinChartOfAccountDescription() { 080 return finChartOfAccountDescription; 081 } 082 083 /** 084 * Sets the finChartOfAccountDescription attribute. 085 * 086 * @param finChartOfAccountDescription The finChartOfAccountDescription to set. 087 */ 088 public void setFinChartOfAccountDescription(String finChartOfAccountDescription) { 089 this.finChartOfAccountDescription = finChartOfAccountDescription; 090 } 091 092 /** 093 * Gets the active attribute. 094 * 095 * @return Returns the active 096 */ 097 public boolean isActive() { 098 return active; 099 } 100 101 /** 102 * Sets the active attribute. 103 * 104 * @param active The active to set. 105 */ 106 public void setActive(boolean active) { 107 this.active = active; 108 } 109 110 111 /** 112 * Gets the finAccountsPayableObject attribute. 113 * 114 * @return Returns the finAccountsPayableObject 115 */ 116 public ObjectCode getFinAccountsPayableObject() { 117 return finAccountsPayableObject; 118 } 119 120 /** 121 * Sets the finAccountsPayableObject attribute. 122 * 123 * @param finAccountsPayableObject The finAccountsPayableObject to set. 124 * @deprecated 125 */ 126 public void setFinAccountsPayableObject(ObjectCode finAccountsPayableObject) { 127 this.finAccountsPayableObject = finAccountsPayableObject; 128 } 129 130 131 /** 132 * Gets the finExternalEncumbranceObj attribute. 133 * 134 * @return Returns the finExternalEncumbranceObj. 135 */ 136 public ObjectCode getFinExternalEncumbranceObj() { 137 return finExternalEncumbranceObj; 138 } 139 140 /** 141 * Sets the finExternalEncumbranceObj attribute value. 142 * 143 * @param finExternalEncumbranceObj The finExternalEncumbranceObj to set. 144 * @deprecated 145 */ 146 public void setFinExternalEncumbranceObj(ObjectCode finExternalEncumbranceObj) { 147 this.finExternalEncumbranceObj = finExternalEncumbranceObj; 148 } 149 150 /** 151 * Gets the finPreEncumbranceObject attribute. 152 * 153 * @return Returns the finPreEncumbranceObject 154 */ 155 public ObjectCode getFinPreEncumbranceObject() { 156 return finPreEncumbranceObject; 157 } 158 159 /** 160 * Sets the finPreEncumbranceObject attribute. 161 * 162 * @param finPreEncumbranceObject The finPreEncumbranceObject to set. 163 * @deprecated 164 */ 165 public void setFinPreEncumbranceObject(ObjectCode finPreEncumbranceObject) { 166 this.finPreEncumbranceObject = finPreEncumbranceObject; 167 } 168 169 /** 170 * Gets the financialCashObject attribute. 171 * 172 * @return Returns the financialCashObject 173 */ 174 public ObjectCode getFinancialCashObject() { 175 return financialCashObject; 176 } 177 178 /** 179 * Sets the financialCashObject attribute. 180 * 181 * @param financialCashObject The financialCashObject to set. 182 * @deprecated 183 */ 184 public void setFinancialCashObject(ObjectCode financialCashObject) { 185 this.financialCashObject = financialCashObject; 186 } 187 188 /** 189 * Gets the icrIncomeFinancialObject attribute. 190 * 191 * @return Returns the icrIncomeFinancialObject 192 */ 193 public ObjectCode getIcrIncomeFinancialObject() { 194 return icrIncomeFinancialObject; 195 } 196 197 /** 198 * Sets the icrIncomeFinancialObject attribute. 199 * 200 * @param icrIncomeFinancialObject The icrIncomeFinancialObject to set. 201 * @deprecated 202 */ 203 public void setIcrIncomeFinancialObject(ObjectCode icrIncomeFinancialObject) { 204 this.icrIncomeFinancialObject = icrIncomeFinancialObject; 205 } 206 207 /** 208 * Gets the finAccountsReceivableObj attribute. 209 * 210 * @return Returns the finAccountsReceivableObj 211 */ 212 public ObjectCode getFinAccountsReceivableObj() { 213 return finAccountsReceivableObj; 214 } 215 216 /** 217 * Sets the finAccountsReceivableObj attribute. 218 * 219 * @param finAccountsReceivableObj The finAccountsReceivableObj to set. 220 * @deprecated 221 */ 222 public void setFinAccountsReceivableObj(ObjectCode finAccountsReceivableObj) { 223 this.finAccountsReceivableObj = finAccountsReceivableObj; 224 } 225 226 public Person getFinCoaManager() { 227 finCoaManager = SpringContext.getBean(PersonService.class).updatePersonIfNecessary(getFinCoaManagerPrincipalId(), finCoaManager); 228 return finCoaManager; 229 } 230 231 /** 232 * Sets the finCoaManagerUniversal attribute. 233 * 234 * @param finCoaManagerUniversal The finCoaManagerUniversal to set. 235 * @deprecated 236 */ 237 public void setFinCoaManager(Person finCoaManagerUniversal) { 238 this.finCoaManager = finCoaManagerUniversal; 239 } 240 241 /** 242 * Gets the reportsToChartOfAccounts attribute. 243 * 244 * @return Returns the reportsToChartOfAccounts 245 */ 246 public Chart getReportsToChartOfAccounts() { 247 return reportsToChartOfAccounts; 248 } 249 250 /** 251 * Sets the reportsToChartOfAccounts attribute. 252 * 253 * @param reportsToChartOfAccounts The reportsToChartOfAccounts to set. 254 * @deprecated 255 */ 256 public void setReportsToChartOfAccounts(Chart reportsToChartOfAccounts) { 257 this.reportsToChartOfAccounts = reportsToChartOfAccounts; 258 } 259 260 /** 261 * Gets the finInternalEncumbranceObj attribute. 262 * 263 * @return Returns the finInternalEncumbranceObj. 264 */ 265 public ObjectCode getFinInternalEncumbranceObj() { 266 return finInternalEncumbranceObj; 267 } 268 269 /** 270 * Sets the finInternalEncumbranceObj attribute value. 271 * 272 * @param finInternalEncumbranceObj The finInternalEncumbranceObj to set. 273 * @deprecated 274 */ 275 public void setFinInternalEncumbranceObj(ObjectCode finInternalEncumbranceObj) { 276 this.finInternalEncumbranceObj = finInternalEncumbranceObj; 277 } 278 279 /** 280 * Gets the icrExpenseFinancialObject attribute. 281 * 282 * @return Returns the icrExpenseFinancialObject. 283 */ 284 public ObjectCode getIcrExpenseFinancialObject() { 285 return icrExpenseFinancialObject; 286 } 287 288 /** 289 * Sets the icrExpenseFinancialObject attribute value. 290 * 291 * @param icrExpenseFinancialObject The icrExpenseFinancialObject to set. 292 * @deprecated 293 */ 294 public void setIcrExpenseFinancialObject(ObjectCode icrExpenseFinancialObject) { 295 this.icrExpenseFinancialObject = icrExpenseFinancialObject; 296 } 297 298 /** 299 * Gets the chartOfAccountsCode attribute. 300 * 301 * @return Returns the chartOfAccountsCode. 302 */ 303 public String getChartOfAccountsCode() { 304 return chartOfAccountsCode; 305 } 306 307 /** 308 * Sets the chartOfAccountsCode attribute value. 309 * 310 * @param chartOfAccountsCode The chartOfAccountsCode to set. 311 */ 312 public void setChartOfAccountsCode(String chartOfAccountsCode) { 313 this.chartOfAccountsCode = chartOfAccountsCode; 314 } 315 316 /** 317 * Gets the expBdgtEliminationsFinObj attribute. 318 * 319 * @return Returns the expBdgtEliminationsFinObj. 320 */ 321 public ObjectCode getExpBdgtEliminationsFinObj() { 322 return expBdgtEliminationsFinObj; 323 } 324 325 /** 326 * Sets the expBdgtEliminationsFinObj attribute value. 327 * 328 * @param expBdgtEliminationsFinObj The expBdgtEliminationsFinObj to set. 329 * @deprecated 330 */ 331 public void setExpBdgtEliminationsFinObj(ObjectCode expBdgtEliminationsFinObj) { 332 this.expBdgtEliminationsFinObj = expBdgtEliminationsFinObj; 333 } 334 335 /** 336 * Gets the incBdgtEliminationsFinObj attribute. 337 * 338 * @return Returns the incBdgtEliminationsFinObj. 339 */ 340 public ObjectCode getIncBdgtEliminationsFinObj() { 341 return incBdgtEliminationsFinObj; 342 } 343 344 /** 345 * Sets the incBdgtEliminationsFinObj attribute value. 346 * 347 * @param incBdgtEliminationsFinObj The incBdgtEliminationsFinObj to set. 348 * @deprecated 349 */ 350 public void setIncBdgtEliminationsFinObj(ObjectCode incBdgtEliminationsFinObj) { 351 this.incBdgtEliminationsFinObj = incBdgtEliminationsFinObj; 352 } 353 354 /** 355 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper() 356 */ 357 @SuppressWarnings("unchecked") 358 protected LinkedHashMap toStringMapper() { 359 LinkedHashMap m = new LinkedHashMap(); 360 361 m.put("chartOfAccountsCode", this.chartOfAccountsCode); 362 363 return m; 364 } 365 366 /** 367 * Gets the finAccountsPayableObjectCode attribute. 368 * 369 * @return Returns the finAccountsPayableObjectCode. 370 */ 371 public String getFinAccountsPayableObjectCode() { 372 return finAccountsPayableObjectCode; 373 } 374 375 /** 376 * Sets the finAccountsPayableObjectCode attribute value. 377 * 378 * @param finAccountsPayableObjectCode The finAccountsPayableObjectCode to set. 379 */ 380 public void setFinAccountsPayableObjectCode(String finAccountsPayableObjectCode) { 381 this.finAccountsPayableObjectCode = finAccountsPayableObjectCode; 382 } 383 384 /** 385 * Gets the finAccountsReceivableObjCode attribute. 386 * 387 * @return Returns the finAccountsReceivableObjCode. 388 */ 389 public String getFinAccountsReceivableObjCode() { 390 return finAccountsReceivableObjCode; 391 } 392 393 /** 394 * Sets the finAccountsReceivableObjCode attribute value. 395 * 396 * @param finAccountsReceivableObjCode The finAccountsReceivableObjCode to set. 397 */ 398 public void setFinAccountsReceivableObjCode(String finAccountsReceivableObjCode) { 399 this.finAccountsReceivableObjCode = finAccountsReceivableObjCode; 400 } 401 402 /** 403 * Gets the financialCashObjectCode attribute. 404 * 405 * @return Returns the financialCashObjectCode. 406 */ 407 public String getFinancialCashObjectCode() { 408 return financialCashObjectCode; 409 } 410 411 /** 412 * Sets the financialCashObjectCode attribute value. 413 * 414 * @param financialCashObjectCode The financialCashObjectCode to set. 415 */ 416 public void setFinancialCashObjectCode(String financialCashObjectCode) { 417 this.financialCashObjectCode = financialCashObjectCode; 418 } 419 420 /** 421 * Gets the finExternalEncumbranceObjCd attribute. 422 * 423 * @return Returns the finExternalEncumbranceObjCd. 424 */ 425 public String getFinExternalEncumbranceObjCd() { 426 return finExternalEncumbranceObjCd; 427 } 428 429 /** 430 * Sets the finExternalEncumbranceObjCd attribute value. 431 * 432 * @param finExternalEncumbranceObjCd The finExternalEncumbranceObjCd to set. 433 */ 434 public void setFinExternalEncumbranceObjCd(String finExternalEncumbranceObjCd) { 435 this.finExternalEncumbranceObjCd = finExternalEncumbranceObjCd; 436 } 437 438 /** 439 * Gets the finInternalEncumbranceObjCd attribute. 440 * 441 * @return Returns the finInternalEncumbranceObjCd. 442 */ 443 public String getFinInternalEncumbranceObjCd() { 444 return finInternalEncumbranceObjCd; 445 } 446 447 /** 448 * Sets the finInternalEncumbranceObjCd attribute value. 449 * 450 * @param finInternalEncumbranceObjCd The finInternalEncumbranceObjCd to set. 451 */ 452 public void setFinInternalEncumbranceObjCd(String finInternalEncumbranceObjCd) { 453 this.finInternalEncumbranceObjCd = finInternalEncumbranceObjCd; 454 } 455 456 /** 457 * Gets the finPreEncumbranceObjectCode attribute. 458 * 459 * @return Returns the finPreEncumbranceObjectCode. 460 */ 461 public String getFinPreEncumbranceObjectCode() { 462 return finPreEncumbranceObjectCode; 463 } 464 465 /** 466 * Sets the finPreEncumbranceObjectCode attribute value. 467 * 468 * @param finPreEncumbranceObjectCode The finPreEncumbranceObjectCode to set. 469 */ 470 public void setFinPreEncumbranceObjectCode(String finPreEncumbranceObjectCode) { 471 this.finPreEncumbranceObjectCode = finPreEncumbranceObjectCode; 472 } 473 474 /** 475 * Gets the icrExpenseFinancialObjectCd attribute. 476 * 477 * @return Returns the icrExpenseFinancialObjectCd. 478 */ 479 public String getIcrExpenseFinancialObjectCd() { 480 return icrExpenseFinancialObjectCd; 481 } 482 483 /** 484 * Sets the icrExpenseFinancialObjectCd attribute value. 485 * 486 * @param icrExpenseFinancialObjectCd The icrExpenseFinancialObjectCd to set. 487 */ 488 public void setIcrExpenseFinancialObjectCd(String icrExpenseFinancialObjectCd) { 489 this.icrExpenseFinancialObjectCd = icrExpenseFinancialObjectCd; 490 } 491 492 /** 493 * Gets the icrIncomeFinancialObjectCode attribute. 494 * 495 * @return Returns the icrIncomeFinancialObjectCode. 496 */ 497 public String getIcrIncomeFinancialObjectCode() { 498 return icrIncomeFinancialObjectCode; 499 } 500 501 /** 502 * Sets the icrIncomeFinancialObjectCode attribute value. 503 * 504 * @param icrIncomeFinancialObjectCode The icrIncomeFinancialObjectCode to set. 505 */ 506 public void setIcrIncomeFinancialObjectCode(String icrIncomeFinancialObjectCode) { 507 this.icrIncomeFinancialObjectCode = icrIncomeFinancialObjectCode; 508 } 509 510 /** 511 * Gets the expBdgtEliminationsFinObjCd attribute. 512 * 513 * @return Returns the expBdgtEliminationsFinObjCd 514 */ 515 public String getExpBdgtEliminationsFinObjCd() { 516 return expBdgtEliminationsFinObjCd; 517 } 518 519 /** 520 * Sets the expBdgtEliminationsFinObjCd attribute. 521 * 522 * @param expBdgtEliminationsFinObjCd The expBdgtEliminationsFinObjCd to set. 523 */ 524 public void setExpBdgtEliminationsFinObjCd(String expBdgtEliminationsFinObjCd) { 525 this.expBdgtEliminationsFinObjCd = expBdgtEliminationsFinObjCd; 526 } 527 528 /** 529 * Gets the incBdgtEliminationsFinObjCd attribute. 530 * 531 * @return Returns the incBdgtEliminationsFinObjCd 532 */ 533 public String getIncBdgtEliminationsFinObjCd() { 534 return incBdgtEliminationsFinObjCd; 535 } 536 537 /** 538 * Sets the incBdgtEliminationsFinObjCd attribute. 539 * 540 * @param incBdgtEliminationsFinObjCd The incBdgtEliminationsFinObjCd to set. 541 */ 542 public void setIncBdgtEliminationsFinObjCd(String incBdgtEliminationsFinObjCd) { 543 this.incBdgtEliminationsFinObjCd = incBdgtEliminationsFinObjCd; 544 } 545 546 private static ChartService chartService; 547 548 /** 549 * Gets the finCoaManagerPrincipalId attribute. 550 * 551 * @return Returns the finCoaManagerPrincipalId. 552 */ 553 public String getFinCoaManagerPrincipalId() { 554 if (StringUtils.isNotBlank(chartOfAccountsCode) && StringUtils.isBlank(finCoaManagerPrincipalId)) { 555 Person chartManager = getChartService().getChartManager(chartOfAccountsCode); 556 if (chartManager != null) { 557 finCoaManager = chartManager; 558 finCoaManagerPrincipalId = chartManager.getPrincipalId(); 559 } else { 560 finCoaManagerPrincipalId = null; 561 finCoaManager = null; 562 } 563 } 564 return finCoaManagerPrincipalId; 565 } 566 567 /** 568 * Sets the finCoaManagerPrincipalId attribute value. 569 * 570 * @param finCoaManagerPrincipalId The finCoaManagerPrincipalId to set. 571 */ 572 public void setFinCoaManagerPrincipalId(String finCoaManagerPrincipalId) { 573 this.finCoaManagerPrincipalId = finCoaManagerPrincipalId; 574 } 575 576 /** 577 * @return Returns the reportsToChartOfAccountsCode. 578 */ 579 public String getReportsToChartOfAccountsCode() { 580 return reportsToChartOfAccountsCode; 581 } 582 583 /** 584 * @param reportsToChartOfAccountsCode The reportsToChartOfAccountsCode to set. 585 */ 586 public void setReportsToChartOfAccountsCode(String reportsToChartOfAccountsCode) { 587 this.reportsToChartOfAccountsCode = reportsToChartOfAccountsCode; 588 } 589 590 /** 591 * Gets the fundBalanceObject attribute. 592 * 593 * @return Returns the fundBalanceObject. 594 */ 595 public ObjectCode getFundBalanceObject() { 596 return fundBalanceObject; 597 } 598 599 /** 600 * Sets the fundBalanceObject attribute value. 601 * 602 * @param fundBalanceObject The fundBalanceObject to set. 603 * @deprecated 604 */ 605 public void setFundBalanceObject(ObjectCode fundBalanceObject) { 606 this.fundBalanceObject = fundBalanceObject; 607 } 608 609 /** 610 * Gets the fundBalanceObjectCode attribute. 611 * 612 * @return Returns the fundBalanceObjectCode. 613 */ 614 public String getFundBalanceObjectCode() { 615 return fundBalanceObjectCode; 616 } 617 618 /** 619 * Sets the fundBalanceObjectCode attribute value. 620 * 621 * @param fundBalanceObjectCode The fundBalanceObjectCode to set. 622 */ 623 public void setFundBalanceObjectCode(String fundBalanceObjectCode) { 624 this.fundBalanceObjectCode = fundBalanceObjectCode; 625 } 626 627 /** 628 * @return Returns the code and description in format: xx - xxxxxxxxxxxxxxxx 629 */ 630 public String getCodeAndDescription() { 631 if (StringUtils.isNotBlank(getChartOfAccountsCode()) && StringUtils.isNotBlank(getFinChartOfAccountDescription())) 632 return getChartOfAccountsCode() + " - " + getFinChartOfAccountDescription(); 633 else 634 return ""; 635 } 636 637 public String getCode() { 638 return this.chartOfAccountsCode; 639 } 640 641 public String getName() { 642 return this.finChartOfAccountDescription; 643 } 644 645 protected static ChartService getChartService() { 646 if ( chartService == null ) { 647 chartService = SpringContext.getBean(ChartService.class); 648 } 649 return chartService; 650 } 651 652 public void setCode(String chartOfAccountsCode) { 653 setChartOfAccountsCode(chartOfAccountsCode); 654 } 655 656 public void setName(String finChartOfAccountDescription) { 657 setFinChartOfAccountDescription(finChartOfAccountDescription); 658 } 659 660 public String getChartCodeForReport() { 661 return this.chartOfAccountsCode; 662 } 663 } 664