001/*
002 * Copyright 2005-2006 The Kuali Foundation
003 * 
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * 
008 * http://www.opensource.org/licenses/ecl2.php
009 * 
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.kuali.ole.fp.document;
018
019import java.util.List;
020
021import org.kuali.ole.integration.cam.CapitalAssetManagementModuleService;
022import org.kuali.ole.sys.OLEConstants;
023import org.kuali.ole.sys.businessobject.ElectronicPaymentClaim;
024import org.kuali.ole.sys.context.SpringContext;
025import org.kuali.ole.sys.document.AmountTotaling;
026import org.kuali.ole.sys.document.Correctable;
027import org.kuali.ole.sys.document.ElectronicPaymentClaiming;
028import org.kuali.ole.sys.service.ElectronicPaymentClaimingService;
029import org.kuali.rice.kew.framework.postprocessor.DocumentRouteStatusChange;
030import org.kuali.rice.kns.service.DataDictionaryService;
031import org.kuali.rice.krad.document.Copyable;
032import org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent;
033import org.kuali.rice.krad.rules.rule.event.SaveDocumentEvent;
034
035/**
036 * The Distribution of Income and Expense (DI) document is used to distribute income or expense, or assets and liabilities. Amounts
037 * being distributed are usually the result of an accumulation of transactions that need to be divided up between various accounts.
038 */
039public class DistributionOfIncomeAndExpenseDocument extends CapitalAccountingLinesDocumentBase implements Copyable, Correctable, AmountTotaling, ElectronicPaymentClaiming {
040    protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DistributionOfIncomeAndExpenseDocument.class);
041
042    protected List<ElectronicPaymentClaim> electronicPaymentClaims;
043    protected transient CapitalAssetManagementModuleService capitalAssetManagementModuleService;
044
045    /**
046     * Constructs a DistributionOfIncomeAndExpenseDocument.java.
047     */
048    public DistributionOfIncomeAndExpenseDocument() {
049        super();
050    }
051
052    /**
053     * @see org.kuali.ole.sys.document.AccountingDocument#getSourceAccountingLinesSectionTitle()
054     */
055    @Override
056    public String getSourceAccountingLinesSectionTitle() {
057        return OLEConstants.FROM;
058    }
059
060    /**
061     * @see org.kuali.ole.sys.document.AccountingDocument#getTargetAccountingLinesSectionTitle()
062     */
063    @Override
064    public String getTargetAccountingLinesSectionTitle() {
065        return OLEConstants.TO;
066    }
067
068
069    /**
070     * @see org.kuali.ole.sys.document.ElectronicPaymentClaiming#declaimElectronicPaymentClaims()
071     */
072    public void declaimElectronicPaymentClaims() {
073        SpringContext.getBean(ElectronicPaymentClaimingService.class).declaimElectronicPaymentClaimsForDocument(this);
074    }
075
076    /**
077     * Gets the electronicPaymentClaims attribute.
078     * 
079     * @return Returns the electronicPaymentClaims.
080     */
081    public List<ElectronicPaymentClaim> getElectronicPaymentClaims() {
082        return electronicPaymentClaims;
083    }
084
085    /**
086     * Sets the electronicPaymentClaims attribute value.
087     * 
088     * @param electronicPaymentClaims The electronicPaymentClaims to set.
089     * @deprecated
090     */
091    public void setElectronicPaymentClaims(List<ElectronicPaymentClaim> electronicPaymentClaims) {
092        this.electronicPaymentClaims = electronicPaymentClaims;
093    }
094
095    /**
096     * @see org.kuali.ole.sys.document.GeneralLedgerPostingDocumentBase#doRouteStatusChange()
097     */
098    @Override
099    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}