Search in sources :

Example 1 with PurchasingItemBase

use of org.kuali.kfs.module.purap.businessobject.PurchasingItemBase in project cu-kfs by CU-CommunityApps.

the class PurchasingNewIndividualItemValidation method validateContainsAtLeastOneItem.

/**
 * Validates that the document contains at least one item.
 *
 * @param purDocument the purchasing document to be validated
 * @return boolean false if the document does not contain at least one item.
 */
public boolean validateContainsAtLeastOneItem(PurchasingDocument purDocument) {
    boolean valid = false;
    for (PurApItem item : purDocument.getItems()) {
        if (!((PurchasingItemBase) item).isEmpty() && item.getItemType().isLineItemIndicator()) {
            return true;
        }
    }
    String documentType = getDocumentTypeLabel(purDocument.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
    if (!valid) {
        GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, PurapKeyConstants.ERROR_ITEM_REQUIRED, documentType);
    }
    return valid;
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurchasingItemBase(org.kuali.kfs.module.purap.businessobject.PurchasingItemBase)

Example 2 with PurchasingItemBase

use of org.kuali.kfs.module.purap.businessobject.PurchasingItemBase in project cu-kfs by CU-CommunityApps.

the class PurchasingDocumentBase method includeItem.

/*
     * validate if item needs to be included in 'commodity' codes check
     */
private boolean includeItem(PurchasingItemBase item, List<PurchasingItemBase> previousPOItems) {
    boolean isNotChanged = true;
    boolean isNew = true;
    for (PurchasingItemBase prevItem : previousPOItems) {
        if (item.getItemLineNumber().equals(prevItem.getItemLineNumber())) {
            isNew = false;
            isNotChanged &= isItemNotChanged(item, prevItem);
        }
    }
    return isNew || !isNotChanged;
}
Also used : PurchasingItemBase(org.kuali.kfs.module.purap.businessobject.PurchasingItemBase)

Example 3 with PurchasingItemBase

use of org.kuali.kfs.module.purap.businessobject.PurchasingItemBase in project cu-kfs by CU-CommunityApps.

the class PurchasingAddItemValidation method validateItemQuantity.

/**
 * Validates that if the item type is quantity based, the item quantity is required and if the item type is amount
 * based, the quantity is not allowed.
 *
 * @param item the item to be validated
 * @return boolean false if there's any validation that fails.
 */
public boolean validateItemQuantity(PurApItem item) {
    boolean valid = true;
    PurchasingItemBase purItem = (PurchasingItemBase) item;
    if (purItem.getItemType().isQuantityBasedGeneralLedgerIndicator() && ObjectUtils.isNull(purItem.getItemQuantity())) {
        valid = false;
        String attributeLabel = businessObjectDictionaryService.getBusinessObjectEntry(item.getClass().getName()).getAttributeDefinition(PurapPropertyConstants.ITEM_QUANTITY).getLabel();
        GlobalVariables.getMessageMap().putError(PurapPropertyConstants.QUANTITY, KFSKeyConstants.ERROR_REQUIRED, attributeLabel + " in " + item.getItemIdentifierString());
    } else if (purItem.getItemType().isAmountBasedGeneralLedgerIndicator() && ObjectUtils.isNotNull(purItem.getItemQuantity())) {
        valid = false;
        String attributeLabel = businessObjectDictionaryService.getBusinessObjectEntry(item.getClass().getName()).getAttributeDefinition(PurapPropertyConstants.ITEM_QUANTITY).getLabel();
        GlobalVariables.getMessageMap().putError(PurapPropertyConstants.QUANTITY, PurapKeyConstants.ERROR_ITEM_QUANTITY_NOT_ALLOWED, attributeLabel + " in " + item.getItemIdentifierString());
    }
    return valid;
}
Also used : PurchasingItemBase(org.kuali.kfs.module.purap.businessobject.PurchasingItemBase)

Example 4 with PurchasingItemBase

use of org.kuali.kfs.module.purap.businessobject.PurchasingItemBase in project cu-kfs by CU-CommunityApps.

the class PurchaseOrderDocument method populatePurchaseOrderFromRequisition.

/**
 * Populates this Purchase Order from the related Requisition Document.
 *
 * @param requisitionDocument the Requisition Document from which field values are copied.
 */
public void populatePurchaseOrderFromRequisition(RequisitionDocument requisitionDocument) {
    this.setPurchaseOrderCreateTimestamp(SpringContext.getBean(DateTimeService.class).getCurrentTimestamp());
    this.getDocumentHeader().setOrganizationDocumentNumber(requisitionDocument.getDocumentHeader().getOrganizationDocumentNumber());
    this.getDocumentHeader().setDocumentDescription(requisitionDocument.getDocumentHeader().getDocumentDescription());
    this.getDocumentHeader().setExplanation(requisitionDocument.getDocumentHeader().getExplanation());
    this.setBillingName(requisitionDocument.getBillingName());
    this.setBillingLine1Address(requisitionDocument.getBillingLine1Address());
    this.setBillingLine2Address(requisitionDocument.getBillingLine2Address());
    this.setBillingCityName(requisitionDocument.getBillingCityName());
    this.setBillingStateCode(requisitionDocument.getBillingStateCode());
    this.setBillingPostalCode(requisitionDocument.getBillingPostalCode());
    this.setBillingCountryCode(requisitionDocument.getBillingCountryCode());
    this.setBillingPhoneNumber(requisitionDocument.getBillingPhoneNumber());
    this.setBillingEmailAddress(requisitionDocument.getBillingEmailAddress());
    this.setReceivingName(requisitionDocument.getReceivingName());
    this.setReceivingCityName(requisitionDocument.getReceivingCityName());
    this.setReceivingLine1Address(requisitionDocument.getReceivingLine1Address());
    this.setReceivingLine2Address(requisitionDocument.getReceivingLine2Address());
    this.setReceivingStateCode(requisitionDocument.getReceivingStateCode());
    this.setReceivingPostalCode(requisitionDocument.getReceivingPostalCode());
    this.setReceivingCountryCode(requisitionDocument.getReceivingCountryCode());
    this.setAddressToVendorIndicator(requisitionDocument.getAddressToVendorIndicator());
    this.setDeliveryBuildingCode(requisitionDocument.getDeliveryBuildingCode());
    this.setDeliveryBuildingRoomNumber(requisitionDocument.getDeliveryBuildingRoomNumber());
    this.setDeliveryBuildingName(requisitionDocument.getDeliveryBuildingName());
    this.setDeliveryCampusCode(requisitionDocument.getDeliveryCampusCode());
    this.setDeliveryCityName(requisitionDocument.getDeliveryCityName());
    this.setDeliveryCountryCode(requisitionDocument.getDeliveryCountryCode());
    this.setDeliveryInstructionText(requisitionDocument.getDeliveryInstructionText());
    this.setDeliveryBuildingLine1Address(requisitionDocument.getDeliveryBuildingLine1Address());
    this.setDeliveryBuildingLine2Address(requisitionDocument.getDeliveryBuildingLine2Address());
    this.setDeliveryPostalCode(requisitionDocument.getDeliveryPostalCode());
    this.setDeliveryRequiredDate(requisitionDocument.getDeliveryRequiredDate());
    this.setDeliveryRequiredDateReasonCode(requisitionDocument.getDeliveryRequiredDateReasonCode());
    this.setDeliveryStateCode(requisitionDocument.getDeliveryStateCode());
    this.setDeliveryToEmailAddress(requisitionDocument.getDeliveryToEmailAddress());
    this.setDeliveryToName(requisitionDocument.getDeliveryToName());
    this.setDeliveryToPhoneNumber(requisitionDocument.getDeliveryToPhoneNumber());
    this.setDeliveryBuildingOtherIndicator(requisitionDocument.isDeliveryBuildingOtherIndicator());
    this.setPurchaseOrderBeginDate(requisitionDocument.getPurchaseOrderBeginDate());
    this.setPurchaseOrderCostSourceCode(requisitionDocument.getPurchaseOrderCostSourceCode());
    this.setPostingYear(requisitionDocument.getPostingYear());
    this.setPurchaseOrderEndDate(requisitionDocument.getPurchaseOrderEndDate());
    this.setChartOfAccountsCode(requisitionDocument.getChartOfAccountsCode());
    this.setDocumentFundingSourceCode(requisitionDocument.getDocumentFundingSourceCode());
    this.setInstitutionContactEmailAddress(requisitionDocument.getInstitutionContactEmailAddress());
    this.setInstitutionContactName(requisitionDocument.getInstitutionContactName());
    this.setInstitutionContactPhoneNumber(requisitionDocument.getInstitutionContactPhoneNumber());
    this.setNonInstitutionFundAccountNumber(requisitionDocument.getNonInstitutionFundAccountNumber());
    this.setNonInstitutionFundChartOfAccountsCode(requisitionDocument.getNonInstitutionFundChartOfAccountsCode());
    this.setNonInstitutionFundOrgChartOfAccountsCode(requisitionDocument.getNonInstitutionFundOrgChartOfAccountsCode());
    this.setNonInstitutionFundOrganizationCode(requisitionDocument.getNonInstitutionFundOrganizationCode());
    this.setOrganizationCode(requisitionDocument.getOrganizationCode());
    this.setRecurringPaymentTypeCode(requisitionDocument.getRecurringPaymentTypeCode());
    this.setRequestorPersonEmailAddress(requisitionDocument.getRequestorPersonEmailAddress());
    this.setRequestorPersonName(requisitionDocument.getRequestorPersonName());
    this.setRequestorPersonPhoneNumber(requisitionDocument.getRequestorPersonPhoneNumber());
    this.setRequisitionIdentifier(requisitionDocument.getPurapDocumentIdentifier());
    this.setPurchaseOrderTotalLimit(requisitionDocument.getPurchaseOrderTotalLimit());
    this.setPurchaseOrderTransmissionMethodCode(requisitionDocument.getPurchaseOrderTransmissionMethodCode());
    this.setUseTaxIndicator(requisitionDocument.isUseTaxIndicator());
    this.setVendorCityName(requisitionDocument.getVendorCityName());
    this.setVendorContractGeneratedIdentifier(requisitionDocument.getVendorContractGeneratedIdentifier());
    this.setVendorCountryCode(requisitionDocument.getVendorCountryCode());
    this.setVendorCustomerNumber(requisitionDocument.getVendorCustomerNumber());
    this.setVendorAttentionName(requisitionDocument.getVendorAttentionName());
    this.setVendorDetailAssignedIdentifier(requisitionDocument.getVendorDetailAssignedIdentifier());
    this.setVendorFaxNumber(requisitionDocument.getVendorFaxNumber());
    this.setVendorHeaderGeneratedIdentifier(requisitionDocument.getVendorHeaderGeneratedIdentifier());
    this.setVendorLine1Address(requisitionDocument.getVendorLine1Address());
    this.setVendorLine2Address(requisitionDocument.getVendorLine2Address());
    this.setVendorAddressInternationalProvinceName(requisitionDocument.getVendorAddressInternationalProvinceName());
    this.setVendorName(requisitionDocument.getVendorName());
    this.setVendorNoteText(requisitionDocument.getVendorNoteText());
    this.setVendorPhoneNumber(requisitionDocument.getVendorPhoneNumber());
    this.setVendorPostalCode(requisitionDocument.getVendorPostalCode());
    this.setVendorStateCode(requisitionDocument.getVendorStateCode());
    this.setVendorRestrictedIndicator(requisitionDocument.getVendorRestrictedIndicator());
    this.setJustification(requisitionDocument.getJustification());
    // KFSPTS-1458, KFSPTS-16990: Also copy vendorEmailAddress from Requisition to PO
    this.setVendorEmailAddress(requisitionDocument.getVendorEmailAddress());
    this.setExternalOrganizationB2bSupplierIdentifier(requisitionDocument.getExternalOrganizationB2bSupplierIdentifier());
    this.setRequisitionSourceCode(requisitionDocument.getRequisitionSourceCode());
    this.setAccountsPayablePurchasingDocumentLinkIdentifier(requisitionDocument.getAccountsPayablePurchasingDocumentLinkIdentifier());
    this.setReceivingDocumentRequiredIndicator(requisitionDocument.isReceivingDocumentRequiredIndicator());
    this.setPaymentRequestPositiveApprovalIndicator(requisitionDocument.isPaymentRequestPositiveApprovalIndicator());
    setApplicationDocumentStatus(PurchaseOrderStatuses.APPDOC_IN_PROCESS);
    this.setAccountDistributionMethod(requisitionDocument.getAccountDistributionMethod());
    // Copy items from requisition (which will copy the item's accounts and capital assets)
    List<PurchaseOrderItem> items = new ArrayList<>();
    for (PurApItem reqItem : ((PurchasingAccountsPayableDocument) requisitionDocument).getItems()) {
        RequisitionCapitalAssetItem reqCamsItem = (RequisitionCapitalAssetItem) requisitionDocument.getPurchasingCapitalAssetItemByItemIdentifier(reqItem.getItemIdentifier());
        items.add(new PurchaseOrderItem((RequisitionItem) reqItem, this, reqCamsItem));
    }
    this.setItems(items);
    // Copy capital asset information that is directly off the document.
    this.setCapitalAssetSystemTypeCode(requisitionDocument.getCapitalAssetSystemTypeCode());
    this.setCapitalAssetSystemStateCode(requisitionDocument.getCapitalAssetSystemStateCode());
    for (CapitalAssetSystem capitalAssetSystem : requisitionDocument.getPurchasingCapitalAssetSystems()) {
        this.getPurchasingCapitalAssetSystems().add(new PurchaseOrderCapitalAssetSystem(capitalAssetSystem));
    }
    this.fixItemReferences();
    // KFSUPGRADE-346/KITI-727
    if (ObjectUtils.isNull(getPurapDocumentIdentifier())) {
        // need retrieve the next available PO id to save in GL entries (only do if purap id is null which should be on first
        // save)
        SequenceAccessorService sas = SpringContext.getBean(SequenceAccessorService.class);
        Long poSequenceNumber = sas.getNextAvailableSequenceNumber("PO_ID", this.getClass());
        setPurapDocumentIdentifier(poSequenceNumber.intValue());
    }
    // KFSUPGRADE-337/KITI-2414 : checking for duplicate sensitive data types
    Set<String> currentSensitiveDataCodes = new HashSet<String>();
    if (purchaseOrderSensitiveData != null) {
        for (PurchaseOrderSensitiveData sensitiveData : purchaseOrderSensitiveData) {
            currentSensitiveDataCodes.add(sensitiveData.getSensitiveDataCode());
        }
    }
    if (requisitionDocument.isSensitive()) {
        for (PurchasingItemBase pib : (List<PurchasingItemBase>) requisitionDocument.getItems()) {
            CommodityCode cc = pib.getCommodityCode();
            if (cc != null && cc.getSensitiveDataCode() != null && currentSensitiveDataCodes.add(cc.getSensitiveDataCode())) {
                if (purchaseOrderSensitiveData == null) {
                    boolean addNewData = true;
                    purchaseOrderSensitiveData = getPurchaseOrderSensitiveData();
                    for (PurchaseOrderSensitiveData sensitiveData : purchaseOrderSensitiveData) {
                        if (!currentSensitiveDataCodes.add(sensitiveData.getSensitiveDataCode())) {
                            addNewData = false;
                        }
                    }
                    if (addNewData) {
                        purchaseOrderSensitiveData.add(new PurchaseOrderSensitiveData(getPurapDocumentIdentifier(), getRequisitionIdentifier(), cc.getSensitiveDataCode()));
                    }
                } else {
                    purchaseOrderSensitiveData.add(new PurchaseOrderSensitiveData(getPurapDocumentIdentifier(), getRequisitionIdentifier(), cc.getSensitiveDataCode()));
                }
            }
        }
    }
    if (purchaseOrderSensitiveData != null) {
        SpringContext.getBean(BusinessObjectService.class).save(purchaseOrderSensitiveData);
    }
}
Also used : PurchaseOrderSensitiveData(org.kuali.kfs.module.purap.businessobject.PurchaseOrderSensitiveData) PurchaseOrderCapitalAssetSystem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderCapitalAssetSystem) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) ArrayList(java.util.ArrayList) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) PurchaseOrderItem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem) SequenceAccessorService(org.kuali.kfs.krad.service.SequenceAccessorService) RequisitionCapitalAssetItem(org.kuali.kfs.module.purap.businessobject.RequisitionCapitalAssetItem) RequisitionItem(org.kuali.kfs.module.purap.businessobject.RequisitionItem) PurchasingItemBase(org.kuali.kfs.module.purap.businessobject.PurchasingItemBase) CommodityCode(org.kuali.kfs.vnd.businessobject.CommodityCode) ArrayList(java.util.ArrayList) List(java.util.List) CapitalAssetSystem(org.kuali.kfs.integration.purap.CapitalAssetSystem) PurchaseOrderCapitalAssetSystem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderCapitalAssetSystem) HashSet(java.util.HashSet)

