Search in sources :

Example 26 with PurApItem

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

the class PurchasingAccountsPayableDocumentBase method getTotalPreTaxDollarAmountWithExclusions.

/**
 * Computes the total dollar amount with the specified item types and possibly below the line items excluded.
 *
 * @param excludedTypes the types of items to be excluded.
 * @param includeBelowTheLine indicates whether below the line items shall be included.
 * @return the total dollar amount with the specified item types excluded.
 */
public KualiDecimal getTotalPreTaxDollarAmountWithExclusions(String[] excludedTypes, boolean includeBelowTheLine) {
    if (excludedTypes == null) {
        excludedTypes = new String[] {};
    }
    KualiDecimal total = new KualiDecimal(BigDecimal.ZERO);
    for (PurApItem item : (List<PurApItem>) getItems()) {
        item.refreshReferenceObject(PurapPropertyConstants.ITEM_TYPE);
        ItemType it = item.getItemType();
        if ((includeBelowTheLine || it.isLineItemIndicator()) && !ArrayUtils.contains(excludedTypes, it.getItemTypeCode())) {
            KualiDecimal extendedPrice = item.getExtendedPrice();
            KualiDecimal itemTotal = (extendedPrice != null) ? extendedPrice : KualiDecimal.ZERO;
            total = total.add(itemTotal);
        }
    }
    return total;
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) ItemType(org.kuali.kfs.module.purap.businessobject.ItemType) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) List(java.util.List) ArrayList(java.util.ArrayList)

Example 27 with PurApItem

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

the class PurchasingDocumentBase method deleteItem.

/**
 * @see org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument#deleteItem(int lineNum)
 */
@Override
public void deleteItem(int lineNum) {
    // remove associated asset items
    PurApItem item = items.get(lineNum);
    if (ObjectUtils.isNotNull(item) && item.getItemIdentifier() != null) {
        PurchasingCapitalAssetItem purchasingCapitalAssetItem = getPurchasingCapitalAssetItemByItemIdentifier(item.getItemIdentifier());
        if (ObjectUtils.isNotNull(purchasingCapitalAssetItem)) {
            getPurchasingCapitalAssetItems().remove(purchasingCapitalAssetItem);
        }
        // no more capital asset items, clear cap asset fields
        if (getPurchasingCapitalAssetItems().size() == 0) {
            clearCapitalAssetFields();
        }
    }
    super.deleteItem(lineNum);
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurchasingCapitalAssetItem(org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem)

Example 28 with PurApItem

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

the class PurchasingAddItemValidation method validate.

public boolean validate(AttributedDocumentEvent event) {
    boolean valid = true;
    GlobalVariables.getMessageMap().addToErrorPath(PurapPropertyConstants.NEW_PURCHASING_ITEM_LINE);
    // refresh itemType
    PurApItem refreshedItem = getItemForValidation();
    refreshedItem.refreshReferenceObject("itemType");
    super.setItemForValidation(refreshedItem);
    valid &= super.validate(event);
    valid &= validateItemUnitPrice(getItemForValidation());
    valid &= validateUnitOfMeasure(getItemForValidation());
    if (getItemForValidation().getItemType().isLineItemIndicator()) {
        valid &= validateItemDescription(getItemForValidation());
        valid &= validateItemQuantity(getItemForValidation());
        commodityCodeValidation.setItemForValidation(getItemForValidation());
        valid &= commodityCodeValidation.validate(event);
        // KFSPTS-2096
        valid &= validateMixItemType(getItemForValidation(), (PurchasingAccountsPayableDocument) event.getDocument());
    }
    GlobalVariables.getMessageMap().removeFromErrorPath(PurapPropertyConstants.NEW_PURCHASING_ITEM_LINE);
    return valid;
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)

Example 29 with PurApItem

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

the class PurchasingAddItemValidation method validateMixItemType.

private boolean validateMixItemType(PurApItem newItem, PurchasingAccountsPayableDocument purapDocument) {
    boolean valid = true;
    if (StringUtils.isNotBlank(newItem.getItemTypeCode())) {
        String itemTypeCode = newItem.getItemTypeCode();
        for (PurApItem item : purapDocument.getItems()) {
            if (StringUtils.isNotBlank(item.getItemTypeCode()) && !itemTypeCode.equalsIgnoreCase(item.getItemTypeCode()) && (CUPurapConstants.ItemTypeCodes.ITEM_TYPE_SERVICE_CODE.equalsIgnoreCase(item.getItemTypeCode()) || CUPurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE.equalsIgnoreCase(item.getItemTypeCode()))) {
                GlobalVariables.getMessageMap().addToErrorPath(PurapPropertyConstants.NEW_PURCHASING_ITEM_LINE);
                GlobalVariables.getMessageMap().putError(CUPurapPropertyConstants.ITEM_TYPE_CODE, CUPurapKeyConstants.PURAP_MIX_ITEM_QTY_NONQTY);
                valid &= false;
                GlobalVariables.getMessageMap().removeFromErrorPath(PurapPropertyConstants.NEW_PURCHASING_ITEM_LINE);
                break;
            }
        }
    }
    return valid;
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem)

Example 30 with PurApItem

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

the class PurchasingImportItemValidation method validate.

@Override
public boolean validate(AttributedDocumentEvent event) {
    boolean valid = true;
    PurApItem refreshedItem = getItemForValidation();
    refreshedItem.refreshReferenceObject("itemType");
    super.setItemForValidation(refreshedItem);
    valid &= super.validate(event);
    GlobalVariables.getMessageMap().addToErrorPath(PurapConstants.ITEM_TAB_ERROR_PROPERTY);
    if (getItemForValidation().getItemType().isLineItemIndicator()) {
        valid &= validateItemDescription(getItemForValidation());
        commodityCodeValidation.setItemForValidation(getItemForValidation());
        valid &= commodityCodeValidation.validate(event);
    }
    valid &= validateItemUnitPrice(getItemForValidation());
    valid &= validateUnitOfMeasureCodeExists(getItemForValidation());
    GlobalVariables.getMessageMap().removeFromErrorPath(PurapConstants.ITEM_TAB_ERROR_PROPERTY);
    return valid;
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem)

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