001    /*
002     * Copyright 2011 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    package org.kuali.kfs.module.ld.document;
017    
018    import java.util.HashMap;
019    import java.util.List;
020    import java.util.Map;
021    
022    import org.kuali.kfs.integration.ld.LaborLedgerPendingEntryForSearching;
023    import org.kuali.kfs.module.ld.LaborConstants;
024    import org.kuali.kfs.module.ld.businessobject.ExpenseTransferAccountingLine;
025    import org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry;
026    import org.kuali.kfs.module.ld.util.LaborPendingEntryGenerator;
027    import org.kuali.kfs.sys.businessobject.AccountingLine;
028    import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper;
029    import org.kuali.kfs.sys.context.SpringContext;
030    import org.kuali.rice.kns.service.ParameterService;
031    import org.kuali.rice.kns.util.KualiDecimal;
032    
033    /**
034     * Labor Document Class for the Salary Expense Transfer Document.
035     */
036    public class SalaryExpenseTransferDocument extends LaborExpenseTransferDocumentBase {
037        protected static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(SalaryExpenseTransferDocument.class);
038    
039        protected Map<String, KualiDecimal> approvalObjectCodeBalances;
040    
041        /**
042         * Default Constructor.
043         */
044        public SalaryExpenseTransferDocument() {
045            super();
046            approvalObjectCodeBalances = new HashMap<String, KualiDecimal>();
047        }
048    
049        /**
050         * Gets the approvalObjectCodeBalances attribute.
051         * 
052         * @return Returns the approvalObjectCodeBalances.
053         */
054        public Map<String, KualiDecimal> getApprovalObjectCodeBalances() {
055            return approvalObjectCodeBalances;
056        }
057    
058        /**
059         * Sets the approvalObjectCodeBalances attribute value.
060         * 
061         * @param approvalObjectCodeBalances The approvalObjectCodeBalances to set.
062         */
063        public void setApprovalObjectCodeBalances(Map<String, KualiDecimal> approvalObjectCodeBalances) {
064            this.approvalObjectCodeBalances = approvalObjectCodeBalances;
065        }
066    
067        /**
068         * @see org.kuali.kfs.module.ld.document.LaborExpenseTransferDocumentBase#generateLaborLedgerPendingEntries(org.kuali.kfs.sys.businessobject.AccountingLine,
069         *      org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)
070         */
071        public boolean generateLaborLedgerPendingEntries(AccountingLine accountingLine, GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
072            LOG.info("started generateLaborLedgerPendingEntries()");
073            
074            boolean isSuccessful = true;
075            ExpenseTransferAccountingLine expenseTransferAccountingLine = (ExpenseTransferAccountingLine) accountingLine;
076    
077            List<LaborLedgerPendingEntry> expensePendingEntries = LaborPendingEntryGenerator.generateExpensePendingEntries(this, expenseTransferAccountingLine, sequenceHelper);
078            if (expensePendingEntries != null && !expensePendingEntries.isEmpty()) {
079                isSuccessful &= this.getLaborLedgerPendingEntries().addAll(expensePendingEntries);
080            }
081    
082            List<LaborLedgerPendingEntry> benefitPendingEntries = LaborPendingEntryGenerator.generateBenefitPendingEntries(this, expenseTransferAccountingLine, sequenceHelper);
083            if (benefitPendingEntries != null && !benefitPendingEntries.isEmpty()) {
084                isSuccessful &= this.getLaborLedgerPendingEntries().addAll(benefitPendingEntries);
085            }
086    
087            return isSuccessful;
088        }
089    
090        /**
091         * @see org.kuali.kfs.module.ld.document.LaborExpenseTransferDocumentBase#generateLaborLedgerBenefitClearingPendingEntries(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)
092         */
093        public boolean generateLaborLedgerBenefitClearingPendingEntries(GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
094            LOG.info("started generateLaborLedgerBenefitClearingPendingEntries()");
095    
096            String chartOfAccountsCode = SpringContext.getBean(ParameterService.class).getParameterValue(SalaryExpenseTransferDocument.class, LaborConstants.SalaryExpenseTransfer.BENEFIT_CLEARING_CHART_PARM_NM);
097            String accountNumber = SpringContext.getBean(ParameterService.class).getParameterValue(SalaryExpenseTransferDocument.class, LaborConstants.SalaryExpenseTransfer.BENEFIT_CLEARING_ACCOUNT_PARM_NM);
098    
099            List<LaborLedgerPendingEntry> benefitClearingPendingEntries = LaborPendingEntryGenerator.generateBenefitClearingPendingEntries(this, sequenceHelper, accountNumber, chartOfAccountsCode);
100    
101            if (benefitClearingPendingEntries != null && !benefitClearingPendingEntries.isEmpty()) {
102                return this.getLaborLedgerPendingEntries().addAll(benefitClearingPendingEntries);
103            }
104    
105            return true;
106        }
107        
108        public List getLaborLedgerPendingEntriesForSearching() {
109            return super.getLaborLedgerPendingEntries();
110        }
111       
112    }