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:
017: package org.kuali.module.purap.document;
018:
019: import java.util.ArrayList;
020:
021: import org.kuali.core.rule.event.KualiDocumentEvent;
022: import org.kuali.kfs.context.SpringContext;
023: import org.kuali.module.purap.PurapConstants;
024: import org.kuali.module.purap.service.PurapGeneralLedgerService;
025: import org.kuali.module.purap.service.PurapService;
026: import org.kuali.module.purap.service.PurchaseOrderService;
027:
028: /**
029: * Purchase Order Void Document
030: */
031: public class PurchaseOrderVoidDocument extends PurchaseOrderDocument {
032: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
033: .getLogger(PurchaseOrderVoidDocument.class);
034:
035: /**
036: * Default constructor.
037: */
038: public PurchaseOrderVoidDocument() {
039: super ();
040: }
041:
042: /**
043: * General Ledger pending entries are not created on save for this document. They are created when the document has been finally
044: * processed. Overriding this method so that entries are not created yet.
045: *
046: * @see org.kuali.module.purap.document.PurchaseOrderDocument#prepareForSave(org.kuali.core.rule.event.KualiDocumentEvent)
047: */
048: @Override
049: public void prepareForSave(KualiDocumentEvent event) {
050: LOG
051: .info("prepareForSave(KualiDocumentEvent) do not create gl entries");
052: setSourceAccountingLines(new ArrayList());
053: setGeneralLedgerPendingEntries(new ArrayList());
054: }
055:
056: /**
057: * When Purchase Order Void document has been processed through Workflow, the general ledger entries are created and the PO
058: * status changes to "VOID".
059: *
060: * @see org.kuali.module.purap.document.PurchaseOrderDocument#handleRouteStatusChange()
061: */
062: @Override
063: public void handleRouteStatusChange() {
064: super .handleRouteStatusChange();
065:
066: // DOCUMENT PROCESSED
067: if (getDocumentHeader().getWorkflowDocument()
068: .stateIsProcessed()) {
069: // generate GL entries
070: SpringContext.getBean(PurapGeneralLedgerService.class)
071: .generateEntriesVoidPurchaseOrder(this );
072:
073: // update indicators
074: SpringContext
075: .getBean(PurchaseOrderService.class)
076: .setCurrentAndPendingIndicatorsForApprovedPODocuments(
077: this );
078:
079: // set purap status
080: SpringContext.getBean(PurapService.class).updateStatus(
081: this , PurapConstants.PurchaseOrderStatuses.VOID);
082: SpringContext.getBean(PurchaseOrderService.class)
083: .saveDocumentNoValidation(this );
084: }
085: // DOCUMENT DISAPPROVED
086: else if (getDocumentHeader().getWorkflowDocument()
087: .stateIsDisapproved()) {
088: SpringContext
089: .getBean(PurchaseOrderService.class)
090: .setCurrentAndPendingIndicatorsForDisapprovedChangePODocuments(
091: this );
092: }
093: // DOCUMENT CANCELED
094: else if (getDocumentHeader().getWorkflowDocument()
095: .stateIsCanceled()) {
096: SpringContext
097: .getBean(PurchaseOrderService.class)
098: .setCurrentAndPendingIndicatorsForCancelledChangePODocuments(
099: this);
100: }
101: }
102:
103: }
|