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 package org.kuali.kfs.module.purap.document;
018
019 import java.util.List;
020
021 import org.kuali.kfs.module.purap.PurapConstants;
022 import org.kuali.kfs.module.purap.document.service.PurapService;
023 import org.kuali.kfs.module.purap.document.service.PurchaseOrderService;
024 import org.kuali.kfs.sys.context.SpringContext;
025 import org.kuali.rice.kew.dto.DocumentRouteStatusChangeDTO;
026 import org.kuali.rice.kns.rule.event.KualiDocumentEvent;
027
028 /**
029 * Purchase Order Payment Hold Document
030 */
031 public class PurchaseOrderPaymentHoldDocument extends PurchaseOrderDocument {
032 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PurchaseOrderPaymentHoldDocument.class);
033
034 /**
035 * Default constructor.
036 */
037 public PurchaseOrderPaymentHoldDocument() {
038 super();
039 }
040
041 /**
042 * General Ledger pending entries are not created for this document. Overriding this method so that entries are not created.
043 *
044 * @see org.kuali.kfs.module.purap.document.PurchaseOrderDocument#customPrepareForSave(org.kuali.rice.kns.rule.event.KualiDocumentEvent)
045 */
046 @Override
047 public void customPrepareForSave(KualiDocumentEvent event) {
048 // do not set the accounts in sourceAccountingLines; this document should not create GL entries
049 }
050
051 @Override
052 public List<Long> getWorkflowEngineDocumentIdsToLock() {
053 List<Long> docIds = super.getWorkflowEngineDocumentIdsToLock();
054 return docIds;
055 }
056
057 /**
058 * When Purchase Order Payment Hold document has been Processed through Workflow, the PO status changes to "Payment Hold".
059 *
060 * @see org.kuali.kfs.module.purap.document.PurchaseOrderDocument#doRouteStatusChange()
061 */
062 @Override
063 public void doRouteStatusChange(DocumentRouteStatusChangeDTO statusChangeEvent) {
064 super.doRouteStatusChange(statusChangeEvent);
065
066 // DOCUMENT PROCESSED
067 if (getDocumentHeader().getWorkflowDocument().stateIsProcessed()) {
068 SpringContext.getBean(PurchaseOrderService.class).setCurrentAndPendingIndicatorsForApprovedPODocuments(this);
069
070 // set purap status
071 SpringContext.getBean(PurapService.class).updateStatus(this, PurapConstants.PurchaseOrderStatuses.PAYMENT_HOLD);
072 }
073 // DOCUMENT DISAPPROVED
074 else if (getDocumentHeader().getWorkflowDocument().stateIsDisapproved()) {
075 SpringContext.getBean(PurchaseOrderService.class).setCurrentAndPendingIndicatorsForDisapprovedChangePODocuments(this);
076 }
077 // DOCUMENT CANCELED
078 else if (getDocumentHeader().getWorkflowDocument().stateIsCanceled()) {
079 SpringContext.getBean(PurchaseOrderService.class).setCurrentAndPendingIndicatorsForCancelledChangePODocuments(this);
080 }
081 }
082
083 }