1 /* 2 * The Kuali Financial System, a comprehensive financial management system for higher education. 3 * 4 * Copyright 2005-2014 The Kuali Foundation 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Affero General Public License as 8 * published by the Free Software Foundation, either version 3 of the 9 * License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Affero General Public License for more details. 15 * 16 * You should have received a copy of the GNU Affero General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 package org.kuali.kfs.fp.document; 21 22 import org.kuali.kfs.coa.businessobject.AccountingPeriod; 23 import org.kuali.kfs.fp.document.service.YearEndPendingEntryService; 24 import org.kuali.kfs.sys.businessobject.AccountingLine; 25 import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry; 26 import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySourceDetail; 27 import org.kuali.kfs.sys.context.SpringContext; 28 import org.kuali.kfs.sys.document.AccountingDocument; 29 import org.kuali.kfs.sys.document.AmountTotaling; 30 31 32 /** 33 * Year End version of the <code>TransferOfFundsDocument</code> functionally the only difference is the accounting period code 34 * used on the glpe entries 35 */ 36 public class YearEndTransferOfFundsDocument extends TransferOfFundsDocument implements YearEndDocument, AmountTotaling { 37 38 /** 39 * Constructs a YearEndTransferOfFundsDocument.java. 40 */ 41 public YearEndTransferOfFundsDocument() { 42 super(); 43 } 44 45 /** 46 * This method calls the super class's overridden method to perform the general customization actions, then calls the 47 * YearEndDocumentUtil matching method to perform year end specific customization activities. 48 * 49 * @param accountingDocument The accounting document containing the general ledger pending entries being customized. 50 * @param accountingLine The accounting line the explicit general ledger pending entry was generated from. 51 * @param explicitEntry The explicit general ledger pending entry to be customized. 52 * 53 * @see org.kuali.kfs.fp.document.validation.impl.TransferOfFundsDocumentRule#customizeExplicitGeneralLedgerPendingEntry(org.kuali.kfs.sys.document.AccountingDocument, 54 * org.kuali.kfs.sys.businessobject.AccountingLine, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) 55 * @see YearEndDocumentUtil#customizeExplicitGeneralLedgerPendingEntry(TransactionalDocument, AccountingLine, 56 * GeneralLedgerPendingEntry) 57 */ 58 @Override 59 public void customizeExplicitGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySourceDetail postable, GeneralLedgerPendingEntry explicitEntry) { 60 super.customizeExplicitGeneralLedgerPendingEntry(postable, explicitEntry); 61 AccountingLine accountingLine = (AccountingLine)postable; 62 SpringContext.getBean(YearEndPendingEntryService.class).customizeExplicitGeneralLedgerPendingEntry(this, accountingLine, explicitEntry); 63 } 64 65 /** 66 * Overridden to populate object code from last year's offset definition 67 * @see org.kuali.kfs.sys.document.AccountingDocumentBase#customizeOffsetGeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySourceDetail, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) 68 */ 69 @Override 70 public boolean customizeOffsetGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySourceDetail accountingLine, GeneralLedgerPendingEntry explicitEntry, GeneralLedgerPendingEntry offsetEntry) { 71 boolean success = super.customizeOffsetGeneralLedgerPendingEntry(accountingLine, explicitEntry, offsetEntry); 72 success &= SpringContext.getBean(YearEndPendingEntryService.class).customizeOffsetGeneralLedgerPendingEntry(this, accountingLine, explicitEntry, offsetEntry); 73 return success; 74 } 75 76 @Override 77 public Class<? extends AccountingDocument> getDocumentClassForAccountingLineValueAllowedValidation() { 78 return TransferOfFundsDocument.class; 79 } 80 81 @Override 82 public void setAccountingPeriod(AccountingPeriod accountingPeriod) { 83 //Need to override this method to set the posting year and 84 //posting period code so that we can have period 13 in the document's 85 //table in the database so that it's consistent with the GL Entry's 86 //posting year and posting period. 87 YearEndPendingEntryService yearEndPendingEntryService = SpringContext.getBean(YearEndPendingEntryService.class); 88 setPostingYear(yearEndPendingEntryService.getPreviousFiscalYear()); 89 this.setPostingPeriodCode(yearEndPendingEntryService.getFinalAccountingPeriod()); 90 } 91 92 }