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 017 package org.kuali.kfs.module.bc.businessobject; 018 019 import java.util.ArrayList; 020 import java.util.HashMap; 021 import java.util.LinkedHashMap; 022 import java.util.List; 023 import java.util.Map; 024 025 import org.kuali.kfs.coa.businessobject.Account; 026 import org.kuali.kfs.coa.businessobject.BalanceType; 027 import org.kuali.kfs.coa.businessobject.Chart; 028 import org.kuali.kfs.coa.businessobject.ObjectCode; 029 import org.kuali.kfs.coa.businessobject.ObjectType; 030 import org.kuali.kfs.coa.businessobject.SubAccount; 031 import org.kuali.kfs.coa.businessobject.SubObjectCode; 032 import org.kuali.kfs.integration.ld.LaborLedgerObject; 033 import org.kuali.kfs.integration.ld.LaborLedgerPositionObjectBenefit; 034 import org.kuali.kfs.module.bc.util.SalarySettingCalculator; 035 import org.kuali.kfs.sys.KFSPropertyConstants; 036 import org.kuali.kfs.sys.ObjectUtil; 037 import org.kuali.kfs.sys.context.SpringContext; 038 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; 039 import org.kuali.rice.kns.service.BusinessObjectService; 040 import org.kuali.rice.kns.service.KualiModuleService; 041 import org.kuali.rice.kns.util.KualiDecimal; 042 import org.kuali.rice.kns.util.KualiInteger; 043 import org.kuali.rice.kns.util.TypedArrayList; 044 045 public class PendingBudgetConstructionGeneralLedger extends PersistableBusinessObjectBase { 046 047 private String documentNumber; 048 private Integer universityFiscalYear; 049 private String chartOfAccountsCode; 050 private String accountNumber; 051 private String subAccountNumber; 052 private String financialObjectCode; 053 private String financialSubObjectCode; 054 private String financialBalanceTypeCode; 055 private String financialObjectTypeCode; 056 private KualiInteger accountLineAnnualBalanceAmount; 057 private KualiInteger financialBeginningBalanceLineAmount; 058 059 private BudgetConstructionHeader budgetConstructionHeader; 060 private ObjectCode financialObject; 061 private Chart chartOfAccounts; 062 private Account account; 063 private SubAccount subAccount; 064 private SubObjectCode financialSubObject; 065 private BalanceType balanceType; 066 private ObjectType objectType; 067 068 private List<BudgetConstructionMonthly> budgetConstructionMonthly; 069 070 // These are not defined under ojb since not all expenditure line objects have these 071 private LaborLedgerObject laborObject; 072 private List<LaborLedgerPositionObjectBenefit> positionObjectBenefit; 073 074 private KualiDecimal adjustmentAmount; 075 private KualiDecimal percentChange; 076 private KualiInteger persistedAccountLineAnnualBalanceAmount; 077 private boolean pendingBudgetConstructionAppointmentFundingExists; 078 079 /** 080 * Default constructor. 081 */ 082 public PendingBudgetConstructionGeneralLedger() { 083 super(); 084 085 budgetConstructionMonthly = new TypedArrayList(BudgetConstructionMonthly.class); 086 } 087 088 /** 089 * Gets the adjustmentAmount attribute. 090 * @return Returns the adjustmentAmount. 091 */ 092 public KualiDecimal getAdjustmentAmount() { 093 return adjustmentAmount; 094 } 095 096 /** 097 * Sets the adjustmentAmount attribute value. 098 * @param adjustmentAmount The adjustmentAmount to set. 099 */ 100 public void setAdjustmentAmount(KualiDecimal adjustmentAmount) { 101 this.adjustmentAmount = adjustmentAmount; 102 } 103 104 /** 105 * Gets(sets) the percentChange based on the current values of base and request amounts 106 * 107 * @return Returns percentChange 108 */ 109 public KualiDecimal getPercentChange() { 110 KualiInteger baseAmount = this.getFinancialBeginningBalanceLineAmount(); 111 KualiInteger requestedAmount = this.getAccountLineAnnualBalanceAmount(); 112 113 return SalarySettingCalculator.getPercentChange(baseAmount, requestedAmount); 114 } 115 116 /** 117 * Sets the percentChange attribute value. 118 * 119 * @param percentChange The percentChange to set. 120 */ 121 public void setPercentChange(KualiDecimal percentChange) { 122 this.percentChange = percentChange; 123 } 124 125 /** 126 * Gets the documentNumber attribute. 127 * 128 * @return Returns the documentNumber 129 */ 130 public String getDocumentNumber() { 131 return documentNumber; 132 } 133 134 /** 135 * Sets the documentNumber attribute. 136 * 137 * @param documentNumber The documentNumber to set. 138 */ 139 public void setDocumentNumber(String documentNumber) { 140 this.documentNumber = documentNumber; 141 } 142 143 144 /** 145 * Gets the universityFiscalYear attribute. 146 * 147 * @return Returns the universityFiscalYear 148 */ 149 public Integer getUniversityFiscalYear() { 150 return universityFiscalYear; 151 } 152 153 /** 154 * Sets the universityFiscalYear attribute. 155 * 156 * @param universityFiscalYear The universityFiscalYear to set. 157 */ 158 public void setUniversityFiscalYear(Integer universityFiscalYear) { 159 this.universityFiscalYear = universityFiscalYear; 160 } 161 162 163 /** 164 * Gets the chartOfAccountsCode attribute. 165 * 166 * @return Returns the chartOfAccountsCode 167 */ 168 public String getChartOfAccountsCode() { 169 return chartOfAccountsCode; 170 } 171 172 /** 173 * Sets the chartOfAccountsCode attribute. 174 * 175 * @param chartOfAccountsCode The chartOfAccountsCode to set. 176 */ 177 public void setChartOfAccountsCode(String chartOfAccountsCode) { 178 this.chartOfAccountsCode = chartOfAccountsCode; 179 } 180 181 182 /** 183 * Gets the accountNumber attribute. 184 * 185 * @return Returns the accountNumber 186 */ 187 public String getAccountNumber() { 188 return accountNumber; 189 } 190 191 /** 192 * Sets the accountNumber attribute. 193 * 194 * @param accountNumber The accountNumber to set. 195 */ 196 public void setAccountNumber(String accountNumber) { 197 this.accountNumber = accountNumber; 198 } 199 200 201 /** 202 * Gets the subAccountNumber attribute. 203 * 204 * @return Returns the subAccountNumber 205 */ 206 public String getSubAccountNumber() { 207 return subAccountNumber; 208 } 209 210 /** 211 * Sets the subAccountNumber attribute. 212 * 213 * @param subAccountNumber The subAccountNumber to set. 214 */ 215 public void setSubAccountNumber(String subAccountNumber) { 216 this.subAccountNumber = subAccountNumber; 217 } 218 219 220 /** 221 * Gets the financialObjectCode attribute. 222 * 223 * @return Returns the financialObjectCode 224 */ 225 public String getFinancialObjectCode() { 226 return financialObjectCode; 227 } 228 229 /** 230 * Sets the financialObjectCode attribute. 231 * 232 * @param financialObjectCode The financialObjectCode to set. 233 */ 234 public void setFinancialObjectCode(String financialObjectCode) { 235 this.financialObjectCode = financialObjectCode; 236 } 237 238 239 /** 240 * Gets the financialSubObjectCode attribute. 241 * 242 * @return Returns the financialSubObjectCode 243 */ 244 public String getFinancialSubObjectCode() { 245 return financialSubObjectCode; 246 } 247 248 /** 249 * Sets the financialSubObjectCode attribute. 250 * 251 * @param financialSubObjectCode The financialSubObjectCode to set. 252 */ 253 public void setFinancialSubObjectCode(String financialSubObjectCode) { 254 this.financialSubObjectCode = financialSubObjectCode; 255 } 256 257 258 /** 259 * Gets the financialBalanceTypeCode attribute. 260 * 261 * @return Returns the financialBalanceTypeCode 262 */ 263 public String getFinancialBalanceTypeCode() { 264 return financialBalanceTypeCode; 265 } 266 267 /** 268 * Sets the financialBalanceTypeCode attribute. 269 * 270 * @param financialBalanceTypeCode The financialBalanceTypeCode to set. 271 */ 272 public void setFinancialBalanceTypeCode(String financialBalanceTypeCode) { 273 this.financialBalanceTypeCode = financialBalanceTypeCode; 274 } 275 276 277 /** 278 * Gets the financialObjectTypeCode attribute. 279 * 280 * @return Returns the financialObjectTypeCode 281 */ 282 public String getFinancialObjectTypeCode() { 283 return financialObjectTypeCode; 284 } 285 286 /** 287 * Sets the financialObjectTypeCode attribute. 288 * 289 * @param financialObjectTypeCode The financialObjectTypeCode to set. 290 */ 291 public void setFinancialObjectTypeCode(String financialObjectTypeCode) { 292 this.financialObjectTypeCode = financialObjectTypeCode; 293 } 294 295 296 /** 297 * Gets the accountLineAnnualBalanceAmount attribute. 298 * 299 * @return Returns the accountLineAnnualBalanceAmount. 300 */ 301 public KualiInteger getAccountLineAnnualBalanceAmount() { 302 if (accountLineAnnualBalanceAmount == null) { 303 accountLineAnnualBalanceAmount = KualiInteger.ZERO; 304 } 305 return accountLineAnnualBalanceAmount; 306 } 307 308 /** 309 * Sets the accountLineAnnualBalanceAmount attribute value. 310 * 311 * @param accountLineAnnualBalanceAmount The accountLineAnnualBalanceAmount to set. 312 */ 313 public void setAccountLineAnnualBalanceAmount(KualiInteger accountLineAnnualBalanceAmount) { 314 this.accountLineAnnualBalanceAmount = accountLineAnnualBalanceAmount; 315 } 316 317 /** 318 * Gets the persistedAccountLineAnnualBalanceAmount attribute. 319 * 320 * @return Returns the persistedAccountLineAnnualBalanceAmount. 321 */ 322 public KualiInteger getPersistedAccountLineAnnualBalanceAmount() { 323 return persistedAccountLineAnnualBalanceAmount; 324 } 325 326 /** 327 * Sets the persistedAccountLineAnnualBalanceAmount attribute value. 328 * 329 * @param persistedAccountLineAnnualBalanceAmount The persistedAccountLineAnnualBalanceAmount to set. 330 */ 331 public void setPersistedAccountLineAnnualBalanceAmount(KualiInteger persistedAccountLineAnnualBalanceAmount) { 332 this.persistedAccountLineAnnualBalanceAmount = persistedAccountLineAnnualBalanceAmount; 333 } 334 335 /** 336 * Gets the financialBeginningBalanceLineAmount attribute. 337 * 338 * @return Returns the financialBeginningBalanceLineAmount. 339 */ 340 public KualiInteger getFinancialBeginningBalanceLineAmount() { 341 return financialBeginningBalanceLineAmount; 342 } 343 344 /** 345 * Sets the financialBeginningBalanceLineAmount attribute value. 346 * 347 * @param financialBeginningBalanceLineAmount The financialBeginningBalanceLineAmount to set. 348 */ 349 public void setFinancialBeginningBalanceLineAmount(KualiInteger financialBeginningBalanceLineAmount) { 350 this.financialBeginningBalanceLineAmount = financialBeginningBalanceLineAmount; 351 } 352 353 /** 354 * Gets the budgetConstructionMonthly attribute. 355 * 356 * @return Returns the budgetConstructionMonthly 357 */ 358 public List<BudgetConstructionMonthly> getBudgetConstructionMonthly() { 359 return budgetConstructionMonthly; 360 } 361 362 /** 363 * Sets the budgetConstructionMonthly attribute. 364 * 365 * @param budgetConstructionMonthly The budgetConstructionMonthly to set. 366 * @deprecated 367 */ 368 public void setBudgetConstructionMonthly(List<BudgetConstructionMonthly> budgetConstructionMonthly) { 369 this.budgetConstructionMonthly = budgetConstructionMonthly; 370 } 371 372 /** 373 * Gets the financialObject attribute. 374 * 375 * @return Returns the financialObject 376 */ 377 public ObjectCode getFinancialObject() { 378 return financialObject; 379 } 380 381 /** 382 * Sets the financialObject attribute. 383 * 384 * @param financialObject The financialObject to set. 385 * @deprecated 386 */ 387 public void setFinancialObject(ObjectCode financialObject) { 388 this.financialObject = financialObject; 389 } 390 391 /** 392 * Gets the chartOfAccounts attribute. 393 * 394 * @return Returns the chartOfAccounts 395 */ 396 public Chart getChartOfAccounts() { 397 return chartOfAccounts; 398 } 399 400 /** 401 * Sets the chartOfAccounts attribute. 402 * 403 * @param chartOfAccounts The chartOfAccounts to set. 404 * @deprecated 405 */ 406 public void setChartOfAccounts(Chart chartOfAccounts) { 407 this.chartOfAccounts = chartOfAccounts; 408 } 409 410 /** 411 * Gets the account attribute. 412 * 413 * @return Returns the account 414 */ 415 public Account getAccount() { 416 return account; 417 } 418 419 /** 420 * Sets the account attribute. 421 * 422 * @param account The account to set. 423 * @deprecated 424 */ 425 public void setAccount(Account account) { 426 this.account = account; 427 } 428 429 /** 430 * Gets the financialSubObject attribute. 431 * 432 * @return Returns the financialSubObject. 433 */ 434 public SubObjectCode getFinancialSubObject() { 435 return financialSubObject; 436 } 437 438 /** 439 * Sets the financialSubObject attribute value. 440 * 441 * @param financialSubObject The financialSubObject to set. 442 * @deprecated 443 */ 444 public void setFinancialSubObject(SubObjectCode financialSubObject) { 445 this.financialSubObject = financialSubObject; 446 } 447 448 /** 449 * Gets the subAccount attribute. 450 * 451 * @return Returns the subAccount. 452 */ 453 public SubAccount getSubAccount() { 454 return subAccount; 455 } 456 457 /** 458 * Sets the subAccount attribute value. 459 * 460 * @param subAccount The subAccount to set. 461 * @deprecated 462 */ 463 public void setSubAccount(SubAccount subAccount) { 464 this.subAccount = subAccount; 465 } 466 467 /** 468 * Gets the balanceType attribute. 469 * 470 * @return Returns the balanceType. 471 */ 472 public BalanceType getBalanceType() { 473 return balanceType; 474 } 475 476 /** 477 * Sets the balanceType attribute value. 478 * 479 * @param balanceType The balanceType to set. 480 * @deprecated 481 */ 482 public void setBalanceType(BalanceType balanceType) { 483 this.balanceType = balanceType; 484 } 485 486 /** 487 * Gets the objectType attribute. 488 * 489 * @return Returns the objectType. 490 */ 491 public ObjectType getObjectType() { 492 return objectType; 493 } 494 495 /** 496 * Sets the objectType attribute value. 497 * 498 * @param objectType The objectType to set. 499 * @deprecated 500 */ 501 public void setObjectType(ObjectType objectType) { 502 this.objectType = objectType; 503 } 504 505 /** 506 * Gets the budgetConstructionHeader attribute. 507 * 508 * @return Returns the budgetConstructionHeader. 509 */ 510 public BudgetConstructionHeader getBudgetConstructionHeader() { 511 return budgetConstructionHeader; 512 } 513 514 /** 515 * Sets the budgetConstructionHeader attribute value. 516 * 517 * @param budgetConstructionHeader The budgetConstructionHeader to set. 518 * @deprecated 519 */ 520 public void setBudgetConstructionHeader(BudgetConstructionHeader budgetConstructionHeader) { 521 this.budgetConstructionHeader = budgetConstructionHeader; 522 } 523 524 /** 525 * Gets the laborObject attribute. 526 * 527 * @return Returns the laborObject. 528 */ 529 public LaborLedgerObject getLaborObject() { 530 laborObject = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(LaborLedgerObject.class).retrieveExternalizableBusinessObjectIfNecessary(this, laborObject, "laborObject"); 531 return laborObject; 532 } 533 534 /** 535 * Sets the laborObject attribute value. 536 * 537 * @param laborObject The laborObject to set. 538 */ 539 public void setLaborObject(LaborLedgerObject laborObject) { 540 this.laborObject = laborObject; 541 } 542 543 /** 544 * Gets the positionObjectBenefit attribute. 545 * 546 * @return Returns the positionObjectBenefit. 547 */ 548 public List<LaborLedgerPositionObjectBenefit> getPositionObjectBenefit() { 549 positionObjectBenefit = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(LaborLedgerPositionObjectBenefit.class).retrieveExternalizableBusinessObjectsList(this, "positionObjectBenefit", LaborLedgerPositionObjectBenefit.class); 550 return positionObjectBenefit; 551 } 552 553 /** 554 * Sets the positionObjectBenefit attribute value. 555 * 556 * @param positionObjectBenefit The positionObjectBenefit to set. 557 */ 558 public void setPositionObjectBenefit(List<LaborLedgerPositionObjectBenefit> positionObjectBenefit) { 559 this.positionObjectBenefit = positionObjectBenefit; 560 } 561 562 /** 563 * Gets the pendingBudgetConstructionAppointmentFundingExists attribute. 564 * 565 * @return Returns the pendingBudgetConstructionAppointmentFundingExists. 566 */ 567 public boolean isPendingBudgetConstructionAppointmentFundingExists() { 568 pendingBudgetConstructionAppointmentFundingExists = false; 569 570 if (this.getLaborObject() != null && this.getLaborObject().isDetailPositionRequiredIndicator()) { 571 Map<String, Object> fieldValues = new HashMap<String, Object>(); 572 573 fieldValues.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, getUniversityFiscalYear()); 574 fieldValues.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, getChartOfAccountsCode()); 575 fieldValues.put(KFSPropertyConstants.ACCOUNT_NUMBER, getAccountNumber()); 576 fieldValues.put(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, getSubAccountNumber()); 577 fieldValues.put(KFSPropertyConstants.FINANCIAL_OBJECT_CODE, getFinancialObjectCode()); 578 fieldValues.put(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE, getFinancialSubObjectCode()); 579 580 int recCount = SpringContext.getBean(BusinessObjectService.class).countMatching(PendingBudgetConstructionAppointmentFunding.class, fieldValues); 581 582 pendingBudgetConstructionAppointmentFundingExists = (recCount > 0) ? true : false; 583 } 584 585 return pendingBudgetConstructionAppointmentFundingExists; 586 } 587 588 /** 589 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper() 590 */ 591 protected LinkedHashMap toStringMapper() { 592 LinkedHashMap m = new LinkedHashMap(); 593 594 if (this.universityFiscalYear != null) { 595 m.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, this.universityFiscalYear.toString()); 596 } 597 598 m.put(KFSPropertyConstants.DOCUMENT_NUMBER, this.getDocumentNumber()); 599 m.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, this.getChartOfAccountsCode()); 600 m.put(KFSPropertyConstants.ACCOUNT_NUMBER, this.getAccountNumber()); 601 m.put(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, this.getSubAccountNumber()); 602 m.put(KFSPropertyConstants.FINANCIAL_OBJECT_CODE, this.getFinancialObjectCode()); 603 m.put(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE, this.getFinancialSubObjectCode()); 604 m.put(KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE, this.getFinancialBalanceTypeCode()); 605 m.put(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE, this.getFinancialObjectTypeCode()); 606 607 return m; 608 } 609 610 /** 611 * Returns a map with the primitive field names as the key and the primitive values as the map value. 612 * 613 * @return Map 614 */ 615 public Map<String, Object> getValuesMap() { 616 Map<String, Object> simpleValues = this.buildPrimaryKeyMap(); 617 618 return simpleValues; 619 } 620 621 /** 622 * build the primary key map with the field names as the map keys and the field values as the map values 623 * 624 * @return the primary key map with the field names as the map keys and the field values as the map values 625 */ 626 public Map<String, Object> buildPrimaryKeyMap() { 627 return ObjectUtil.buildPropertyMap(this, getPrimaryKeyFields()); 628 } 629 630 /** 631 * get the list of primary keys 632 * @return the list of primary keys 633 */ 634 public static List<String> getPrimaryKeyFields(){ 635 List<String> primaryKeyFields = new ArrayList<String>(); 636 primaryKeyFields.add(KFSPropertyConstants.DOCUMENT_NUMBER); 637 primaryKeyFields.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR); 638 primaryKeyFields.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE); 639 primaryKeyFields.add(KFSPropertyConstants.ACCOUNT_NUMBER); 640 primaryKeyFields.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER); 641 primaryKeyFields.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE); 642 primaryKeyFields.add(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE); 643 primaryKeyFields.add(KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE); 644 primaryKeyFields.add(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE); 645 646 return primaryKeyFields; 647 } 648 }