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.document.service.impl; 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.module.ar.document.CustomerInvoiceDocument; 024 import org.kuali.kfs.sys.businessobject.ChartOrgHolder; 025 import org.kuali.kfs.sys.context.SpringContext; 026 import org.kuali.kfs.sys.service.FinancialSystemUserService; 027 import org.kuali.kfs.sys.service.UniversityDateService; 028 import org.kuali.rice.kns.service.BusinessObjectService; 029 import org.kuali.rice.kns.util.GlobalVariables; 030 import org.kuali.rice.kns.util.ObjectUtils; 031 032 public class ReceivableAccountingLineServiceImpl implements ReceivableAccountingLineService { 033 034 private UniversityDateService universityDateService; 035 private BusinessObjectService businessObjectService; 036 037 /** 038 * @see org.kuali.kfs.module.ar.document.service.impl.ReceivableAccountingLineService#setReceivableAccountingLineForCustomerInvoiceDocument(org.kuali.kfs.module.ar.document.CustomerInvoiceDocument) 039 */ 040 @SuppressWarnings("unchecked") 041 public void setReceivableAccountingLineForCustomerInvoiceDocument(CustomerInvoiceDocument customerInvoiceDocument) { 042 043 Integer currentUniverisityFiscalYear = universityDateService.getCurrentFiscalYear(); 044 ChartOrgHolder currentUser = SpringContext.getBean(FinancialSystemUserService.class).getPrimaryOrganization(GlobalVariables.getUserSession().getPerson(), ArConstants.AR_NAMESPACE_CODE); 045 046 Map criteria = new HashMap(); 047 criteria.put("universityFiscalYear", currentUniverisityFiscalYear); 048 criteria.put("chartOfAccountsCode", currentUser.getChartOfAccountsCode()); 049 criteria.put("organizationCode", currentUser.getOrganizationCode()); 050 051 OrganizationAccountingDefault organizationAccountingDefault = (OrganizationAccountingDefault)businessObjectService.findByPrimaryKey(OrganizationAccountingDefault.class, criteria); 052 if( ObjectUtils.isNotNull( organizationAccountingDefault) ){ 053 customerInvoiceDocument.setPaymentChartOfAccountsCode(organizationAccountingDefault.getDefaultPaymentChartOfAccountsCode()); 054 customerInvoiceDocument.setPaymentAccountNumber(organizationAccountingDefault.getDefaultPaymentAccountNumber()); 055 customerInvoiceDocument.setPaymentSubAccountNumber(organizationAccountingDefault.getDefaultPaymentSubAccountNumber()); 056 customerInvoiceDocument.setPaymentFinancialObjectCode(organizationAccountingDefault.getDefaultPaymentFinancialObjectCode()); 057 customerInvoiceDocument.setPaymentFinancialSubObjectCode(organizationAccountingDefault.getDefaultPaymentFinancialSubObjectCode()); 058 customerInvoiceDocument.setPaymentProjectCode(organizationAccountingDefault.getDefaultPaymentProjectCode()); 059 customerInvoiceDocument.setPaymentOrganizationReferenceIdentifier(organizationAccountingDefault.getDefaultPaymentOrganizationReferenceIdentifier()); 060 } 061 } 062 063 public UniversityDateService getUniversityDateService() { 064 return universityDateService; 065 } 066 067 public void setUniversityDateService(UniversityDateService universityDateService) { 068 this.universityDateService = universityDateService; 069 } 070 071 public BusinessObjectService getBusinessObjectService() { 072 return businessObjectService; 073 } 074 075 public void setBusinessObjectService(BusinessObjectService businessObjectService) { 076 this.businessObjectService = businessObjectService; 077 } 078 079 } 080