001: /*
002: * Copyright 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.gl.service.impl;
017:
018: import org.kuali.kfs.KFSConstants;
019: import org.kuali.module.chart.bo.OrganizationReversion;
020: import org.kuali.module.chart.bo.OrganizationReversionDetail;
021: import org.kuali.module.chart.service.OrganizationReversionService;
022: import org.kuali.module.chart.service.impl.OrganizationReversionServiceImpl;
023:
024: /**
025: * A mock implementation of OrganizationReversionService, used by the OrganizationReversionLogicTest
026: * @see org.kuali.module.gl.service.impl.orgreversion.OrganizationReversionLogicTest
027: */
028: public class OrganizationReversionMockService extends
029: OrganizationReversionServiceImpl implements
030: OrganizationReversionService {
031: public static final String DEFAULT_BUDGET_REVERSION_CHART = "BL";
032: public static final String DEFAULT_BUDGET_REVERSION_ACCOUNT = "0211301";
033: public static final String DEFAULT_CASH_REVERSION_CHART = "BL";
034: public static final String DEFAULT_CASH_REVERSION_ACCOUNT = "0211401";
035:
036: /**
037: * Always returns the same mock organization reversion record, no matter what keys are handed to it
038: * @param fiscal year the fiscal year of the organization reversion record that will be returned
039: * @param chart the chart of the organization reversion record that will be returned
040: * @param orgCode the organization code of the organization reversion record that will be returned
041: * @return an OrganizationReversion record with the given chart, org, and year, but everything else--budget reversion and cash reversion account information and category details--pre-set
042: * @see org.kuali.module.chart.service.impl.OrganizationReversionServiceImpl#getByPrimaryId(java.lang.Integer, java.lang.String,
043: * java.lang.String)
044: */
045: @Override
046: public OrganizationReversion getByPrimaryId(Integer fiscalYear,
047: String chartCode, String orgCode) {
048: // always return the same OrganizationReversion no matter what
049: OrganizationReversion orgRev = new OrganizationReversion();
050: orgRev.setChartOfAccountsCode(chartCode);
051: orgRev.setUniversityFiscalYear(fiscalYear);
052: orgRev.setOrganizationCode(orgCode);
053: orgRev
054: .setBudgetReversionChartOfAccountsCode(DEFAULT_BUDGET_REVERSION_CHART);
055: orgRev
056: .setBudgetReversionAccountNumber(DEFAULT_BUDGET_REVERSION_ACCOUNT);
057: orgRev
058: .setCashReversionFinancialChartOfAccountsCode(DEFAULT_CASH_REVERSION_CHART);
059: orgRev
060: .setCashReversionAccountNumber(DEFAULT_CASH_REVERSION_ACCOUNT);
061: orgRev.setCarryForwardByObjectCodeIndicator(true);
062:
063: orgRev.addOrganizationReversionDetail(createDetail(fiscalYear,
064: chartCode, orgCode, "C01", KFSConstants.RULE_CODE_A));
065: orgRev.addOrganizationReversionDetail(createDetail(fiscalYear,
066: chartCode, orgCode, "C02", KFSConstants.RULE_CODE_C1));
067: orgRev.addOrganizationReversionDetail(createDetail(fiscalYear,
068: chartCode, orgCode, "C03", KFSConstants.RULE_CODE_C2));
069: orgRev.addOrganizationReversionDetail(createDetail(fiscalYear,
070: chartCode, orgCode, "C04", KFSConstants.RULE_CODE_N1));
071: orgRev.addOrganizationReversionDetail(createDetail(fiscalYear,
072: chartCode, orgCode, "C05", KFSConstants.RULE_CODE_N2));
073: orgRev.addOrganizationReversionDetail(createDetail(fiscalYear,
074: chartCode, orgCode, "C06", KFSConstants.RULE_CODE_A));
075: orgRev.addOrganizationReversionDetail(createDetail(fiscalYear,
076: chartCode, orgCode, "C07", KFSConstants.RULE_CODE_A));
077: orgRev.addOrganizationReversionDetail(createDetail(fiscalYear,
078: chartCode, orgCode, "C08", KFSConstants.RULE_CODE_R1));
079: orgRev.addOrganizationReversionDetail(createDetail(fiscalYear,
080: chartCode, orgCode, "C09", KFSConstants.RULE_CODE_R2));
081: orgRev.addOrganizationReversionDetail(createDetail(fiscalYear,
082: chartCode, orgCode, "C10", KFSConstants.RULE_CODE_A));
083: orgRev.addOrganizationReversionDetail(createDetail(fiscalYear,
084: chartCode, orgCode, "C11", KFSConstants.RULE_CODE_A));
085:
086: return orgRev;
087: }
088:
089: /**
090: * Creates a mock OrganizationReversionDetail record, based on the parameters
091: *
092: * @param fiscalYear the fiscal year to set
093: * @param chartCode the chart to set
094: * @param orgCode the org code to set
095: * @param categoryCode the category code of the record
096: * @param categoryAlgorithm the algorithm to use for the record
097: */
098: private OrganizationReversionDetail createDetail(
099: Integer fiscalYear, String chartCode, String orgCode,
100: String categoryCode, String categoryAlgorithm) {
101: OrganizationReversionDetail detail = new OrganizationReversionDetail();
102: detail.setUniversityFiscalYear(new Integer(fiscalYear
103: .intValue() - 1));
104: detail.setChartOfAccountsCode(chartCode);
105: detail.setOrganizationCode(orgCode);
106: detail.setOrganizationReversionCategoryCode(categoryCode);
107: detail.setOrganizationReversionCode(categoryAlgorithm);
108: detail.setOrganizationReversionObjectCode("5000");
109: return detail;
110: }
111:
112: }
|