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 /* 017 * Created on Oct 12, 2005 018 * 019 */ 020 package org.kuali.kfs.gl.batch.service.impl; 021 022 import java.util.Date; 023 024 import org.apache.ojb.broker.metadata.MetadataManager; 025 import org.kuali.kfs.gl.GeneralLedgerConstants; 026 import org.kuali.kfs.gl.batch.service.AccountingCycleCachingService; 027 import org.kuali.kfs.gl.batch.service.PostTransaction; 028 import org.kuali.kfs.gl.batch.service.PosterService; 029 import org.kuali.kfs.gl.businessobject.AccountBalance; 030 import org.kuali.kfs.gl.businessobject.Entry; 031 import org.kuali.kfs.gl.businessobject.Transaction; 032 import org.kuali.kfs.gl.dataaccess.EntryDao; 033 import org.kuali.kfs.sys.service.ReportWriterService; 034 import org.kuali.rice.kns.service.PersistenceStructureService; 035 import org.springframework.transaction.annotation.Transactional; 036 037 /** 038 * An implementation of PostTransaction that posts the actual entry 039 */ 040 @Transactional 041 public class PostEntry implements PostTransaction { 042 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PostEntry.class); 043 044 private AccountingCycleCachingService accountingCycleCachingService; 045 private PersistenceStructureService persistenceStructureService; 046 047 /** 048 * Constructs an instance of PostEntry 049 */ 050 public PostEntry() { 051 super(); 052 } 053 054 /** 055 * Saves the transaction as a new GL Entry 056 * 057 * @param t the transaction which is being posted 058 * @param mode the mode the poster is currently running in 059 * @param postDate the date this transaction should post to 060 * @param posterReportWriterService the writer service where the poster is writing its report 061 * @return the accomplished post type 062 * @see org.kuali.kfs.gl.batch.service.PostTransaction#post(org.kuali.kfs.gl.businessobject.Transaction, int, java.util.Date) 063 */ 064 public String post(Transaction t, int mode, Date postDate, ReportWriterService posterReportWriterService) { 065 LOG.debug("post() started"); 066 067 Entry e = new Entry(t, postDate); 068 069 if (mode == PosterService.MODE_REVERSAL) { 070 e.setFinancialDocumentReversalDate(null); 071 } 072 073 accountingCycleCachingService.insertEntry(e); 074 075 return GeneralLedgerConstants.INSERT_CODE; 076 } 077 078 /** 079 * @see org.kuali.kfs.gl.batch.service.PostTransaction#getDestinationName() 080 */ 081 public String getDestinationName() { 082 return persistenceStructureService.getTableName(Entry.class); 083 } 084 085 public void setAccountingCycleCachingService(AccountingCycleCachingService accountingCycleCachingService) { 086 this.accountingCycleCachingService = accountingCycleCachingService; 087 } 088 089 public void setPersistenceStructureService(PersistenceStructureService persistenceStructureService) { 090 this.persistenceStructureService = persistenceStructureService; 091 } 092 093 }