0001: /*
0002: * Copyright 2006-2007 The Kuali Foundation.
0003: *
0004: * Licensed under the Educational Community License, Version 1.0 (the "License");
0005: * you may not use this file except in compliance with the License.
0006: * You may obtain a copy of the License at
0007: *
0008: * http://www.opensource.org/licenses/ecl1.php
0009: *
0010: * Unless required by applicable law or agreed to in writing, software
0011: * distributed under the License is distributed on an "AS IS" BASIS,
0012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013: * See the License for the specific language governing permissions and
0014: * limitations under the License.
0015: */
0016:
0017: package org.kuali.module.purap.document;
0018:
0019: import static org.kuali.core.util.KualiDecimal.ZERO;
0020:
0021: import java.math.BigDecimal;
0022: import java.sql.Date;
0023: import java.util.ArrayList;
0024: import java.util.Collections;
0025: import java.util.Iterator;
0026: import java.util.List;
0027:
0028: import org.apache.commons.lang.StringUtils;
0029: import org.kuali.core.bo.PersistableBusinessObject;
0030: import org.kuali.core.document.Document;
0031: import org.kuali.core.rule.event.KualiDocumentEvent;
0032: import org.kuali.core.service.DataDictionaryService;
0033: import org.kuali.core.service.DateTimeService;
0034: import org.kuali.core.service.SequenceAccessorService;
0035: import org.kuali.core.util.KualiDecimal;
0036: import org.kuali.core.util.ObjectUtils;
0037: import org.kuali.core.util.TypedArrayList;
0038: import org.kuali.core.workflow.service.KualiWorkflowDocument;
0039: import org.kuali.core.workflow.service.KualiWorkflowInfo;
0040: import org.kuali.core.workflow.service.WorkflowDocumentService;
0041: import org.kuali.kfs.context.SpringContext;
0042: import org.kuali.kfs.service.ConciseXmlDocumentConversionService;
0043: import org.kuali.module.purap.PurapConstants;
0044: import org.kuali.module.purap.PurapWorkflowConstants;
0045: import org.kuali.module.purap.PurapConstants.CreditMemoStatuses;
0046: import org.kuali.module.purap.PurapConstants.PurchaseOrderStatuses;
0047: import org.kuali.module.purap.PurapConstants.RequisitionSources;
0048: import org.kuali.module.purap.PurapConstants.VendorChoice;
0049: import org.kuali.module.purap.PurapWorkflowConstants.NodeDetails;
0050: import org.kuali.module.purap.PurapWorkflowConstants.PurchaseOrderDocument.NodeDetailEnum;
0051: import org.kuali.module.purap.bo.CreditMemoView;
0052: import org.kuali.module.purap.bo.ItemType;
0053: import org.kuali.module.purap.bo.PaymentRequestView;
0054: import org.kuali.module.purap.bo.PurApItem;
0055: import org.kuali.module.purap.bo.PurchaseOrderAccount;
0056: import org.kuali.module.purap.bo.PurchaseOrderItem;
0057: import org.kuali.module.purap.bo.PurchaseOrderVendorChoice;
0058: import org.kuali.module.purap.bo.PurchaseOrderVendorQuote;
0059: import org.kuali.module.purap.bo.PurchaseOrderVendorStipulation;
0060: import org.kuali.module.purap.bo.RecurringPaymentFrequency;
0061: import org.kuali.module.purap.bo.RequisitionItem;
0062: import org.kuali.module.purap.service.PurapAccountingService;
0063: import org.kuali.module.purap.service.PurapService;
0064: import org.kuali.module.purap.service.PurchaseOrderService;
0065: import org.kuali.module.purap.service.RequisitionService;
0066: import org.kuali.module.vendor.VendorConstants;
0067: import org.kuali.module.vendor.bo.ContractManager;
0068: import org.kuali.module.vendor.bo.PaymentTermType;
0069: import org.kuali.module.vendor.bo.ShippingPaymentTerms;
0070: import org.kuali.module.vendor.bo.ShippingTitle;
0071: import org.kuali.module.vendor.bo.VendorDetail;
0072:
0073: import edu.iu.uis.eden.EdenConstants;
0074: import edu.iu.uis.eden.clientapp.vo.ActionTakenEventVO;
0075: import edu.iu.uis.eden.clientapp.vo.DocumentRouteLevelChangeVO;
0076: import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
0077: import edu.iu.uis.eden.clientapp.vo.ReportCriteriaVO;
0078: import edu.iu.uis.eden.exception.WorkflowException;
0079:
0080: /**
0081: * Purchase Order Document
0082: */
0083: public class PurchaseOrderDocument extends PurchasingDocumentBase {
0084: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
0085: .getLogger(PurchaseOrderDocument.class);
0086:
0087: private Date purchaseOrderCreateDate;
0088: private Integer requisitionIdentifier;
0089: private String purchaseOrderVendorChoiceCode;
0090: private String recurringPaymentFrequencyCode;
0091: private KualiDecimal recurringPaymentAmount;
0092: private Date recurringPaymentDate;
0093: private KualiDecimal initialPaymentAmount;
0094: private Date initialPaymentDate;
0095: private KualiDecimal finalPaymentAmount;
0096: private Date finalPaymentDate;
0097: private Date purchaseOrderInitialOpenDate;
0098: private Date purchaseOrderLastTransmitDate;
0099: private Date purchaseOrderQuoteDueDate;
0100: private String purchaseOrderQuoteTypeCode;
0101: private String purchaseOrderQuoteVendorNoteText;
0102: private boolean purchaseOrderConfirmedIndicator;
0103: private String purchaseOrderCommodityDescription;
0104: private Integer purchaseOrderPreviousIdentifier;
0105: private Integer alternateVendorHeaderGeneratedIdentifier;
0106: private Integer alternateVendorDetailAssignedIdentifier;
0107: private Integer newQuoteVendorHeaderGeneratedIdentifier;
0108: private Integer newQuoteVendorDetailAssignedIdentifier;
0109: private String alternateVendorName;
0110: private boolean purchaseOrderCurrentIndicator = false;
0111: private boolean pendingActionIndicator = false;
0112: private Date purchaseOrderFirstTransmissionDate;
0113: private Integer contractManagerCode;
0114:
0115: // COLLECTIONS
0116: private List<PurchaseOrderVendorStipulation> purchaseOrderVendorStipulations;
0117: private List<PurchaseOrderVendorQuote> purchaseOrderVendorQuotes;
0118:
0119: // NOT PERSISTED IN DB
0120: private String statusChange;
0121: private String alternateVendorNumber;
0122: private String purchaseOrderRetransmissionMethodCode;
0123: private String retransmitHeader;
0124: private Integer purchaseOrderQuoteListIdentifier;
0125: private KualiDecimal internalPurchasingLimit;
0126:
0127: // REFERENCE OBJECTS
0128: private PurchaseOrderVendorChoice purchaseOrderVendorChoice;
0129: private PaymentTermType vendorPaymentTerms;
0130: private ShippingTitle vendorShippingTitle;
0131: private ShippingPaymentTerms vendorShippingPaymentTerms;
0132: private RecurringPaymentFrequency recurringPaymentFrequency;
0133: private ContractManager contractManager;
0134:
0135: /**
0136: * Default constructor.
0137: */
0138: public PurchaseOrderDocument() {
0139: super ();
0140: this .purchaseOrderVendorStipulations = new TypedArrayList(
0141: PurchaseOrderVendorStipulation.class);
0142: this .purchaseOrderVendorQuotes = new TypedArrayList(
0143: PurchaseOrderVendorQuote.class);
0144: }
0145:
0146: /**
0147: * @see org.kuali.core.document.Document#getDocumentRepresentationForSerialization()
0148: */
0149: @Override
0150: protected Document getDocumentRepresentationForSerialization() {
0151: return SpringContext.getBean(
0152: ConciseXmlDocumentConversionService.class)
0153: .getDocumentForSerialization(this );
0154: }
0155:
0156: public ContractManager getContractManager() {
0157: return contractManager;
0158: }
0159:
0160: public void setContractManager(ContractManager contractManager) {
0161: this .contractManager = contractManager;
0162: }
0163:
0164: public Integer getContractManagerCode() {
0165: return contractManagerCode;
0166: }
0167:
0168: public void setContractManagerCode(Integer contractManagerCode) {
0169: this .contractManagerCode = contractManagerCode;
0170: }
0171:
0172: /**
0173: * @see org.kuali.module.purap.document.PurchasingAccountsPayableDocumentBase#getOverrideWorkflowButtons()
0174: */
0175: @Override
0176: public Boolean getOverrideWorkflowButtons() {
0177: if (ObjectUtils.isNull(super .getOverrideWorkflowButtons())) {
0178: // should only be null on the first call... never after
0179: setOverrideWorkflowButtons(Boolean.TRUE);
0180: }
0181: return super .getOverrideWorkflowButtons();
0182: }
0183:
0184: /**
0185: * @see org.kuali.core.bo.PersistableBusinessObjectBase#isBoNotesSupport()
0186: */
0187: @Override
0188: public boolean isBoNotesSupport() {
0189: return true;
0190: }
0191:
0192: /**
0193: * @see org.kuali.module.purap.document.PurchasingAccountsPayableDocumentBase#customPrepareForSave()
0194: */
0195: @Override
0196: public void customPrepareForSave(KualiDocumentEvent event) {
0197: super .customPrepareForSave(event);
0198: if (ObjectUtils.isNull(getPurapDocumentIdentifier())) {
0199: // need retrieve the next available PO id to save in GL entries (only do if purap id is null which should be on first
0200: // save)
0201: Long poSequenceNumber = SpringContext.getBean(
0202: SequenceAccessorService.class)
0203: .getNextAvailableSequenceNumber("PO_ID");
0204: setPurapDocumentIdentifier(new Integer(poSequenceNumber
0205: .intValue()));
0206: }
0207:
0208: // Set outstanding encumbered quantity/amount on items
0209: for (Iterator items = this .getItems().iterator(); items
0210: .hasNext();) {
0211: PurchaseOrderItem item = (PurchaseOrderItem) items.next();
0212:
0213: // Set quantities
0214: item.setItemOutstandingEncumberedQuantity(item
0215: .getItemQuantity());
0216: item.setItemReceivedTotalQuantity(ZERO);
0217: item.setItemReturnedTotalQuantity(ZERO);
0218: item.setItemInvoicedTotalQuantity(ZERO);
0219: item.setItemInvoicedTotalAmount(ZERO);
0220:
0221: // Set amount
0222: item.setItemOutstandingEncumberedAmount(item
0223: .getExtendedPrice() == null ? ZERO : item
0224: .getExtendedPrice());
0225:
0226: List accounts = (List) item.getSourceAccountingLines();
0227: Collections.sort(accounts);
0228:
0229: for (Iterator iterator = accounts.iterator(); iterator
0230: .hasNext();) {
0231: PurchaseOrderAccount account = (PurchaseOrderAccount) iterator
0232: .next();
0233: if (!account.isEmpty()) {
0234: account
0235: .setItemAccountOutstandingEncumbranceAmount(account
0236: .getAmount());
0237: }
0238: }// endfor accounts
0239: }// endfor items
0240:
0241: this .setSourceAccountingLines(SpringContext.getBean(
0242: PurapAccountingService.class)
0243: .generateSummaryWithNoZeroTotals(this .getItems()));
0244: }// end customPrepareForSave(KualiDocumentEvent)
0245:
0246: /**
0247: * @see org.kuali.module.purap.document.PurchasingAccountsPayableDocumentBase#prepareForSave()
0248: */
0249: @Override
0250: public void prepareForSave(KualiDocumentEvent event) {
0251: if (PurapConstants.PurchaseOrderDocTypes.PURCHASE_ORDER_DOCUMENT
0252: .equals(getDocumentHeader().getWorkflowDocument()
0253: .getDocumentType())) {
0254: if (!getDocumentHeader().getWorkflowDocument()
0255: .stateIsProcessed()
0256: && !getDocumentHeader().getWorkflowDocument()
0257: .stateIsFinal()) {
0258: super .prepareForSave(event);
0259: } else {
0260: // if doc is PROCESSED or FINAL, saving should not be creating GL entries
0261: setGeneralLedgerPendingEntries(new ArrayList());
0262: }
0263: }
0264: }
0265:
0266: /**
0267: * Sets default values for APO.
0268: */
0269: public void setDefaultValuesForAPO() {
0270: this .setPurchaseOrderAutomaticIndicator(Boolean.TRUE);
0271: if (!RequisitionSources.B2B.equals(this
0272: .getRequisitionSourceCode())) {
0273: this
0274: .setPurchaseOrderVendorChoiceCode(VendorChoice.SMALL_ORDER);
0275: }
0276: }
0277:
0278: /**
0279: * Populates this Purchase Order from the related Requisition Document.
0280: *
0281: * @param requisitionDocument the Requisition Document from which field values are copied.
0282: */
0283: public void populatePurchaseOrderFromRequisition(
0284: RequisitionDocument requisitionDocument) {
0285: this .setPurchaseOrderCreateDate(SpringContext.getBean(
0286: DateTimeService.class).getCurrentSqlDate());
0287: this .getDocumentHeader().setOrganizationDocumentNumber(
0288: requisitionDocument.getDocumentHeader()
0289: .getOrganizationDocumentNumber());
0290: this .getDocumentHeader().setFinancialDocumentDescription(
0291: requisitionDocument.getDocumentHeader()
0292: .getFinancialDocumentDescription());
0293:
0294: this .setPurchaseOrderBeginDate(requisitionDocument
0295: .getPurchaseOrderBeginDate());
0296: this .setBillingCityName(requisitionDocument
0297: .getBillingCityName());
0298: this .setBillingCountryCode(requisitionDocument
0299: .getBillingCountryCode());
0300: this .setBillingLine1Address(requisitionDocument
0301: .getBillingLine1Address());
0302: this .setBillingLine2Address(requisitionDocument
0303: .getBillingLine2Address());
0304: this .setBillingName(requisitionDocument.getBillingName());
0305: this .setBillingPhoneNumber(requisitionDocument
0306: .getBillingPhoneNumber());
0307: this .setBillingPostalCode(requisitionDocument
0308: .getBillingPostalCode());
0309: this .setBillingStateCode(requisitionDocument
0310: .getBillingStateCode());
0311: this .setPurchaseOrderCostSourceCode(requisitionDocument
0312: .getPurchaseOrderCostSourceCode());
0313: this .setDeliveryBuildingCode(requisitionDocument
0314: .getDeliveryBuildingCode());
0315: this .setDeliveryBuildingRoomNumber(requisitionDocument
0316: .getDeliveryBuildingRoomNumber());
0317: this .setDeliveryBuildingName(requisitionDocument
0318: .getDeliveryBuildingName());
0319: this .setDeliveryCampusCode(requisitionDocument
0320: .getDeliveryCampusCode());
0321: this .setDeliveryCityName(requisitionDocument
0322: .getDeliveryCityName());
0323: this .setDeliveryCountryCode(requisitionDocument
0324: .getDeliveryCountryCode());
0325: this .setDeliveryInstructionText(requisitionDocument
0326: .getDeliveryInstructionText());
0327: this .setDeliveryBuildingLine1Address(requisitionDocument
0328: .getDeliveryBuildingLine1Address());
0329: this .setDeliveryBuildingLine2Address(requisitionDocument
0330: .getDeliveryBuildingLine2Address());
0331: this .setDeliveryPostalCode(requisitionDocument
0332: .getDeliveryPostalCode());
0333: this .setDeliveryRequiredDate(requisitionDocument
0334: .getDeliveryRequiredDate());
0335: this .setDeliveryRequiredDateReasonCode(requisitionDocument
0336: .getDeliveryRequiredDateReasonCode());
0337: this .setDeliveryStateCode(requisitionDocument
0338: .getDeliveryStateCode());
0339: this .setDeliveryToEmailAddress(requisitionDocument
0340: .getDeliveryToEmailAddress());
0341: this .setDeliveryToName(requisitionDocument.getDeliveryToName());
0342: this .setDeliveryToPhoneNumber(requisitionDocument
0343: .getDeliveryToPhoneNumber());
0344: this .setPostingYear(requisitionDocument.getPostingYear());
0345: this .setPurchaseOrderEndDate(requisitionDocument
0346: .getPurchaseOrderEndDate());
0347: this .setChartOfAccountsCode(requisitionDocument
0348: .getChartOfAccountsCode());
0349: this .setFundingSourceCode(requisitionDocument
0350: .getFundingSourceCode());
0351: this .setInstitutionContactEmailAddress(requisitionDocument
0352: .getInstitutionContactEmailAddress());
0353: this .setInstitutionContactName(requisitionDocument
0354: .getInstitutionContactName());
0355: this .setInstitutionContactPhoneNumber(requisitionDocument
0356: .getInstitutionContactPhoneNumber());
0357: this .setNonInstitutionFundAccountNumber(requisitionDocument
0358: .getNonInstitutionFundAccountNumber());
0359: this
0360: .setNonInstitutionFundChartOfAccountsCode(requisitionDocument
0361: .getNonInstitutionFundChartOfAccountsCode());
0362: this
0363: .setNonInstitutionFundOrgChartOfAccountsCode(requisitionDocument
0364: .getNonInstitutionFundOrgChartOfAccountsCode());
0365: this .setNonInstitutionFundOrganizationCode(requisitionDocument
0366: .getNonInstitutionFundOrganizationCode());
0367: this .setOrganizationCode(requisitionDocument
0368: .getOrganizationCode());
0369: this .setRecurringPaymentTypeCode(requisitionDocument
0370: .getRecurringPaymentTypeCode());
0371: this .setRequestorPersonEmailAddress(requisitionDocument
0372: .getRequestorPersonEmailAddress());
0373: this .setRequestorPersonName(requisitionDocument
0374: .getRequestorPersonName());
0375: this .setRequestorPersonPhoneNumber(requisitionDocument
0376: .getRequestorPersonPhoneNumber());
0377: this .setRequisitionIdentifier(requisitionDocument
0378: .getPurapDocumentIdentifier());
0379: this .setPurchaseOrderTotalLimit(requisitionDocument
0380: .getPurchaseOrderTotalLimit());
0381: this .setPurchaseOrderTransmissionMethodCode(requisitionDocument
0382: .getPurchaseOrderTransmissionMethodCode());
0383: this .setVendorCityName(requisitionDocument.getVendorCityName());
0384: this .setVendorContract(requisitionDocument.getVendorContract());
0385: this .setVendorCountryCode(requisitionDocument
0386: .getVendorCountryCode());
0387: this .setVendorCustomerNumber(requisitionDocument
0388: .getVendorCustomerNumber());
0389: this .setVendorDetailAssignedIdentifier(requisitionDocument
0390: .getVendorDetailAssignedIdentifier());
0391: this .setVendorFaxNumber(requisitionDocument
0392: .getVendorFaxNumber());
0393: this .setVendorHeaderGeneratedIdentifier(requisitionDocument
0394: .getVendorHeaderGeneratedIdentifier());
0395: this .setVendorLine1Address(requisitionDocument
0396: .getVendorLine1Address());
0397: this .setVendorLine2Address(requisitionDocument
0398: .getVendorLine2Address());
0399: this .setVendorName(requisitionDocument.getVendorName());
0400: this .setVendorNoteText(requisitionDocument.getVendorNoteText());
0401: this .setVendorPhoneNumber(requisitionDocument
0402: .getVendorPhoneNumber());
0403: this .setVendorPostalCode(requisitionDocument
0404: .getVendorPostalCode());
0405: this .setVendorRestrictedIndicator(requisitionDocument
0406: .getVendorRestrictedIndicator());
0407: this .setVendorStateCode(requisitionDocument
0408: .getVendorStateCode());
0409: this
0410: .setExternalOrganizationB2bSupplierIdentifier(requisitionDocument
0411: .getExternalOrganizationB2bSupplierIdentifier());
0412: this .setRequisitionSourceCode(requisitionDocument
0413: .getRequisitionSourceCode());
0414: this
0415: .setAccountsPayablePurchasingDocumentLinkIdentifier(requisitionDocument
0416: .getAccountsPayablePurchasingDocumentLinkIdentifier());
0417:
0418: this
0419: .setStatusCode(PurapConstants.PurchaseOrderStatuses.IN_PROCESS);
0420:
0421: // copy items from req to pending (which will copy the item's accounts and assets)
0422: List<PurchaseOrderItem> items = new ArrayList();
0423: for (PurApItem reqItem : ((PurchasingAccountsPayableDocument) requisitionDocument)
0424: .getItems()) {
0425: items.add(new PurchaseOrderItem((RequisitionItem) reqItem,
0426: this ));
0427: }
0428: this .setItems(items);
0429: }
0430:
0431: /**
0432: * Returns the Vendor Stipulation at the specified index in this Purchase Order.
0433: *
0434: * @param index the specified index.
0435: * @return the Vendor Stipulation at the specified index.
0436: */
0437: public PurchaseOrderVendorStipulation getPurchaseOrderVendorStipulation(
0438: int index) {
0439: while (getPurchaseOrderVendorStipulations().size() <= index) {
0440: getPurchaseOrderVendorStipulations().add(
0441: new PurchaseOrderVendorStipulation());
0442: }
0443: return (PurchaseOrderVendorStipulation) purchaseOrderVendorStipulations
0444: .get(index);
0445: }
0446:
0447: /**
0448: * @see org.kuali.kfs.document.GeneralLedgerPostingDocumentBase#handleRouteStatusChange()
0449: */
0450: @Override
0451: public void handleRouteStatusChange() {
0452: LOG.debug("handleRouteStatusChange() started");
0453: super .handleRouteStatusChange();
0454:
0455: // child classes need to call super, but we don't want to inherit the post-processing done by this PO class
0456: if (PurchaseOrderDocument.class.getName().equals(
0457: this .getClass().getName())) {
0458: try {
0459: // DOCUMENT PROCESSED
0460: if (getDocumentHeader().getWorkflowDocument()
0461: .stateIsProcessed()) {
0462: SpringContext.getBean(PurchaseOrderService.class)
0463: .completePurchaseOrder(this );
0464: }
0465: // DOCUMENT DISAPPROVED
0466: else if (getDocumentHeader().getWorkflowDocument()
0467: .stateIsDisapproved()) {
0468: String nodeName = SpringContext.getBean(
0469: WorkflowDocumentService.class)
0470: .getCurrentRouteLevelName(
0471: getDocumentHeader()
0472: .getWorkflowDocument());
0473: NodeDetails currentNode = NodeDetailEnum
0474: .getNodeDetailEnumByName(nodeName);
0475: if (ObjectUtils.isNotNull(currentNode)) {
0476: if (StringUtils.isNotBlank(currentNode
0477: .getDisapprovedStatusCode())) {
0478: SpringContext
0479: .getBean(PurapService.class)
0480: .updateStatus(
0481: this ,
0482: currentNode
0483: .getDisapprovedStatusCode());
0484: SpringContext.getBean(
0485: PurchaseOrderService.class)
0486: .saveDocumentNoValidation(this );
0487: RequisitionDocument req = getPurApSourceDocumentIfPossible();
0488: appSpecificRouteDocumentToUser(
0489: getDocumentHeader()
0490: .getWorkflowDocument(),
0491: req.getDocumentHeader()
0492: .getWorkflowDocument()
0493: .getRoutedByUserNetworkId(),
0494: "Notification of Order Disapproval for Requisition "
0495: + req
0496: .getPurapDocumentIdentifier()
0497: + "(document id "
0498: + req.getDocumentNumber()
0499: + ")",
0500: "Requisition Routed By User");
0501: return;
0502: }
0503: }
0504: logAndThrowRuntimeException("No status found to set for document being disapproved in node '"
0505: + nodeName + "'");
0506: }
0507: // DOCUMENT CANCELED
0508: else if (getDocumentHeader().getWorkflowDocument()
0509: .stateIsCanceled()) {
0510: SpringContext.getBean(PurapService.class)
0511: .updateStatus(this ,
0512: PurchaseOrderStatuses.CANCELLED);
0513: SpringContext.getBean(PurchaseOrderService.class)
0514: .saveDocumentNoValidation(this );
0515: }
0516: } catch (WorkflowException e) {
0517: logAndThrowRuntimeException(
0518: "Error saving routing data while saving document with id "
0519: + getDocumentNumber(), e);
0520: }
0521: }
0522: }
0523:
0524: /**
0525: * Returns the name of the current route node.
0526: *
0527: * @param wd the current workflow document.
0528: * @return the name of the current route node.
0529: * @throws WorkflowException
0530: */
0531: private String getCurrentRouteNodeName(KualiWorkflowDocument wd)
0532: throws WorkflowException {
0533: String[] nodeNames = wd.getNodeNames();
0534: if ((nodeNames == null) || (nodeNames.length == 0)) {
0535: return null;
0536: } else {
0537: return nodeNames[0];
0538: }
0539: }
0540:
0541: /**
0542: * Sends FYI workflow request to the given user on this document.
0543: *
0544: * @param workflowDocument the associated workflow document.
0545: * @param userNetworkId the network ID of the user to be sent to.
0546: * @param annotation the annotation notes contained in this document.
0547: * @param responsibility the responsibility specified in the request.
0548: * @throws WorkflowException
0549: */
0550: private void appSpecificRouteDocumentToUser(
0551: KualiWorkflowDocument workflowDocument,
0552: String userNetworkId, String annotation,
0553: String responsibility) throws WorkflowException {
0554: if (ObjectUtils.isNotNull(workflowDocument)) {
0555: String annotationNote = (ObjectUtils.isNull(annotation)) ? ""
0556: : annotation;
0557: String responsibilityNote = (ObjectUtils
0558: .isNull(responsibility)) ? "" : responsibility;
0559: String currentNodeName = getCurrentRouteNodeName(workflowDocument);
0560: workflowDocument.appSpecificRouteDocumentToUser(
0561: EdenConstants.ACTION_REQUEST_FYI_REQ,
0562: currentNodeName, 0, annotationNote,
0563: new NetworkIdVO(userNetworkId), responsibilityNote,
0564: true);
0565: }
0566: }
0567:
0568: /**
0569: * @see org.kuali.core.document.DocumentBase#handleRouteLevelChange(edu.iu.uis.eden.clientapp.vo.DocumentRouteLevelChangeVO)
0570: */
0571: @Override
0572: public void handleRouteLevelChange(
0573: DocumentRouteLevelChangeVO levelChangeEvent) {
0574: LOG.debug("handleRouteLevelChange() started");
0575: super .handleRouteLevelChange(levelChangeEvent);
0576:
0577: LOG.debug("handleRouteLevelChange() started");
0578: String newNodeName = levelChangeEvent.getNewNodeName();
0579: if (StringUtils.isNotBlank(newNodeName)) {
0580: ReportCriteriaVO reportCriteriaVO = new ReportCriteriaVO(
0581: Long.valueOf(getDocumentNumber()));
0582: reportCriteriaVO.setTargetNodeName(newNodeName);
0583: try {
0584: NodeDetails newNodeDetails = NodeDetailEnum
0585: .getNodeDetailEnumByName(newNodeName);
0586: if (ObjectUtils.isNotNull(newNodeDetails)) {
0587: if (PurapWorkflowConstants.PurchaseOrderDocument.NodeDetailEnum.DOCUMENT_TRANSMISSION
0588: .equals(newNodeDetails)) {
0589: // in the document transmission node... we do special processing to set the status and update the PO
0590: boolean willHaveRequest = SpringContext
0591: .getBean(KualiWorkflowInfo.class)
0592: .documentWillHaveAtLeastOneActionRequest(
0593: reportCriteriaVO, null);
0594: PurchaseOrderService poService = SpringContext
0595: .getBean(PurchaseOrderService.class);
0596: poService
0597: .setupDocumentForPendingFirstTransmission(
0598: this , willHaveRequest);
0599: poService.saveDocumentNoValidation(this );
0600: } else {
0601: String newStatusCode = newNodeDetails
0602: .getAwaitingStatusCode();
0603: if (StringUtils.isNotBlank(newStatusCode)) {
0604: if (SpringContext
0605: .getBean(KualiWorkflowInfo.class)
0606: .documentWillHaveAtLeastOneActionRequest(
0607: reportCriteriaVO,
0608: new String[] {
0609: EdenConstants.ACTION_REQUEST_APPROVE_REQ,
0610: EdenConstants.ACTION_REQUEST_COMPLETE_REQ })) {
0611: // if an approve or complete request will be created then we need to set the status as awaiting for
0612: // the new node
0613: SpringContext.getBean(
0614: PurapService.class)
0615: .updateStatus(this ,
0616: newStatusCode);
0617: SpringContext.getBean(
0618: PurchaseOrderService.class)
0619: .saveDocumentNoValidation(this );
0620: }
0621: }
0622: }
0623: }
0624: } catch (WorkflowException e) {
0625: String errorMsg = "Workflow Error found checking actions requests on document with id "
0626: + getDocumentNumber()
0627: + ". *** WILL NOT UPDATE PURAP STATUS ***";
0628: LOG.warn(errorMsg, e);
0629: }
0630: }
0631: }
0632:
0633: /**
0634: * @see org.kuali.core.document.DocumentBase#doActionTaken(edu.iu.uis.eden.clientapp.vo.ActionTakenEventVO)
0635: */
0636: @Override
0637: public void doActionTaken(ActionTakenEventVO event) {
0638: super .doActionTaken(event);
0639: // additional processing
0640: }
0641:
0642: /**
0643: * Gets the active items in this Purchase Order.
0644: *
0645: * @return the list of all active items in this Purchase Order.
0646: */
0647: public List getItemsActiveOnly() {
0648: List returnList = new ArrayList();
0649: for (Iterator iter = getItems().iterator(); iter.hasNext();) {
0650: PurchaseOrderItem item = (PurchaseOrderItem) iter.next();
0651: if (item.isItemActiveIndicator()) {
0652: returnList.add(item);
0653: }
0654: }
0655: return returnList;
0656: }
0657:
0658: /**
0659: * Gets the active items in this Purchase Order, and sets up the alternate amount for GL entry creation.
0660: *
0661: * @return the list of all active items in this Purchase Order.
0662: */
0663: public List getItemsActiveOnlySetupAlternateAmount() {
0664: List returnList = new ArrayList();
0665: for (Iterator iter = getItems().iterator(); iter.hasNext();) {
0666: PurchaseOrderItem item = (PurchaseOrderItem) iter.next();
0667: if (item.isItemActiveIndicator()) {
0668: for (Iterator iterator = item
0669: .getSourceAccountingLines().iterator(); iterator
0670: .hasNext();) {
0671: PurchaseOrderAccount account = (PurchaseOrderAccount) iterator
0672: .next();
0673: account
0674: .setAlternateAmountForGLEntryCreation(account
0675: .getItemAccountOutstandingEncumbranceAmount());
0676: }
0677: returnList.add(item);
0678: }
0679: }
0680: return returnList;
0681: }
0682:
0683: public Integer getAlternateVendorDetailAssignedIdentifier() {
0684: return alternateVendorDetailAssignedIdentifier;
0685: }
0686:
0687: public void setAlternateVendorDetailAssignedIdentifier(
0688: Integer alternateVendorDetailAssignedIdentifier) {
0689: this .alternateVendorDetailAssignedIdentifier = alternateVendorDetailAssignedIdentifier;
0690: }
0691:
0692: public Integer getAlternateVendorHeaderGeneratedIdentifier() {
0693: return alternateVendorHeaderGeneratedIdentifier;
0694: }
0695:
0696: public void setAlternateVendorHeaderGeneratedIdentifier(
0697: Integer alternateVendorHeaderGeneratedIdentifier) {
0698: this .alternateVendorHeaderGeneratedIdentifier = alternateVendorHeaderGeneratedIdentifier;
0699: }
0700:
0701: public String getAlternateVendorName() {
0702: return alternateVendorName;
0703: }
0704:
0705: public void setAlternateVendorName(String alternateVendorName) {
0706: this .alternateVendorName = alternateVendorName;
0707: }
0708:
0709: public KualiDecimal getFinalPaymentAmount() {
0710: return finalPaymentAmount;
0711: }
0712:
0713: public void setFinalPaymentAmount(KualiDecimal finalPaymentAmount) {
0714: this .finalPaymentAmount = finalPaymentAmount;
0715: }
0716:
0717: public Date getFinalPaymentDate() {
0718: return finalPaymentDate;
0719: }
0720:
0721: public void setFinalPaymentDate(Date finalPaymentDate) {
0722: this .finalPaymentDate = finalPaymentDate;
0723: }
0724:
0725: public KualiDecimal getInitialPaymentAmount() {
0726: return initialPaymentAmount;
0727: }
0728:
0729: public void setInitialPaymentAmount(
0730: KualiDecimal initialPaymentAmount) {
0731: this .initialPaymentAmount = initialPaymentAmount;
0732: }
0733:
0734: public Date getInitialPaymentDate() {
0735: return initialPaymentDate;
0736: }
0737:
0738: public void setInitialPaymentDate(Date initialPaymentDate) {
0739: this .initialPaymentDate = initialPaymentDate;
0740: }
0741:
0742: public String getPurchaseOrderCommodityDescription() {
0743: return purchaseOrderCommodityDescription;
0744: }
0745:
0746: public void setPurchaseOrderCommodityDescription(
0747: String purchaseOrderCommodityDescription) {
0748: this .purchaseOrderCommodityDescription = purchaseOrderCommodityDescription;
0749: }
0750:
0751: public boolean isPurchaseOrderConfirmedIndicator() {
0752: return purchaseOrderConfirmedIndicator;
0753: }
0754:
0755: public void setPurchaseOrderConfirmedIndicator(
0756: boolean purchaseOrderConfirmedIndicator) {
0757: this .purchaseOrderConfirmedIndicator = purchaseOrderConfirmedIndicator;
0758: }
0759:
0760: public Date getPurchaseOrderCreateDate() {
0761: return purchaseOrderCreateDate;
0762: }
0763:
0764: public void setPurchaseOrderCreateDate(Date purchaseOrderCreateDate) {
0765: this .purchaseOrderCreateDate = purchaseOrderCreateDate;
0766: }
0767:
0768: public Date getPurchaseOrderInitialOpenDate() {
0769: return purchaseOrderInitialOpenDate;
0770: }
0771:
0772: public void setPurchaseOrderInitialOpenDate(
0773: Date purchaseOrderInitialOpenDate) {
0774: this .purchaseOrderInitialOpenDate = purchaseOrderInitialOpenDate;
0775: }
0776:
0777: public Date getPurchaseOrderLastTransmitDate() {
0778: return purchaseOrderLastTransmitDate;
0779: }
0780:
0781: public void setPurchaseOrderLastTransmitDate(
0782: Date purchaseOrderLastTransmitDate) {
0783: this .purchaseOrderLastTransmitDate = purchaseOrderLastTransmitDate;
0784: }
0785:
0786: public Integer getPurchaseOrderPreviousIdentifier() {
0787: return purchaseOrderPreviousIdentifier;
0788: }
0789:
0790: public void setPurchaseOrderPreviousIdentifier(
0791: Integer purchaseOrderPreviousIdentifier) {
0792: this .purchaseOrderPreviousIdentifier = purchaseOrderPreviousIdentifier;
0793: }
0794:
0795: public Date getPurchaseOrderQuoteDueDate() {
0796: return purchaseOrderQuoteDueDate;
0797: }
0798:
0799: public void setPurchaseOrderQuoteDueDate(
0800: Date purchaseOrderQuoteDueDate) {
0801: this .purchaseOrderQuoteDueDate = purchaseOrderQuoteDueDate;
0802: }
0803:
0804: public String getPurchaseOrderQuoteTypeCode() {
0805: return purchaseOrderQuoteTypeCode;
0806: }
0807:
0808: public void setPurchaseOrderQuoteTypeCode(
0809: String purchaseOrderQuoteTypeCode) {
0810: this .purchaseOrderQuoteTypeCode = purchaseOrderQuoteTypeCode;
0811: }
0812:
0813: public String getPurchaseOrderQuoteVendorNoteText() {
0814: return purchaseOrderQuoteVendorNoteText;
0815: }
0816:
0817: public void setPurchaseOrderQuoteVendorNoteText(
0818: String purchaseOrderQuoteVendorNoteText) {
0819: this .purchaseOrderQuoteVendorNoteText = purchaseOrderQuoteVendorNoteText;
0820: }
0821:
0822: public String getPurchaseOrderVendorChoiceCode() {
0823: return purchaseOrderVendorChoiceCode;
0824: }
0825:
0826: public void setPurchaseOrderVendorChoiceCode(
0827: String purchaseOrderVendorChoiceCode) {
0828: this .purchaseOrderVendorChoiceCode = purchaseOrderVendorChoiceCode;
0829: }
0830:
0831: public KualiDecimal getRecurringPaymentAmount() {
0832: return recurringPaymentAmount;
0833: }
0834:
0835: public void setRecurringPaymentAmount(
0836: KualiDecimal recurringPaymentAmount) {
0837: this .recurringPaymentAmount = recurringPaymentAmount;
0838: }
0839:
0840: public Date getRecurringPaymentDate() {
0841: return recurringPaymentDate;
0842: }
0843:
0844: public void setRecurringPaymentDate(Date recurringPaymentDate) {
0845: this .recurringPaymentDate = recurringPaymentDate;
0846: }
0847:
0848: public String getRecurringPaymentFrequencyCode() {
0849: return recurringPaymentFrequencyCode;
0850: }
0851:
0852: public void setRecurringPaymentFrequencyCode(
0853: String recurringPaymentFrequencyCode) {
0854: this .recurringPaymentFrequencyCode = recurringPaymentFrequencyCode;
0855: }
0856:
0857: public Integer getRequisitionIdentifier() {
0858: return requisitionIdentifier;
0859: }
0860:
0861: public void setRequisitionIdentifier(Integer requisitionIdentifier) {
0862: this .requisitionIdentifier = requisitionIdentifier;
0863: }
0864:
0865: public PurchaseOrderVendorChoice getPurchaseOrderVendorChoice() {
0866: return purchaseOrderVendorChoice;
0867: }
0868:
0869: public void setPurchaseOrderVendorChoice(
0870: PurchaseOrderVendorChoice purchaseOrderVendorChoice) {
0871: this .purchaseOrderVendorChoice = purchaseOrderVendorChoice;
0872: }
0873:
0874: public RecurringPaymentFrequency getRecurringPaymentFrequency() {
0875: return recurringPaymentFrequency;
0876: }
0877:
0878: public void setRecurringPaymentFrequency(
0879: RecurringPaymentFrequency recurringPaymentFrequency) {
0880: this .recurringPaymentFrequency = recurringPaymentFrequency;
0881: }
0882:
0883: public PaymentTermType getVendorPaymentTerms() {
0884: return vendorPaymentTerms;
0885: }
0886:
0887: public void setVendorPaymentTerms(PaymentTermType vendorPaymentTerms) {
0888: this .vendorPaymentTerms = vendorPaymentTerms;
0889: }
0890:
0891: public ShippingPaymentTerms getVendorShippingPaymentTerms() {
0892: return vendorShippingPaymentTerms;
0893: }
0894:
0895: public void setVendorShippingPaymentTerms(
0896: ShippingPaymentTerms vendorShippingPaymentTerms) {
0897: this .vendorShippingPaymentTerms = vendorShippingPaymentTerms;
0898: }
0899:
0900: public ShippingTitle getVendorShippingTitle() {
0901: return vendorShippingTitle;
0902: }
0903:
0904: public void setVendorShippingTitle(ShippingTitle vendorShippingTitle) {
0905: this .vendorShippingTitle = vendorShippingTitle;
0906: }
0907:
0908: public List getPurchaseOrderVendorStipulations() {
0909: return purchaseOrderVendorStipulations;
0910: }
0911:
0912: public String getStatusChange() {
0913: return statusChange;
0914: }
0915:
0916: public void setPurchaseOrderVendorStipulations(
0917: List purchaseOrderVendorStipulations) {
0918: this .purchaseOrderVendorStipulations = purchaseOrderVendorStipulations;
0919: }
0920:
0921: public List<PurchaseOrderVendorQuote> getPurchaseOrderVendorQuotes() {
0922: return purchaseOrderVendorQuotes;
0923: }
0924:
0925: public void setPurchaseOrderVendorQuotes(
0926: List<PurchaseOrderVendorQuote> purchaseOrderVendorQuotes) {
0927: this .purchaseOrderVendorQuotes = purchaseOrderVendorQuotes;
0928: }
0929:
0930: public PurchaseOrderVendorQuote getPurchaseOrderVendorQuote(
0931: int index) {
0932: while (getPurchaseOrderVendorQuotes().size() <= index) {
0933: getPurchaseOrderVendorQuotes().add(
0934: new PurchaseOrderVendorQuote());
0935: }
0936: return (PurchaseOrderVendorQuote) purchaseOrderVendorQuotes
0937: .get(index);
0938: }
0939:
0940: public void setStatusChange(String statusChange) {
0941: this .statusChange = statusChange;
0942: }
0943:
0944: public String getPurchaseOrderRetransmissionMethodCode() {
0945: return purchaseOrderRetransmissionMethodCode;
0946: }
0947:
0948: public void setPurchaseOrderRetransmissionMethodCode(
0949: String purchaseOrderRetransmissionMethodCode) {
0950: this .purchaseOrderRetransmissionMethodCode = purchaseOrderRetransmissionMethodCode;
0951: }
0952:
0953: public String getRetransmitHeader() {
0954: return retransmitHeader;
0955: }
0956:
0957: public void setRetransmitHeader(String retransmitHeader) {
0958: this .retransmitHeader = retransmitHeader;
0959: }
0960:
0961: public boolean isPendingActionIndicator() {
0962: return pendingActionIndicator;
0963: }
0964:
0965: public void setPendingActionIndicator(boolean pendingActionIndicator) {
0966: this .pendingActionIndicator = pendingActionIndicator;
0967: }
0968:
0969: public boolean isPurchaseOrderCurrentIndicator() {
0970: return purchaseOrderCurrentIndicator;
0971: }
0972:
0973: public void setPurchaseOrderCurrentIndicator(
0974: boolean purchaseOrderCurrentIndicator) {
0975: this .purchaseOrderCurrentIndicator = purchaseOrderCurrentIndicator;
0976: }
0977:
0978: public Date getPurchaseOrderFirstTransmissionDate() {
0979: return purchaseOrderFirstTransmissionDate;
0980: }
0981:
0982: public void setPurchaseOrderFirstTransmissionDate(
0983: Date purchaseOrderFirstTransmissionDate) {
0984: this .purchaseOrderFirstTransmissionDate = purchaseOrderFirstTransmissionDate;
0985: }
0986:
0987: /**
0988: * Gets the alternateVendorNumber attribute.
0989: *
0990: * @return Returns the alternateVendorNumber.
0991: */
0992: public String getAlternateVendorNumber() {
0993: String hdrGenId = "";
0994: String detAssgndId = "";
0995: String vendorNumber = "";
0996: if (this .alternateVendorHeaderGeneratedIdentifier != null) {
0997: hdrGenId = this .alternateVendorHeaderGeneratedIdentifier
0998: .toString();
0999: }
1000: if (this .alternateVendorDetailAssignedIdentifier != null) {
1001: detAssgndId = this .alternateVendorDetailAssignedIdentifier
1002: .toString();
1003: }
1004: if (!StringUtils.isEmpty(hdrGenId)
1005: && !StringUtils.isEmpty(detAssgndId)) {
1006: vendorNumber = hdrGenId + "-" + detAssgndId;
1007: }
1008: return vendorNumber;
1009: }
1010:
1011: /**
1012: * Sets the alternateVendorNumber attribute value.
1013: *
1014: * @param alternateVendorNumber The vendorNumber to set.
1015: */
1016: public void setAlternateVendorNumber(String vendorNumber) {
1017: if (!StringUtils.isEmpty(vendorNumber)) {
1018: int dashInd = vendorNumber.indexOf("-");
1019: if (vendorNumber.length() >= dashInd) {
1020: String vndrHdrGenId = vendorNumber
1021: .substring(0, dashInd);
1022: String vndrDetailAssgnedId = vendorNumber
1023: .substring(dashInd + 1);
1024: if (!StringUtils.isEmpty(vndrHdrGenId)
1025: && !StringUtils.isEmpty(vndrDetailAssgnedId)) {
1026: this .alternateVendorHeaderGeneratedIdentifier = new Integer(
1027: vndrHdrGenId);
1028: this .alternateVendorDetailAssignedIdentifier = new Integer(
1029: vndrDetailAssgnedId);
1030: }
1031: }
1032: } else {
1033: this .alternateVendorNumber = vendorNumber;
1034: }
1035: }
1036:
1037: /**
1038: * Sets alternate vendor fields based on a given VendorDetail.
1039: *
1040: * @param vendorDetail the vendor detail used to set vendor fields.
1041: */
1042: public void templateAlternateVendor(VendorDetail vendorDetail) {
1043: if (vendorDetail == null) {
1044: return;
1045: }
1046: this .setAlternateVendorNumber(vendorDetail
1047: .getVendorHeaderGeneratedIdentifier()
1048: + VendorConstants.DASH
1049: + vendorDetail.getVendorDetailAssignedIdentifier());
1050: this .setAlternateVendorName(vendorDetail.getVendorName());
1051: }
1052:
1053: /**
1054: * Overriding this from the super class so that Note will use only the oldest PurchaseOrderDocument as the
1055: * documentBusinessObject.
1056: *
1057: * @see org.kuali.core.document.Document#getDocumentBusinessObject()
1058: */
1059: @Override
1060: public PersistableBusinessObject getDocumentBusinessObject() {
1061: if (ObjectUtils.isNotNull(getPurapDocumentIdentifier())
1062: && ((ObjectUtils.isNull(documentBusinessObject)) || ObjectUtils
1063: .isNull(((PurchaseOrderDocument) documentBusinessObject)
1064: .getPurapDocumentIdentifier()))) {
1065: refreshDocumentBusinessObject();
1066: } else if (ObjectUtils.isNull(getPurapDocumentIdentifier())
1067: && ObjectUtils.isNull(documentBusinessObject)) {
1068: // needed to keep populate happy
1069: documentBusinessObject = new PurchaseOrderDocument();
1070: }
1071: return documentBusinessObject;
1072: }
1073:
1074: public void refreshDocumentBusinessObject() {
1075: documentBusinessObject = SpringContext.getBean(
1076: PurchaseOrderService.class).getOldestPurchaseOrder(
1077: this ,
1078: (PurchaseOrderDocument) this .documentBusinessObject);
1079: }
1080:
1081: public void setDocumentBusinessObject(PurchaseOrderDocument po) {
1082: documentBusinessObject = po;
1083: }
1084:
1085: /**
1086: * @see org.kuali.module.purap.document.PurchasingAccountsPayableDocumentBase#getItemClass()
1087: */
1088: @Override
1089: public Class getItemClass() {
1090: return PurchaseOrderItem.class;
1091: }
1092:
1093: /**
1094: * @see org.kuali.module.purap.document.PurchasingAccountsPayableDocumentBase#getPurApSourceDocumentIfPossible()
1095: */
1096: @Override
1097: public RequisitionDocument getPurApSourceDocumentIfPossible() {
1098: RequisitionDocument sourceDoc = null;
1099: if (ObjectUtils.isNotNull(getRequisitionIdentifier())) {
1100: sourceDoc = SpringContext.getBean(RequisitionService.class)
1101: .getRequisitionById(getRequisitionIdentifier());
1102: }
1103: return sourceDoc;
1104: }
1105:
1106: /**
1107: * @see org.kuali.module.purap.document.PurchasingAccountsPayableDocumentBase#getPurApSourceDocumentLabelIfPossible()
1108: */
1109: @Override
1110: public String getPurApSourceDocumentLabelIfPossible() {
1111: return SpringContext.getBean(DataDictionaryService.class)
1112: .getDocumentLabelByClass(RequisitionDocument.class);
1113: }
1114:
1115: public Integer getNewQuoteVendorDetailAssignedIdentifier() {
1116: return newQuoteVendorDetailAssignedIdentifier;
1117: }
1118:
1119: public void setNewQuoteVendorDetailAssignedIdentifier(
1120: Integer newQuoteVendorDetailAssignedIdentifier) {
1121: this .newQuoteVendorDetailAssignedIdentifier = newQuoteVendorDetailAssignedIdentifier;
1122: }
1123:
1124: public Integer getNewQuoteVendorHeaderGeneratedIdentifier() {
1125: return newQuoteVendorHeaderGeneratedIdentifier;
1126: }
1127:
1128: public void setNewQuoteVendorHeaderGeneratedIdentifier(
1129: Integer newQuoteVendorHeaderGeneratedIdentifier) {
1130: this .newQuoteVendorHeaderGeneratedIdentifier = newQuoteVendorHeaderGeneratedIdentifier;
1131: }
1132:
1133: public Integer getPurchaseOrderQuoteListIdentifier() {
1134: return purchaseOrderQuoteListIdentifier;
1135: }
1136:
1137: public void setPurchaseOrderQuoteListIdentifier(
1138: Integer purchaseOrderQuoteListIdentifier) {
1139: this .purchaseOrderQuoteListIdentifier = purchaseOrderQuoteListIdentifier;
1140: }
1141:
1142: /**
1143: * Returns true if a vendor has been awarded for this Purchase Order.
1144: *
1145: * @return true if a vendor has been awarded for this Purchase Order.
1146: */
1147: public boolean isPurchaseOrderAwarded() {
1148: return (getAwardedVendorQuote() != null);
1149: }
1150:
1151: /**
1152: * Returns the quote from the awarded vendor.
1153: *
1154: * @return the quote from the awarded vendor.
1155: */
1156: public PurchaseOrderVendorQuote getAwardedVendorQuote() {
1157: for (PurchaseOrderVendorQuote vendorQuote : purchaseOrderVendorQuotes) {
1158: if (vendorQuote.getPurchaseOrderQuoteAwardDate() != null) {
1159: return vendorQuote;
1160: }
1161: }
1162: return null;
1163: }
1164:
1165: /**
1166: * @see org.kuali.module.purap.document.PurchasingDocumentBase#getTotalDollarAmount()
1167: */
1168: @Override
1169: public KualiDecimal getTotalDollarAmount() {
1170: // return total without inactive and with below the line
1171: return getTotalDollarAmount(false, true);
1172: }
1173:
1174: /**
1175: * @see org.kuali.module.purap.document.PurchasingAccountsPayableDocumentBase#getTotalDollarAmountAboveLineItems()
1176: */
1177: @Override
1178: public KualiDecimal getTotalDollarAmountAboveLineItems() {
1179: return getTotalDollarAmount(false, false);
1180: }
1181:
1182: /**
1183: * Gets the total dollar amount for this Purchase Order.
1184: *
1185: * @param includeInactive indicates whether inactive items shall be included.
1186: * @param includeBelowTheLine indicates whether below the line items shall be included.
1187: * @return the total dollar amount for this Purchase Order.
1188: */
1189: public KualiDecimal getTotalDollarAmount(boolean includeInactive,
1190: boolean includeBelowTheLine) {
1191: KualiDecimal total = new KualiDecimal(BigDecimal.ZERO);
1192: for (PurchaseOrderItem item : (List<PurchaseOrderItem>) getItems()) {
1193: ItemType it = item.getItemType();
1194: if ((includeBelowTheLine || it
1195: .isItemTypeAboveTheLineIndicator())
1196: && (includeInactive || item.isItemActiveIndicator())) {
1197: KualiDecimal extendedPrice = item.getExtendedPrice();
1198: KualiDecimal itemTotal = (extendedPrice != null) ? extendedPrice
1199: : KualiDecimal.ZERO;
1200: total = total.add(itemTotal);
1201: }
1202: }
1203: return total;
1204: }
1205:
1206: /**
1207: * Returns true if this Purchase Order contains unpaid items in the Payment Request or Credie Memo.
1208: *
1209: * @return true if this Purchase Order contains unpaid items in the Payment Request or Credie Memo.
1210: */
1211: public boolean getContainsUnpaidPaymentRequestsOrCreditMemos() {
1212: if (getRelatedPaymentRequestViews() != null) {
1213: for (PaymentRequestView element : getRelatedPaymentRequestViews()) {
1214: // If the PREQ is neither cancelled nor voided, check whether the PREQ has been paid.
1215: // If it has not been paid, then this method will return true.
1216: if (!PurapConstants.PaymentRequestStatuses.CANCELLED_STATUSES
1217: .contains(element.getStatusCode())) {
1218: if (element.getPaymentPaidDate() == null) {
1219: return true;
1220: }
1221: }
1222: }// endfor
1223: }
1224: if (getRelatedCreditMemoViews() != null) {
1225: for (CreditMemoView element : getRelatedCreditMemoViews()) {
1226: // If the CM is cancelled, check whether the CM has been paid.
1227: // If it has not been paid, then this method will return true.
1228: if (!CreditMemoStatuses.CANCELLED_STATUSES
1229: .contains(element.getCreditMemoStatusCode())) {
1230: if (element.getCreditMemoPaidTimestamp() == null) {
1231: return true;
1232: }
1233: }
1234: }// endfor
1235: }
1236: return false;
1237: }
1238:
1239: /**
1240: * Used for routing only.
1241: *
1242: * @deprecated
1243: */
1244: public String getContractManagerName() {
1245: return "";
1246: }
1247:
1248: /**
1249: * Used for routing only.
1250: *
1251: * @deprecated
1252: */
1253: public void setContractManagerName(String contractManagerName) {
1254: }
1255:
1256: /**
1257: * Used for routing only.
1258: *
1259: * @deprecated
1260: */
1261: public String getStatusDescription() {
1262: return "";
1263: }
1264:
1265: /**
1266: * Used for routing only.
1267: *
1268: * @deprecated
1269: */
1270: public void setStatusDescription(String statusDescription) {
1271: }
1272:
1273: public KualiDecimal getInternalPurchasingLimit() {
1274: return internalPurchasingLimit;
1275: }
1276:
1277: public void setInternalPurchasingLimit(
1278: KualiDecimal internalPurchasingLimit) {
1279: this.internalPurchasingLimit = internalPurchasingLimit;
1280: }
1281: }
|