1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
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  
29  
30  
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  }