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.businessobject.GECSourceAccountingLine;
19  import org.kuali.ole.fp.businessobject.GECTargetAccountingLine;
20  import org.kuali.ole.fp.document.GeneralErrorCorrectionDocument;
21  import org.kuali.ole.sys.OLEConstants;
22  
23  import java.util.List;
24  
25  public class OleGeneralErrorCorrectionDocument extends GeneralErrorCorrectionDocument {
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          throw new UnsupportedOperationException("Cannot answer split question for this node you call \"" + nodeName + "\"");
37      }
38  
39      private boolean hasVendorDepositAccount() {
40          List<GECSourceAccountingLine> sourceAccounts = this.getSourceAccountingLines();
41          List<GECTargetAccountingLine> targetAccounts = this.getTargetAccountingLines();
42          for (GECSourceAccountingLine sourceAccount : sourceAccounts) {
43              if (sourceAccount.getAccount().getSubFundGroupCode().equalsIgnoreCase(OLEConstants.CLEARING_ACCOUNT_CODE)) {
44                  return true;
45              }
46          }
47          for (GECTargetAccountingLine targetAccount : targetAccounts) {
48              if (targetAccount.getAccount().getSubFundGroupCode().equalsIgnoreCase(OLEConstants.CLEARING_ACCOUNT_CODE)) {
49                  return true;
50              }
51          }
52          return false;
53      }
54  
55  }