Example 5 with PurchasingItemBase

use of org.kuali.kfs.module.purap.businessobject.PurchasingItemBase in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method addFavoriteAccount.

/*
     * KFSPTS-985 : add favorite account.
     * This is a copy from requisitionaction.  to be shared by both req & po
     */
public ActionForward addFavoriteAccount(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase poForm = (PurchasingFormBase) form;
    PurchasingDocumentBase document = (PurchasingDocumentBase) poForm.getDocument();
    int itemIdx = getSelectedLine(request);
    final int DISTRIBUTION_INDEX = -2;
    PurchasingFavoriteAccountLineBuilderBase<? extends PurApAccountingLine> favoriteAccountBuilder;
    // Initialize the correct builder based on whether the Favorite Account is for an item in the list or for account distribution.
    if (itemIdx >= 0) {
        PurchasingItemBase item = (PurchasingItemBase) document.getItem(itemIdx);
        favoriteAccountBuilder = new PurchasingFavoriteAccountLineBuilderForLineItem<PurApAccountingLine>(item, itemIdx, poForm.setupNewPurchasingAccountingLine());
    } else if (itemIdx == DISTRIBUTION_INDEX) {
        favoriteAccountBuilder = new PurchasingFavoriteAccountLineBuilderForDistribution<PurApAccountingLine>(document, poForm.getAccountDistributionsourceAccountingLines(), poForm.setupNewAccountDistributionAccountingLine());
    } else {
        return mapping.findForward(KFSConstants.MAPPING_BASIC);
    }
    // Add a new Favorite-Account-derived accounting line to the list, with errors inserted into the message map as appropriate.
    favoriteAccountBuilder.addNewFavoriteAccountLineToListIfPossible();
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PurchasingFavoriteAccountLineBuilderForDistribution(edu.cornell.kfs.module.purap.util.PurchasingFavoriteAccountLineBuilderForDistribution) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PurchasingItemBase(org.kuali.kfs.module.purap.businessobject.PurchasingItemBase) PurchasingDocumentBase(org.kuali.kfs.module.purap.document.PurchasingDocumentBase)

Aggregations

PurchasingItemBase (org.kuali.kfs.module.purap.businessobject.PurchasingItemBase)11 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 CommodityCode (org.kuali.kfs.vnd.businessobject.CommodityCode)3 List (java.util.List)2 Map (java.util.Map)2 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)2 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)2 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)2 PurchasingFavoriteAccountLineBuilderForDistribution (edu.cornell.kfs.module.purap.util.PurchasingFavoriteAccountLineBuilderForDistribution)1 BigDecimal (java.math.BigDecimal)1 HashSet (java.util.HashSet)1 ConfigurationService (org.kuali.kfs.core.api.config.property.ConfigurationService)1 CapitalAssetSystem (org.kuali.kfs.integration.purap.CapitalAssetSystem)1 WorkflowDocument (org.kuali.kfs.kew.api.WorkflowDocument)1 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)1 PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)1 Document (org.kuali.kfs.krad.document.Document)1 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)1