View Javadoc
1   /*
2    * Copyright 2005-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  
17  package org.kuali.ole.fp.document;
18  
19  import java.util.List;
20  
21  import org.kuali.ole.integration.cam.CapitalAssetManagementModuleService;
22  import org.kuali.ole.sys.OLEConstants;
23  import org.kuali.ole.sys.businessobject.ElectronicPaymentClaim;
24  import org.kuali.ole.sys.context.SpringContext;
25  import org.kuali.ole.sys.document.AmountTotaling;
26  import org.kuali.ole.sys.document.Correctable;
27  import org.kuali.ole.sys.document.ElectronicPaymentClaiming;
28  import org.kuali.ole.sys.service.ElectronicPaymentClaimingService;
29  import org.kuali.rice.kew.framework.postprocessor.DocumentRouteStatusChange;
30  import org.kuali.rice.kns.service.DataDictionaryService;
31  import org.kuali.rice.krad.document.Copyable;
32  import org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent;
33  import org.kuali.rice.krad.rules.rule.event.SaveDocumentEvent;
34  
35  /**
36   * The Distribution of Income and Expense (DI) document is used to distribute income or expense, or assets and liabilities. Amounts
37   * being distributed are usually the result of an accumulation of transactions that need to be divided up between various accounts.
38   */
39  public class DistributionOfIncomeAndExpenseDocument extends CapitalAccountingLinesDocumentBase implements Copyable, Correctable, AmountTotaling, ElectronicPaymentClaiming {
40      protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DistributionOfIncomeAndExpenseDocument.class);
41  
42      protected List<ElectronicPaymentClaim> electronicPaymentClaims;
43      protected transient CapitalAssetManagementModuleService capitalAssetManagementModuleService;
44  
45      /**
46       * Constructs a DistributionOfIncomeAndExpenseDocument.java.
47       */
48      public DistributionOfIncomeAndExpenseDocument() {
49          super();
50      }
51  
52      /**
53       * @see org.kuali.ole.sys.document.AccountingDocument#getSourceAccountingLinesSectionTitle()
54       */
55      @Override
56      public String getSourceAccountingLinesSectionTitle() {
57          return OLEConstants.FROM;
58      }
59  
60      /**
61       * @see org.kuali.ole.sys.document.AccountingDocument#getTargetAccountingLinesSectionTitle()
62       */
63      @Override
64      public String getTargetAccountingLinesSectionTitle() {
65          return OLEConstants.TO;
66      }
67  
68  
69      /**
70       * @see org.kuali.ole.sys.document.ElectronicPaymentClaiming#declaimElectronicPaymentClaims()
71       */
72      public void declaimElectronicPaymentClaims() {
73          SpringContext.getBean(ElectronicPaymentClaimingService.class).declaimElectronicPaymentClaimsForDocument(this);
74      }
75  
76      /**
77       * Gets the electronicPaymentClaims attribute.
78       * 
79       * @return Returns the electronicPaymentClaims.
80       */
81      public List<ElectronicPaymentClaim> getElectronicPaymentClaims() {
82          return electronicPaymentClaims;
83      }
84  
85      /**
86       * Sets the electronicPaymentClaims attribute value.
87       * 
88       * @param electronicPaymentClaims The electronicPaymentClaims to set.
89       * @deprecated
90       */
91      public void setElectronicPaymentClaims(List<ElectronicPaymentClaim> electronicPaymentClaims) {
92          this.electronicPaymentClaims = electronicPaymentClaims;
93      }
94  
95      /**
96       * @see org.kuali.ole.sys.document.GeneralLedgerPostingDocumentBase#doRouteStatusChange()
97       */
98      @Override
99      public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
100         super.doRouteStatusChange(statusChangeEvent);
101         this.getCapitalAssetManagementModuleService().deleteDocumentAssetLocks(this);
102     }
103 
104     /**
105      * @see org.kuali.rice.krad.document.DocumentBase#postProcessSave(org.kuali.rice.krad.rule.event.KualiDocumentEvent)
106      */
107     @Override
108     public void postProcessSave(KualiDocumentEvent event) {
109         super.postProcessSave(event);
110         if (!(event instanceof SaveDocumentEvent)) { // don't lock until they route
111             String documentTypeName = SpringContext.getBean(DataDictionaryService.class).getDocumentTypeNameByClass(this.getClass());
112             this.getCapitalAssetManagementModuleService().generateCapitalAssetLock(this, documentTypeName);
113         }
114     }
115 
116     /**
117      * @return CapitalAssetManagementModuleService
118      */
119     CapitalAssetManagementModuleService getCapitalAssetManagementModuleService() {
120         if (capitalAssetManagementModuleService == null) {
121             capitalAssetManagementModuleService = SpringContext.getBean(CapitalAssetManagementModuleService.class);
122         }
123         return capitalAssetManagementModuleService;
124     }
125 }