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.service;
017
018 import java.util.Collection;
019 import java.util.Iterator;
020 import java.util.List;
021
022 import org.kuali.kfs.coa.businessobject.Account;
023 import org.kuali.kfs.coa.businessobject.AccountDelegate;
024 import org.kuali.kfs.sys.businessobject.AccountingLine;
025 import org.kuali.kfs.sys.businessobject.SourceAccountingLine;
026 import org.kuali.rice.kim.bo.Person;
027 import org.kuali.kfs.sys.document.AccountingDocument;
028 import org.kuali.rice.kim.bo.Person;
029
030
031 /**
032 * This interface defines methods that an Account Service must provide
033 */
034 public interface AccountService {
035 /**
036 * Retrieves an Account object based on primary key.
037 *
038 * @param chartOfAccountsCode - Chart of Accounts Code
039 * @param accountNumber - Account Number
040 * @return Account
041 */
042 public Account getByPrimaryId(String chartOfAccountsCode, String accountNumber);
043
044 /**
045 * Method is used by KualiAccountAttribute to enable caching of orgs for routing.
046 *
047 * @see org.kuali.kfs.coa.service.AccountService#getByPrimaryId(java.lang.String, java.lang.String)
048 */
049 public Account getByPrimaryIdWithCaching(String chartOfAccountsCode, String accountNumber);
050
051 /**
052 * This method retrieves the fiscal officers primary delegate based on the chart, account, and document type specified on the
053 * example, along with the total dollar amount
054 *
055 * @param delegateExample The object that contains the chart, account, and document type that should be used to query the
056 * account delegate table
057 * @param totalDollarAmount The amount that should be compared to the from and to amount on the account delegate table
058 * @return The primary delegate for this account, document type, and amount
059 */
060 public AccountDelegate getPrimaryDelegationByExample(AccountDelegate delegateExample, String totalDollarAmount);
061
062 /**
063 * This method retrieves the fiscal officers secondary delegates based on the chart, account, and document type specified on the
064 * example, along with the total dollar amount
065 *
066 * @param delegateExample The object that contains the chart, account, and document type that should be used to query the
067 * account delegate table
068 * @param totalDollarAmount The amount that should be compared to the from and to amount on the account delegate table
069 * @return The primary delegate for this account, document type, and amount
070 */
071 public List getSecondaryDelegationsByExample(AccountDelegate delegateExample, String totalDollarAmount);
072
073 /**
074 * Fetches the accounts that the user is either the fiscal officer or fiscal officer delegate for.
075 *
076 * @param kualiUser
077 * @return a list of Accounts that the user has responsibility for
078 */
079 public List getAccountsThatUserIsResponsibleFor(Person kualiUser);
080
081 /**
082 * Does the given user have responsibilities on the given account?
083 *
084 * @param kualiUser the universal user to check responsibilities for
085 * @param account the account to check responsibilities on
086 * @return true if user does have responsibilities, false if otherwise
087 */
088 public boolean hasResponsibilityOnAccount(Person kualiUser, Account account);
089
090 /**
091 * get all accounts in the system. This is needed by a sufficient funds rebuilder job
092 *
093 * @return iterator of all accounts
094 */
095 public Iterator getAllAccounts();
096
097 /**
098 * Retrieves all active accounts from the database where the given principal is the fiscal officer
099 * @param principalId the principal id of the fiscal officer
100 * @return an Iterator of active Accounts
101 */
102 public abstract Iterator<Account> getActiveAccountsForFiscalOfficer(String principalId);
103
104 /**
105 * Retrieves all expired accounts from the database where the given principal is the fiscal officer
106 * @param principalId the principal id of the fiscal officer
107 * @return an Iterator of expired Accounts
108 */
109 public abstract Iterator<Account> getExpiredAccountsForFiscalOfficer(String principalId);
110
111 /**
112 * Retrieves all active accounts from the database where the given principal is the account supervisor
113 * @param principalId the principal id of the account supervisor
114 * @return an Iterator of active Accounts
115 */
116 public abstract Iterator<Account> getActiveAccountsForAccountSupervisor(String principalId);
117
118 /**
119 * Retrieves all active accounts from the database where the given principal is the account supervisor
120 * @param principalId the principal id of the account supervisor
121 * @return an Iterator of expired Accounts
122 */
123 public abstract Iterator<Account> getExpiredAccountsForAccountSupervisor(String principalId);
124
125 /**
126 * Determines if the given principal is the fiscal officer of any non-closed account
127 * @param principalId the principal to check for the fiscal officer role
128 * @return true if the principal is a fiscal officer for any non-closed account, false otherwise
129 */
130 public abstract boolean isPrincipalInAnyWayShapeOrFormFiscalOfficer(String principalId);
131
132 /**
133 * Determines if the given principal is the account supervisor of any non-closed account
134 * @param principalId the principal to check for the account supervisor role
135 * @return true if the principal is a account supervisor for any non-closed account, false otherwise
136 */
137 public abstract boolean isPrincipalInAnyWayShapeOrFormAccountSupervisor(String principalId);
138
139 /**
140 * Determines if the given principal is the account manager of any non-closed account
141 * @param principalId the principal to check for the account manager role
142 * @return true if the principal is a account manager for any non-closed account, false otherwise
143 */
144 public abstract boolean isPrincipalInAnyWayShapeOrFormAccountManager(String principalId);
145
146 /**
147 * Returns the accounts associated with a given account number
148 * @param accountNumber the account number
149 * @return a list of accounts associated with that account number
150 */
151 public abstract Collection<Account> getAccountsForAccountNumber(String accountNumber);
152
153 /**
154 * Returns the unique account associated with a given account number.
155 * This method only applies when parameter ACCOUNTS_CAN_CROSS_CHARTS_IND is set to "N".
156 * @param accountNumber the account number
157 * @return the unique account associated with that account number
158 */
159 public Account getUniqueAccountForAccountNumber(String accountNumber);
160
161 /**
162 * Returns true if parameter ACCOUNTS_CAN_CROSS_CHARTS_IND is set to "Y"; otherwise false.
163 */
164 public boolean accountsCanCrossCharts();
165
166 /*
167 * Populate chart code if it's null, according to the account number in the specified accounting line.
168 * This only happens when parameter ACCOUNTS_CAN_CROSS_CHARTS_IND is set to "N", and Javascript is turned off.
169 * @param the new source accounting line
170 */
171 public void populateAccountingLineChartIfNeeded(AccountingLine line);
172 }
173