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.math.BigDecimal;
020: import java.util.List;
021:
022: import org.kuali.core.rule.event.KualiDocumentEvent;
023: import org.kuali.core.service.DateTimeService;
024: import org.kuali.core.util.KualiDecimal;
025: import org.kuali.kfs.context.SpringContext;
026: import org.kuali.module.purap.PurapConstants;
027: import org.kuali.module.purap.bo.PurchaseOrderItem;
028: import org.kuali.module.purap.service.PurapService;
029: import org.kuali.module.purap.service.PurchaseOrderService;
030:
031: /**
032: * Purchase Order Retransmit Document
033: */
034: public class PurchaseOrderRetransmitDocument extends
035: PurchaseOrderDocument {
036: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
037: .getLogger(PurchaseOrderRetransmitDocument.class);
038:
039: /**
040: * Default constructor.
041: */
042: public PurchaseOrderRetransmitDocument() {
043: super ();
044: }
045:
046: /**
047: * General Ledger pending entries are not created for this document. Overriding this method so that entries are not created.
048: *
049: * @see org.kuali.module.purap.document.PurchaseOrderDocument#customPrepareForSave(org.kuali.core.rule.event.KualiDocumentEvent)
050: */
051: @Override
052: public void customPrepareForSave(KualiDocumentEvent event) {
053: // do not set the accounts in sourceAccountingLines; this document should not create GL entries
054: }
055:
056: /**
057: * Adds up the total amount of the items selected by the user for retransmit, then return the amount.
058: *
059: * @return KualiDecimal the total amount of the items selected by the user for retransmit.
060: */
061: public KualiDecimal getTotalDollarAmountForRetransmit() {
062: // We should only add up the amount of the items that were selected for retransmit.
063: KualiDecimal total = new KualiDecimal(BigDecimal.ZERO);
064: for (PurchaseOrderItem item : (List<PurchaseOrderItem>) getItems()) {
065: if (item.isItemSelectedForRetransmitIndicator()) {
066: KualiDecimal extendedPrice = item.getExtendedPrice();
067: KualiDecimal itemTotal = (extendedPrice != null) ? extendedPrice
068: : KualiDecimal.ZERO;
069: total = total.add(itemTotal);
070: }
071: }
072:
073: return total;
074: }
075:
076: /**
077: * When Purchase Order Retransmit document has been Processed through Workflow, the PO status remains to "OPEN" and the last
078: * transmit date is updated.
079: *
080: * @see org.kuali.module.purap.document.PurchaseOrderDocument#handleRouteStatusChange()
081: */
082: @Override
083: public void handleRouteStatusChange() {
084: super .handleRouteStatusChange();
085:
086: // DOCUMENT PROCESSED
087: if (getDocumentHeader().getWorkflowDocument()
088: .stateIsProcessed()) {
089: SpringContext
090: .getBean(PurchaseOrderService.class)
091: .setCurrentAndPendingIndicatorsForApprovedPODocuments(
092: this );
093: setPurchaseOrderLastTransmitDate(SpringContext.getBean(
094: DateTimeService.class).getCurrentSqlDate());
095: SpringContext.getBean(PurapService.class).updateStatus(
096: this , PurapConstants.PurchaseOrderStatuses.OPEN);
097: SpringContext.getBean(PurchaseOrderService.class)
098: .saveDocumentNoValidation(this );
099: }
100: // DOCUMENT DISAPPROVED
101: else if (getDocumentHeader().getWorkflowDocument()
102: .stateIsDisapproved()) {
103: SpringContext
104: .getBean(PurchaseOrderService.class)
105: .setCurrentAndPendingIndicatorsForDisapprovedChangePODocuments(
106: this );
107: }
108: // DOCUMENT CANCELED
109: else if (getDocumentHeader().getWorkflowDocument()
110: .stateIsCanceled()) {
111: SpringContext
112: .getBean(PurchaseOrderService.class)
113: .setCurrentAndPendingIndicatorsForCancelledChangePODocuments(
114: this);
115: }
116:
117: }
118:
119: }
|