001: /*
002: * Copyright 2006-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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.module.financial.service.impl;
017:
018: import org.kuali.module.chart.bo.Account;
019: import org.kuali.module.chart.bo.ObjectCode;
020: import org.kuali.module.financial.service.AccountPresenceService;
021: import org.kuali.module.gl.bo.Balance;
022: import org.kuali.module.gl.dao.BalanceDao;
023: import org.springframework.transaction.annotation.Transactional;
024:
025: /**
026: *
027: * This is the default implementation of the AccountPresenceService interface.
028: *
029: */
030: @Transactional
031: public class AccountPresenceServiceImpl implements
032: AccountPresenceService {
033: private BalanceDao balanceDao;
034:
035: /**
036: * This method determines if an object code has been budgeted for account presence.
037: *
038: * @param account The account to be checked for the presence control flag.
039: * @param objectCode The object code being reviewed.
040: * @return True if the object code has been budgeted for an account presence, false otherwise.
041: *
042: * @see org.kuali.module.financial.service.AccountPresenceService#isObjectCodeBudgetedForAccountPresence(org.kuali.module.chart.bo.Account, org.kuali.module.chart.bo.ObjectCode)
043: */
044: public boolean isObjectCodeBudgetedForAccountPresence(
045: Account account, ObjectCode objectCode) {
046: boolean objectCodeValid = true;
047:
048: /*
049: * first check if account has presence control turned on, if not no checks need to take place on object code budgeting
050: */
051: if (account.isFinancialObjectivePrsctrlIndicator()) {
052: /*
053: * can have budgeting record for object code, it's consolidation code, or object level
054: */
055:
056: // try to find budget record for object code
057: Balance foundBalance = (Balance) balanceDao
058: .getCurrentBudgetForObjectCode(objectCode
059: .getUniversityFiscalYear(), account
060: .getChartOfAccountsCode(), account
061: .getAccountNumber(), objectCode
062: .getFinancialObjectCode());
063:
064: // if object code budget not found, try consolidation object code
065: if (foundBalance == null) {
066: foundBalance = (Balance) balanceDao
067: .getCurrentBudgetForObjectCode(objectCode
068: .getUniversityFiscalYear(), account
069: .getChartOfAccountsCode(), account
070: .getAccountNumber(), objectCode
071: .getFinancialObjectLevel()
072: .getConsolidatedObjectCode());
073:
074: // if consolidation object code budget not found, try object level
075: if (foundBalance == null) {
076: foundBalance = (Balance) balanceDao
077: .getCurrentBudgetForObjectCode(objectCode
078: .getUniversityFiscalYear(), account
079: .getChartOfAccountsCode(), account
080: .getAccountNumber(), objectCode
081: .getFinancialObjectLevelCode());
082:
083: // object not budgeted
084: if (foundBalance == null) {
085: objectCodeValid = false;
086: }
087: }
088: }
089: }
090:
091: return objectCodeValid;
092: }
093:
094: /**
095: * Simple getter used to retrieve an instance of the BalanceDao.
096: *
097: * @return Returns the balanceDao.
098: */
099: public BalanceDao getBalanceDao() {
100: return balanceDao;
101: }
102:
103: /**
104: * Simple setter used to set the local BalanceDao attribute.
105: *
106: * @param balanceDao The balanceDao to set.
107: */
108: public void setBalanceDao(BalanceDao balanceDao) {
109: this.balanceDao = balanceDao;
110: }
111: }
|