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 Amendment Document
030: */
031: public class PurchaseOrderAmendmentDocument extends
032: PurchaseOrderDocument {
033: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
034: .getLogger(PurchaseOrderAmendmentDocument.class);
035:
036: /**
037: * Default constructor.
038: */
039: public PurchaseOrderAmendmentDocument() {
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 Amendment document has been Processed through Workflow, the general ledger entries are created and the PO
059: * status remains "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: .generateEntriesApproveAmendPurchaseOrder(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:
084: SpringContext.getBean(PurchaseOrderService.class)
085: .saveDocumentNoValidation(this );
086: }
087: // DOCUMENT DISAPPROVED
088: else if (getDocumentHeader().getWorkflowDocument()
089: .stateIsDisapproved()) {
090: SpringContext
091: .getBean(PurchaseOrderService.class)
092: .setCurrentAndPendingIndicatorsForDisapprovedChangePODocuments(
093: this );
094: SpringContext.getBean(PurchaseOrderService.class)
095: .saveDocumentNoValidation(this );
096: }
097: // DOCUMENT CANCELED
098: else if (getDocumentHeader().getWorkflowDocument()
099: .stateIsCanceled()) {
100: SpringContext
101: .getBean(PurchaseOrderService.class)
102: .setCurrentAndPendingIndicatorsForCancelledChangePODocuments(
103: this );
104: SpringContext.getBean(PurchaseOrderService.class)
105: .saveDocumentNoValidation(this);
106: }
107: }
108:
109: }
|