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.purap.businessobject;
017    
018    import static org.kuali.kfs.sys.KFSPropertyConstants.ACCOUNT_NUMBER;
019    import static org.kuali.kfs.sys.KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE;
020    import static org.kuali.kfs.sys.KFSPropertyConstants.FINANCIAL_OBJECT_CODE;
021    import static org.kuali.kfs.sys.KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE;
022    import static org.kuali.kfs.sys.KFSPropertyConstants.ORGANIZATION_REFERENCE_ID;
023    import static org.kuali.kfs.sys.KFSPropertyConstants.PERCENT;
024    import static org.kuali.kfs.sys.KFSPropertyConstants.PROJECT_CODE;
025    import static org.kuali.kfs.sys.KFSPropertyConstants.SUB_ACCOUNT_NUMBER;
026    
027    import org.kuali.kfs.module.purap.document.PurchaseOrderDocument;
028    import org.kuali.kfs.module.purap.document.RequisitionDocument;
029    import org.kuali.kfs.sys.businessobject.AccountingLineParserBase;
030    import org.kuali.kfs.sys.document.AccountingDocument;
031    
032    /**
033     * This class is used to parse an PurApItem accounting line.
034     */
035    public class PurApAccountingLineParser extends AccountingLineParserBase {
036        protected static final String[] PURAP_FORMAT = { CHART_OF_ACCOUNTS_CODE, ACCOUNT_NUMBER, SUB_ACCOUNT_NUMBER, FINANCIAL_OBJECT_CODE, FINANCIAL_SUB_OBJECT_CODE, PROJECT_CODE, ORGANIZATION_REFERENCE_ID, PERCENT };
037    
038        /**
039         * Constructs a AuxiliaryVoucherAccountingLineParser.java.
040         */
041        public PurApAccountingLineParser() {
042            super();
043        }
044    
045        /**
046         * @see org.kuali.rice.kns.bo.AccountingLineParserBase#getSourceAccountingLineFormat()
047         */
048        @Override
049        public String[] getSourceAccountingLineFormat() {
050            return removeChartFromFormatIfNeeded(PURAP_FORMAT);
051        }
052        
053        /**
054         * @see org.kuali.rice.kns.bo.AccountingLineParser#getSourceAccountingLineClass(org.kuali.rice.kns.document.AccountingDocument)
055         */
056        @Override
057        protected Class getSourceAccountingLineClass(final AccountingDocument accountingDocument) {
058            if (accountingDocument instanceof RequisitionDocument)
059                return RequisitionAccount.class;
060            else if (accountingDocument instanceof PurchaseOrderDocument)
061                return PurchaseOrderAccount.class;
062            else return super.getSourceAccountingLineClass(accountingDocument);
063        }
064    
065    }