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