View Javadoc
1   /*
2    * The Kuali Financial System, a comprehensive financial management system for higher education.
3    * 
4    * Copyright 2005-2014 The Kuali Foundation
5    * 
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Affero General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   * 
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Affero General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Affero General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.kuali.kfs.fp.document;
20  
21  import java.util.ArrayList;
22  import java.util.List;
23  
24  import org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails;
25  import org.kuali.kfs.fp.businessobject.CapitalAssetInformation;
26  import org.kuali.kfs.fp.businessobject.CapitalAssetInformationDetail;
27  import org.kuali.kfs.integration.cab.CapitalAssetBuilderModuleService;
28  import org.kuali.kfs.sys.businessobject.AccountingLine;
29  import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySourceDetail;
30  import org.kuali.kfs.sys.context.SpringContext;
31  import org.kuali.kfs.sys.document.AccountingDocumentBase;
32  import org.kuali.kfs.sys.document.service.DebitDeterminerService;
33  import org.kuali.rice.kew.framework.postprocessor.DocumentRouteStatusChange;
34  import org.kuali.rice.krad.util.ObjectUtils;
35  
36  /**
37   * class which defines behavior common for capital asset information lines.
38   */
39   public class CapitalAssetInformationDocumentBase extends AccountingDocumentBase implements CapitalAssetEditable {
40      protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CapitalAssetInformationDocumentBase.class);
41      protected Integer nextCapitalAssetLineNumber;
42  
43      // capital asset
44      protected List<CapitalAssetInformation> capitalAssetInformation;
45      
46      /**
47       * Constructs a CapitalAssetInformationDocumentBase
48       */
49      public CapitalAssetInformationDocumentBase() {
50          super();
51          
52          this.setCapitalAssetInformation(new ArrayList());
53          this.setNextCapitalAssetLineNumber(1);
54      }
55  
56      /**
57       * @see org.kuali.kfs.sys.document.GeneralLedgerPostingDocumentBase#doRouteStatusChange()
58       */
59      @Override
60      public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
61          super.doRouteStatusChange(statusChangeEvent);
62  
63          String documentNumber = getDocumentHeader().getDocumentNumber();
64          // update gl status as processed when all the capital assets have been processed...
65          SpringContext.getBean(CapitalAssetBuilderModuleService.class).markProcessedGLEntryLine(documentNumber);
66      }
67      
68      /**
69       * @see org.kuali.kfs.sys.document.AccountingDocumentBase#buildListOfDeletionAwareLists()
70       */
71      @Override
72      public List buildListOfDeletionAwareLists() {
73          List<List> managedLists = super.buildListOfDeletionAwareLists();
74          
75          List<CapitalAssetInformation> capitalAssets = new ArrayList<CapitalAssetInformation>();
76          capitalAssets.addAll(this.getCapitalAssetInformation());
77  
78          managedLists.add(capitalAssets); 
79          
80          return managedLists;
81      }
82  
83      /**
84       * Return true if account line is debit
85       * 
86       * @param financialDocument submitted accounting document
87       * @param accountingLine accounting line from accounting document
88       * @return true is account line is debit
89       * @see IsDebitUtils#isDebitConsideringSectionAndTypePositiveOnly(FinancialDocumentRuleBase, FinancialDocument, AccountingLine)
90       * @see org.kuali.rice.krad.rule.AccountingLineRule#isDebit(org.kuali.rice.krad.document.FinancialDocument,
91       *      org.kuali.rice.krad.bo.AccountingLine)
92       */
93      public boolean isDebit(GeneralLedgerPendingEntrySourceDetail postable) {
94          DebitDeterminerService isDebitUtils = SpringContext.getBean(DebitDeterminerService.class);
95          return isDebitUtils.isDebitConsideringSectionAndTypePositiveOnly(this, (AccountingLine) postable);
96      }
97      
98      /**
99       * @see org.kuali.kfs.fp.document.CapitalAssetEditable#getCapitalAssetInformation()
100      */
101     public List<CapitalAssetInformation> getCapitalAssetInformation() {
102         return ObjectUtils.isNull(capitalAssetInformation) ? null : capitalAssetInformation;
103     }
104 
105     /**
106      * @see org.kuali.kfs.fp.document.CapitalAssetEditable#setCapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation)
107      */
108     public void setCapitalAssetInformation(List<CapitalAssetInformation> capitalAssetInformation) {
109         this.capitalAssetInformation = capitalAssetInformation;
110     }
111     
112     /**
113      * Gets the nextCapitalAssetLineNumber attribute.
114      * 
115      * @return Returns the nextCapitalAssetLineNumber
116      */
117     
118     public Integer getNextCapitalAssetLineNumber() {
119         return nextCapitalAssetLineNumber;
120     }
121 
122     /** 
123      * Sets the nextCapitalAssetLineNumber attribute.
124      * 
125      * @param nextCapitalAssetLineNumber The nextCapitalAssetLineNumber to set.
126      */
127     public void setNextCapitalAssetLineNumber(Integer nextCapitalAssetLineNumber) {
128         this.nextCapitalAssetLineNumber = nextCapitalAssetLineNumber;
129     }
130 }