Search in sources :

Example 6 with PurApItem

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

the class PurchasingActionBase method importItems.

/**
 * Import items to the document from a spreadsheet.
 *
 * @param mapping An ActionMapping
 * @param form An ActionForm
 * @param request The HttpServletRequest
 * @param response The HttpServletResponse
 * @return An ActionForward
 * @throws Exception
 */
public ActionForward importItems(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    LOG.info("Importing item lines");
    PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
    PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();
    String documentNumber = purDocument.getDocumentNumber();
    FormFile itemFile = purchasingForm.getItemImportFile();
    Class itemClass = purDocument.getItemClass();
    List<PurApItem> importedItems = null;
    String errorPath = PurapConstants.ITEM_TAB_ERRORS;
    ItemParser itemParser = purDocument.getItemParser();
    // starting position of the imported items, equals the # of
    int itemLinePosition = purDocument.getItemLinePosition();
    try {
        importedItems = itemParser.importItems(itemFile, itemClass, documentNumber);
        // validate imported items
        boolean allPassed = true;
        int itemLineNumber = 0;
        for (PurApItem item : importedItems) {
            // Before the validation, set the item line number to the same as the line number in the import file (starting from
            // 1)
            // so that the error message will use the correct line number if there're errors for the current item line.
            item.setItemLineNumber(++itemLineNumber);
            allPassed &= SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedImportPurchasingAccountsPayableItemEvent("", purDocument, item));
            // After the validation, set the item line number to the correct value as if it's added to the item list.
            item.setItemLineNumber(itemLineNumber + itemLinePosition);
        }
        if (allPassed) {
            updateBOReferenceforNewItems(importedItems, (PurchasingDocumentBase) purDocument);
            purDocument.getItems().addAll(itemLinePosition, importedItems);
        }
    } catch (ItemParserException e) {
        GlobalVariables.getMessageMap().putError(errorPath, e.getErrorKey(), e.getErrorParameters());
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : ItemParser(org.kuali.kfs.module.purap.util.ItemParser) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) AttributedImportPurchasingAccountsPayableItemEvent(org.kuali.kfs.module.purap.document.validation.event.AttributedImportPurchasingAccountsPayableItemEvent) FormFile(org.apache.struts.upload.FormFile) ItemParserException(org.kuali.kfs.module.purap.exception.ItemParserException)

Example 7 with PurApItem

use of org.kuali.kfs.module.purap.businessobject.PurApItem 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 -- Added, req has this new attribute's value and it needs to be carried over to the 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(PurapConstants.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().intValue());
        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 8 with PurApItem

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

the class PurchaseOrderDocument method isAwardReviewRequired.

protected boolean isAwardReviewRequired() {
    ParameterService parameterService = SpringContext.getBean(ParameterService.class);
    boolean objectCodeAllowed = true;
    for (PurApItem item : (List<PurApItem>) this.getItems()) {
        for (PurApAccountingLine accountingLine : item.getSourceAccountingLines()) {
            objectCodeAllowed = isObjectCodeAllowedForAwardRouting(accountingLine, parameterService);
            // level.
            if (objectCodeAllowed) {
                return objectCodeAllowed;
            }
        }
    }
    return objectCodeAllowed;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) ArrayList(java.util.ArrayList) List(java.util.List)

Example 9 with PurApItem

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

the class PurchasingAccountsPayableDocumentBase method itemSwap.

/**
 * @see org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument#itemSwap(int positionFrom, int positionTo)
 */
@Override
public void itemSwap(int positionFrom, int positionTo) {
    // if out of range do nothing
    if ((positionTo < 0) || (positionTo >= getItemLinePosition())) {
        return;
    }
    PurApItem item1 = this.getItem(positionFrom);
    PurApItem item2 = this.getItem(positionTo);
    Integer oldFirstPos = item1.getItemLineNumber();
    // swap line numbers
    item1.setItemLineNumber(item2.getItemLineNumber());
    item2.setItemLineNumber(oldFirstPos);
    // fix ordering in list
    items.remove(positionFrom);
    items.add(positionTo, item1);
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem)

Example 10 with PurApItem

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

the class PurchasingAccountsPayableDocumentBase method getPersistedSourceAccountingLinesForComparison.

/**
 * Accounting lines that are read-only should skip validation
 *
 * @see org.kuali.kfs.sys.document.AccountingDocumentBase#getPersistedSourceAccountingLinesForComparison()
 */
@SuppressWarnings("rawtypes")
@Override
protected List getPersistedSourceAccountingLinesForComparison() {
    LOG.info("Checking persisted source accounting lines for read-only fields");
    List<String> restrictedItemTypesList = new ArrayList<String>();
    try {
        restrictedItemTypesList = new ArrayList<String>(SpringContext.getBean(ParameterService.class).getParameterValuesAsString(this.getClass(), PurapParameterConstants.PURAP_ITEM_TYPES_RESTRICTING_ACCOUNT_EDIT));
    } catch (IllegalArgumentException iae) {
    // do nothing, not a problem if no restricted types are defined
    }
    PurapAccountingService purApAccountingService = SpringContext.getBean(PurapAccountingService.class);
    List persistedSourceLines = new ArrayList();
    for (PurApItem item : (List<PurApItem>) this.getItems()) {
        // only check items that already have been persisted since last save
        if (ObjectUtils.isNotNull(item.getItemIdentifier())) {
            // Disable validation if the item is read-only
            final boolean isNotReadOnly = !((restrictedItemTypesList != null) && restrictedItemTypesList.contains(item.getItemTypeCode()));
            if (isNotReadOnly) {
                persistedSourceLines.addAll(purApAccountingService.getAccountsFromItem(item));
            }
        }
    }
    return persistedSourceLines;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) PurapAccountingService(org.kuali.kfs.module.purap.service.PurapAccountingService)

Aggregations

PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)45 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)17 ArrayList (java.util.ArrayList)15 List (java.util.List)15 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)10 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)7 PurchasingAccountsPayableDocument (org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)5 PurchasingDocument (org.kuali.kfs.module.purap.document.PurchasingDocument)5 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)4 ItemType (org.kuali.kfs.module.purap.businessobject.ItemType)4 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)4 PurchasingItemBase (org.kuali.kfs.module.purap.businessobject.PurchasingItemBase)4 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)4 BigDecimal (java.math.BigDecimal)3 HashSet (java.util.HashSet)3 PurApAccountingLineBase (org.kuali.kfs.module.purap.businessobject.PurApAccountingLineBase)3 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)3 PurchaseOrderAmendmentDocument (org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument)3 PurchasingAccountsPayableDocumentBase (org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocumentBase)3 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)3