001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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.module.financial.document;
017:
018: import org.kuali.core.document.AmountTotaling;
019: import org.kuali.core.document.Copyable;
020: import org.kuali.core.document.Correctable;
021: import org.kuali.core.exceptions.InfrastructureException;
022: import org.kuali.kfs.KFSConstants;
023: import org.kuali.kfs.bo.AccountingLineParser;
024: import org.kuali.kfs.bo.SourceAccountingLine;
025: import org.kuali.kfs.bo.TargetAccountingLine;
026: import org.kuali.kfs.context.SpringContext;
027: import org.kuali.kfs.document.AccountingDocumentBase;
028: import org.kuali.kfs.service.ParameterService;
029: import org.kuali.module.financial.bo.IndirectCostAdjustmentDocumentAccountingLineParser;
030: import org.kuali.module.financial.rules.IndirectCostAdjustmentDocumentRuleConstants;
031:
032: public class IndirectCostAdjustmentDocument extends
033: AccountingDocumentBase implements Copyable, Correctable,
034: AmountTotaling {
035:
036: /**
037: * Constructs a IndirectCostAdjustmentDocument.java.
038: */
039: public IndirectCostAdjustmentDocument() {
040: super ();
041: }
042:
043: /**
044: * @see org.kuali.kfs.document.AccountingDocument#getSourceAccountingLinesSectionTitle()
045: */
046: @Override
047: public String getSourceAccountingLinesSectionTitle() {
048: return KFSConstants.GRANT;
049: }
050:
051: /**
052: * @see org.kuali.kfs.document.AccountingDocument#getTargetAccountingLinesSectionTitle()
053: */
054: @Override
055: public String getTargetAccountingLinesSectionTitle() {
056: return KFSConstants.ICR;
057: }
058:
059: /**
060: * per ICA specs, adds a target(receipt) line when an source(grant) line is added using the following logic to populate the
061: * target line.
062: * <ol>
063: * <li>receipt line's chart = chart from grant line
064: * <li>receipt line's account = ICR account for the account entered on the grant line
065: * <li>receipt line's object code = Financial System Parameter APC for the document global receipt line object code (see APC
066: * setion below)
067: * <li>receipt line's amount = amount from grant line
068: * </ol>
069: *
070: * @see org.kuali.kfs.document.AccountingDocumentBase#addSourceAccountingLine(SourceAccountingLine)
071: */
072: @Override
073: public void addSourceAccountingLine(SourceAccountingLine line) {
074: // add source
075: super .addSourceAccountingLine(line);
076: // create and populate target line
077: TargetAccountingLine targetAccountingLine = null;
078: try {
079: targetAccountingLine = (TargetAccountingLine) getTargetAccountingLineClass()
080: .newInstance();
081: } catch (Exception e) {
082: throw new InfrastructureException(
083: "unable to create a target accounting line", e);
084: }
085: // get apc object code value
086: String objectCode = SpringContext
087: .getBean(ParameterService.class)
088: .getParameterValue(
089: IndirectCostAdjustmentDocument.class,
090: IndirectCostAdjustmentDocumentRuleConstants.RECEIPT_OBJECT_CODE);
091: targetAccountingLine.setFinancialObjectCode(objectCode);
092: targetAccountingLine.setAccountNumber(line.getAccount()
093: .getIndirectCostRecoveryAcctNbr());
094: targetAccountingLine.setChartOfAccountsCode(line
095: .getChartOfAccountsCode());
096: targetAccountingLine
097: .setDocumentNumber(line.getDocumentNumber());
098: targetAccountingLine.setPostingYear(line.getPostingYear());
099: targetAccountingLine.setAmount(line.getAmount());
100: // refresh reference objects
101:
102: targetAccountingLine.refresh();
103: // add target line
104: addTargetAccountingLine(targetAccountingLine);
105: }
106:
107: /**
108: * @see org.kuali.kfs.document.AccountingDocumentBase#getAccountingLineParser()
109: */
110: @Override
111: public AccountingLineParser getAccountingLineParser() {
112: return new IndirectCostAdjustmentDocumentAccountingLineParser();
113: }
114: }
|