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.ar.businessobject.defaultvalue;
017
018 import java.util.HashMap;
019 import java.util.Map;
020
021 import org.kuali.kfs.module.ar.ArConstants;
022 import org.kuali.kfs.module.ar.businessobject.OrganizationAccountingDefault;
023 import org.kuali.kfs.sys.businessobject.ChartOrgHolder;
024 import org.kuali.kfs.sys.context.SpringContext;
025 import org.kuali.kfs.sys.service.FinancialSystemUserService;
026 import org.kuali.kfs.sys.service.UniversityDateService;
027 import org.kuali.rice.kns.service.BusinessObjectService;
028 import org.kuali.rice.kns.util.GlobalVariables;
029
030 public class OrganizationAccountingDefaultValueFinderBase {
031
032 protected OrganizationAccountingDefault organizationAccountingDefault;
033
034 /**
035 * Constructs a OrganizationAccountingDefaultValueFinderBase. Sets the OrganizationAccountingDefault BO based on current
036 * year, current users chart of account code, and current users organization code
037 */
038 @SuppressWarnings("unchecked")
039 public OrganizationAccountingDefaultValueFinderBase(){
040 Integer currentUniversityFiscalYear = SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear();
041 ChartOrgHolder chartUser = SpringContext.getBean(FinancialSystemUserService.class).getPrimaryOrganization(GlobalVariables.getUserSession().getPerson(), ArConstants.AR_NAMESPACE_CODE);
042
043 Map criteria = new HashMap();
044 criteria.put("universityFiscalYear", currentUniversityFiscalYear);
045 criteria.put("chartOfAccountsCode", chartUser.getChartOfAccountsCode());
046 criteria.put("organizationCode", chartUser.getOrganizationCode());
047 organizationAccountingDefault = (OrganizationAccountingDefault)SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(OrganizationAccountingDefault.class, criteria);
048 }
049 }
050