View Javadoc
1   /*
2    * Copyright 2012 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community License, Version 1.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl1.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.select.document;
17  
18  import org.kuali.ole.fp.document.DistributionOfIncomeAndExpenseDocument;
19  import org.kuali.ole.sys.OLEConstants;
20  import org.kuali.ole.sys.businessobject.SourceAccountingLine;
21  import org.kuali.ole.sys.businessobject.TargetAccountingLine;
22  
23  import java.util.List;
24  
25  public class OleDistributionOfIncomeAndExpenseDocument extends DistributionOfIncomeAndExpenseDocument {
26  
27      /**
28       * Provides answers to the following splits: HasVendorDepositAccount
29       *
30       * @see org.kuali.ole.sys.document.FinancialSystemTransactionalDocumentBase#answerSplitNodeQuestion(java.lang.String)
31       */
32      @Override
33      public boolean answerSplitNodeQuestion(String nodeName) throws UnsupportedOperationException {
34          if (nodeName.equals(OLEConstants.HAS_VENDOR_DEPOSIT_ACCOUNT)) {
35              return hasVendorDepositAccount();
36          }
37          throw new UnsupportedOperationException("Cannot answer split question for this node you call \"" + nodeName + "\"");
38      }
39  
40      private boolean hasVendorDepositAccount() {
41          List<SourceAccountingLine> sourceAccounts = this.getSourceAccountingLines();
42          List<TargetAccountingLine> targetAccounts = this.getTargetAccountingLines();
43          for (SourceAccountingLine sourceAccount : sourceAccounts) {
44              if (sourceAccount.getAccount().getSubFundGroupCode().equalsIgnoreCase(OLEConstants.CLEARING_ACCOUNT_CODE)) {
45                  return true;
46              }
47          }
48          for (TargetAccountingLine targetAccount : targetAccounts) {
49              if (targetAccount.getAccount().getSubFundGroupCode().equalsIgnoreCase(OLEConstants.CLEARING_ACCOUNT_CODE)) {
50                  return true;
51              }
52          }
53          return false;
54      }
55  }