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.ld.businessobject; 018 019 import java.util.ArrayList; 020 import java.util.List; 021 022 import org.kuali.kfs.module.ld.LaborConstants; 023 import org.kuali.kfs.sys.KFSPropertyConstants; 024 import org.kuali.kfs.sys.context.SpringContext; 025 import org.kuali.rice.kim.bo.Person; 026 import org.kuali.rice.kim.service.PersonService; 027 import org.kuali.rice.kns.util.KualiDecimal; 028 029 /** 030 * Labor business object for Account Status (Current Funds). 031 */ 032 public class AccountStatusCurrentFunds extends LedgerBalance { 033 private String personName; 034 private KualiDecimal outstandingEncum; 035 private KualiDecimal july1BudgetAmount; 036 private KualiDecimal annualActualAmount; 037 private KualiDecimal variance; 038 039 /** 040 * Constructs an AccountStatusCurrentFunds.java. 041 */ 042 public AccountStatusCurrentFunds() { 043 super(); 044 setMonth1Amount(KualiDecimal.ZERO); 045 this.setOutstandingEncum(KualiDecimal.ZERO); 046 this.setVariance(KualiDecimal.ZERO); 047 this.setJuly1BudgetAmount(KualiDecimal.ZERO); 048 this.setAnnualActualAmount(KualiDecimal.ZERO); 049 } 050 051 /** 052 * Gets the person name 053 * 054 * @return the person name 055 */ 056 public String getName() { 057 Person person = (Person) SpringContext.getBean(PersonService.class).getPersonByEmployeeId(getEmplid()); 058 if (person == null) { 059 return LaborConstants.BalanceInquiries.UnknownPersonName; 060 } 061 062 return person.getName(); 063 } 064 065 /** 066 * Sets the persons name 067 * 068 * @param personName 069 */ 070 public void setName(String personName) { 071 this.personName = personName; 072 } 073 074 /** 075 * Gets an outstanding encumberance value 076 * 077 * @return outstanding encumberance value 078 */ 079 public KualiDecimal getOutstandingEncum() { 080 return outstandingEncum; 081 } 082 083 /** 084 * Sets an outstanding encumberance value 085 * 086 * @param outstandingEncum 087 */ 088 public void setOutstandingEncum(KualiDecimal outstandingEncum) { 089 this.outstandingEncum = outstandingEncum; 090 } 091 092 /** 093 * Gets the Jul1BudgerAmount 094 * 095 * @return July1st amount 096 */ 097 public KualiDecimal getJuly1BudgetAmount() { 098 return july1BudgetAmount; 099 } 100 101 /** 102 * Sets the july1BudgetAmount 103 * 104 * @param july1BudgetAmount 105 */ 106 public void setJuly1BudgetAmount(KualiDecimal july1BudgetAmount) { 107 this.july1BudgetAmount = july1BudgetAmount; 108 } 109 110 /** 111 * Gets the variance which is calculated by substracting from July1BudgetAmount the YTD Actual, and outstanding encumbrance. 112 * 113 * @return 114 */ 115 public KualiDecimal getVariance() { 116 return this.getJuly1BudgetAmount().subtract(getAnnualActualAmount()).subtract(getOutstandingEncum()); 117 } 118 119 /** 120 * Sets the variance which is calculated by substracting from July1BudgetAmount the YTD Actual, and outstanding encumbrance. 121 * 122 * @param variance 123 */ 124 public void setVariance(KualiDecimal variance) { 125 this.variance = variance; 126 } 127 128 /** 129 * Returns a list of keys used to generate a query. 130 * 131 * @param consolidated 132 * @return a list with the keys needed to generate a query 133 */ 134 public List<String> getKeyFieldList(boolean consolidated) { 135 List<String> primaryKeyList = new ArrayList<String>(); 136 primaryKeyList.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR); 137 primaryKeyList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE); 138 primaryKeyList.add(KFSPropertyConstants.ACCOUNT_NUMBER); 139 140 if (!consolidated) { 141 primaryKeyList.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER); 142 } 143 144 primaryKeyList.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE); 145 146 if (!consolidated) { 147 primaryKeyList.add(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE); 148 } 149 primaryKeyList.add(KFSPropertyConstants.POSITION_NUMBER); 150 primaryKeyList.add(KFSPropertyConstants.EMPLID); 151 152 return primaryKeyList; 153 } 154 155 /** 156 * Gets the annualActualAmount attribute. 157 * 158 * @return Returns the annualActualAmount. 159 */ 160 public KualiDecimal getAnnualActualAmount() { 161 return this.getAccountLineAnnualBalanceAmount().add(this.getContractsGrantsBeginningBalanceAmount()); 162 } 163 164 /** 165 * Sets the annualActualAmount attribute value. 166 * 167 * @param annualActualAmount The annualActualAmount to set. 168 */ 169 public void setAnnualActualAmount(KualiDecimal annualActualAmount) { 170 this.annualActualAmount = annualActualAmount; 171 } 172 } 173