001/*
002 * Copyright 2008 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 */
016package org.kuali.ole.module.purap.businessobject;
017
018import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
019import org.kuali.ole.module.purap.document.RequisitionDocument;
020import org.kuali.ole.sys.businessobject.AccountingLineParserBase;
021import org.kuali.ole.sys.document.AccountingDocument;
022
023import static org.kuali.ole.sys.OLEPropertyConstants.*;
024
025/**
026 * This class is used to parse an PurApItem accounting line.
027 */
028public class PurApAccountingLineParser extends AccountingLineParserBase {
029    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};
030
031    /**
032     * Constructs a AuxiliaryVoucherAccountingLineParser.java.
033     */
034    public PurApAccountingLineParser() {
035        super();
036    }
037
038    /**
039     * @see org.kuali.rice.krad.bo.AccountingLineParserBase#getSourceAccountingLineFormat()
040     */
041    @Override
042    public String[] getSourceAccountingLineFormat() {
043        return removeChartFromFormatIfNeeded(PURAP_FORMAT);
044    }
045
046    /**
047     * @see org.kuali.rice.krad.bo.AccountingLineParser#getSourceAccountingLineClass(org.kuali.rice.krad.document.AccountingDocument)
048     */
049    @Override
050    protected Class getSourceAccountingLineClass(final AccountingDocument accountingDocument) {
051        if (accountingDocument instanceof RequisitionDocument)
052            return RequisitionAccount.class;
053        else if (accountingDocument instanceof PurchaseOrderDocument)
054            return PurchaseOrderAccount.class;
055        else return super.getSourceAccountingLineClass(accountingDocument);
056    }
057
058}