View Javadoc
1   /*
2    * Copyright 2006 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.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/ecl2.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.fp.document;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.ole.fp.businessobject.CapitalAssetAccountsGroupDetails;
22  import org.kuali.ole.fp.businessobject.CapitalAssetInformation;
23  import org.kuali.ole.fp.businessobject.CapitalAssetInformationDetail;
24  import org.kuali.ole.integration.cab.CapitalAssetBuilderModuleService;
25  import org.kuali.ole.sys.businessobject.AccountingLine;
26  import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntrySourceDetail;
27  import org.kuali.ole.sys.context.SpringContext;
28  import org.kuali.ole.sys.document.AccountingDocumentBase;
29  import org.kuali.ole.sys.document.service.DebitDeterminerService;
30  import org.kuali.rice.kew.framework.postprocessor.DocumentRouteStatusChange;
31  import org.kuali.rice.krad.util.ObjectUtils;
32  
33  /**
34   * class which defines behavior common for capital asset information lines.
35   */
36   public class CapitalAssetInformationDocumentBase extends AccountingDocumentBase implements CapitalAssetEditable {
37      protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CapitalAssetInformationDocumentBase.class);
38      protected Integer nextCapitalAssetLineNumber;
39      
40      // capital asset
41      protected List<CapitalAssetInformation> capitalAssetInformation;
42      
43      /**
44       * Constructs a CapitalAssetInformationDocumentBase
45       */
46      public CapitalAssetInformationDocumentBase() {
47          super();
48          
49          this.setCapitalAssetInformation(new ArrayList());
50          this.setNextCapitalAssetLineNumber(1);
51      }
52  
53      /**
54       * @see org.kuali.ole.sys.document.GeneralLedgerPostingDocumentBase#doRouteStatusChange()
55       */
56      @Override
57      public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
58          super.doRouteStatusChange(statusChangeEvent);
59  
60          String documentNumber = getDocumentHeader().getDocumentNumber();
61          // update gl status as processed when all the capital assets have been processed...
62          SpringContext.getBean(CapitalAssetBuilderModuleService.class).markProcessedGLEntryLine(documentNumber);
63      }
64      
65      /**
66       * @see org.kuali.ole.sys.document.AccountingDocumentBase#buildListOfDeletionAwareLists()
67       */
68      @Override
69      public List buildListOfDeletionAwareLists() {
70          List<List> managedLists = super.buildListOfDeletionAwareLists();
71          
72          List<CapitalAssetInformation> capitalAssets = new ArrayList<CapitalAssetInformation>();
73          capitalAssets.addAll(this.getCapitalAssetInformation());
74  
75          managedLists.add(capitalAssets); 
76         
77          return managedLists;
78      }
79  
80      /**
81       * Return true if account line is debit
82       * 
83       * @param financialDocument submitted accounting document
84       * @param accountingLine accounting line from accounting document
85       * @return true is account line is debit
86       * @see IsDebitUtils#isDebitConsideringSectionAndTypePositiveOnly(FinancialDocumentRuleBase, FinancialDocument, AccountingLine)
87       * @see org.kuali.rice.krad.rule.AccountingLineRule#isDebit(org.kuali.rice.krad.document.FinancialDocument,
88       *      org.kuali.rice.krad.bo.AccountingLine)
89       */
90      public boolean isDebit(GeneralLedgerPendingEntrySourceDetail postable) {
91          DebitDeterminerService isDebitUtils = SpringContext.getBean(DebitDeterminerService.class);
92          return isDebitUtils.isDebitConsideringSectionAndTypePositiveOnly(this, (AccountingLine) postable);
93      }
94      
95      /**
96       * @see org.kuali.ole.fp.document.CapitalAssetEditable#getCapitalAssetInformation()
97       */
98      public List<CapitalAssetInformation> getCapitalAssetInformation() {
99          return ObjectUtils.isNull(capitalAssetInformation) ? null : capitalAssetInformation;
100     }
101 
102     /**
103      * @see org.kuali.ole.fp.document.CapitalAssetEditable#setCapitalAssetInformation(org.kuali.ole.fp.businessobject.CapitalAssetInformation)
104      */
105     public void setCapitalAssetInformation(List<CapitalAssetInformation> capitalAssetInformation) {
106         this.capitalAssetInformation = capitalAssetInformation;
107     }
108     
109     /**
110      * Gets the nextCapitalAssetLineNumber attribute.
111      * 
112      * @return Returns the nextCapitalAssetLineNumber
113      */
114     
115     public Integer getNextCapitalAssetLineNumber() {
116         return nextCapitalAssetLineNumber;
117     }
118 
119     /** 
120      * Sets the nextCapitalAssetLineNumber attribute.
121      * 
122      * @param nextCapitalAssetLineNumber The nextCapitalAssetLineNumber to set.
123      */
124     public void setNextCapitalAssetLineNumber(Integer nextCapitalAssetLineNumber) {
125         this.nextCapitalAssetLineNumber = nextCapitalAssetLineNumber;
126     }
127 }