Search in sources :

Example 41 with PurApItem

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

the class CuPurchaseOrderForm method populateItemAccountingLines.

// end KFSUPGRADE-411
/**
 * Overridden to properly increment the local "itemCount" loop counter when processing POA documents,
 * but otherwise has the same code as in the superclass.
 *
 * @see org.kuali.kfs.module.purap.document.web.struts.PurchasingAccountsPayableFormBase#populateItemAccountingLines(java.util.Map)
 */
@SuppressWarnings("rawtypes")
@Override
protected void populateItemAccountingLines(Map parameterMap) {
    if (!(getDocument() instanceof PurchaseOrderAmendmentDocument)) {
        super.populateItemAccountingLines(parameterMap);
        return;
    }
    int itemCount = 0;
    for (PurApItem item : ((PurchasingAccountsPayableDocument) getDocument()).getItems()) {
        populateAccountingLine(item.getNewSourceLine(), KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.ITEM + "[" + itemCount + "]." + KFSPropertyConstants.NEW_SOURCE_LINE, parameterMap);
        int sourceLineCount = 0;
        for (PurApAccountingLine purApLine : item.getSourceAccountingLines()) {
            populateAccountingLine(purApLine, KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.ITEM + "[" + itemCount + "]." + KFSPropertyConstants.SOURCE_ACCOUNTING_LINE + "[" + sourceLineCount + "]", parameterMap);
            sourceLineCount += 1;
        }
        itemCount += 1;
    }
}
Also used : PurchaseOrderAmendmentDocument(org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)

Example 42 with PurApItem

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

the class CuPurchasingAccountsPayableObjectCodeOverrideBranchingValidation method determineBranch.

@Override
protected String determineBranch(AttributedDocumentEvent event) {
    if (!StringUtils.isBlank(propertyPath)) {
        refreshByPath(accountingLineForValidation);
    }
    boolean isTaxApproval = false;
    // KFSPTS-1891 : treasury manager also skip this object type allowed check
    boolean isTreasuryApproval = false;
    // or if this accounting line is from a Tax Charge line.
    if (accountingDocumentForValidation instanceof PaymentRequestDocument) {
        PaymentRequestDocument preq = (PaymentRequestDocument) accountingDocumentForValidation;
        PurApAccountingLine purapAccountingLine = (PurApAccountingLine) accountingLineForValidation;
        PurApItem item = purapAccountingLine.getPurapItem();
        if (StringUtils.equals(PaymentRequestStatuses.APPDOC_AWAITING_TAX_REVIEW, preq.getApplicationDocumentStatus())) {
            isTaxApproval = true;
        } else if (StringUtils.equals(PaymentRequestStatuses.APPDOC_PAYMENT_METHOD_REVIEW, preq.getApplicationDocumentStatus())) {
            isTreasuryApproval = true;
        } else if (StringUtils.equals(PaymentRequestStatuses.APPDOC_DEPARTMENT_APPROVED, preq.getApplicationDocumentStatus()) && (ObjectUtils.isNotNull(item) && item.getItemType().getIsTaxCharge())) {
            isTaxApproval = true;
        }
    }
    if (isTaxApproval || isTreasuryApproval) {
        return null;
    } else if (isAccountingLineValueAllowed(accountingDocumentForValidation.getClass(), accountingLineForValidation, parameterToCheckAgainst, propertyPath, (responsibleProperty != null ? responsibleProperty : propertyPath))) {
        return OBJECT_CODE_OVERRIDEN;
    } else {
        return OBJECT_CODE_NOT_OVERRIDEN;
    }
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument)

Example 43 with PurApItem

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

the class CuRequisitionAssignToTradeInValidation method validate.

public boolean validate(AttributedDocumentEvent event) {
    // Initialize the valid and true, and get the requisition document.
    boolean foundTradeIn = false;
    boolean valid = true;
    PurchasingAccountsPayableDocumentBase purapDoc = (PurchasingAccountsPayableDocumentBase) event.getDocument();
    // First, get all the items from the requisition document.  For each of
    // the items, look for the ones that are assigned to a trade-in value.
    // For these trade-in items, validate that the trade-in line has a valid
    // description and amount.
    List<PurApItem> items = (List<PurApItem>) purapDoc.getItems();
    for (PurApItem item : items) {
        item.refreshReferenceObject(PurapPropertyConstants.ITEM_TYPE);
        if (item.getItemAssignedToTradeInIndicator()) {
            foundTradeIn = true;
            break;
        }
    }
    // Was a trade-in found for any of the above items?
    if (foundTradeIn) {
        // Get the trade-in item.
        PurApItem tradeInItem = purapDoc.getTradeInItem();
        if (tradeInItem != null) {
            if (StringUtils.isEmpty(tradeInItem.getItemDescription())) {
                String attributeLabel = dataDictionaryService.getDataDictionary().getBusinessObjectEntry(tradeInItem.getClass().getName()).getAttributeDefinition(PurapPropertyConstants.ITEM_DESCRIPTION).getLabel();
                tradeInItem.getItemLineNumber();
                GlobalVariables.getMessageMap().putError("document.item[" + getTradeInItemLineIndex(items) + "]." + PurapPropertyConstants.ITEM_DESCRIPTION, PurapKeyConstants.ERROR_ITEM_BELOW_THE_LINE, "The item description of " + tradeInItem.getItemType().getItemTypeDescription(), "empty");
                valid = false;
            } else if (ObjectUtils.isNull(tradeInItem.getItemUnitPrice())) {
                String attributeLabel = dataDictionaryService.getDataDictionary().getBusinessObjectEntry(tradeInItem.getClass().getName()).getAttributeDefinition(PurapPropertyConstants.ITEM_UNIT_PRICE).getLabel();
                GlobalVariables.getMessageMap().putError("document.item[" + getTradeInItemLineIndex(items) + "]." + PurapPropertyConstants.ITEM_UNIT_PRICE, PurapKeyConstants.ERROR_ITEM_BELOW_THE_LINE, tradeInItem.getItemType().getItemTypeDescription(), "zero");
                valid = false;
            }
        }
    }
    return valid;
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurchasingAccountsPayableDocumentBase(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocumentBase) List(java.util.List)

Example 44 with PurApItem

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

the class CuPurchaseOrderAmendmentAccountValidation method validate.

/**
 * Overridden to allow POAs to use expired accounts.
 *
 * @see org.kuali.kfs.module.purap.document.validation.impl.PurchaseOrderAmendmentAccountValidation#validate(
 * org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
 */
@Override
public boolean validate(AttributedDocumentEvent event) {
    boolean valid = true;
    PurchaseOrderDocument poaDocument = (PurchaseOrderDocument) event.getDocument();
    List<PurApItem> items = poaDocument.getItemsActiveOnly();
    PurchaseOrderDocument po = SpringContext.getBean(PurchaseOrderService.class).getCurrentPurchaseOrder(poaDocument.getPurapDocumentIdentifier());
    List<PurApItem> poItems = po.getItems();
    for (PurApItem item : items) {
        String identifierString = item.getItemIdentifierString();
        if (item.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE) && item.getSourceAccountingLines() != null && item.getSourceAccountingLines().size() > 0) {
            if (isItemChanged(item, poItems)) {
                List<PurApAccountingLine> accountingLines = item.getSourceAccountingLines();
                for (PurApAccountingLine accountingLine : accountingLines) {
                    if (!accountingLine.getAccount().isActive()) {
                        valid = false;
                        GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, PurapKeyConstants.ERROR_ITEM_ACCOUNT_INACTIVE, accountingLine.getAccount().getAccountNumber());
                        break;
                    }
                }
            }
        }
    }
    return valid;
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurchaseOrderService(org.kuali.kfs.module.purap.document.service.PurchaseOrderService) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument)

Example 45 with PurApItem

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

the class CuPurchaseOrderAmendmentAccountValidation method isItemChanged.

// Copied and tweaked this superclass method, and increased its visibility.
protected boolean isItemChanged(PurApItem poaItem, List<PurApItem> poItems) {
    boolean changed = false;
    int poaItemId = poaItem.getItemLineNumber().intValue();
    for (PurApItem poItem : poItems) {
        if (poItem.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE) && poaItemId == poItem.getItemLineNumber().intValue()) {
            if (poaItem.getItemQuantity() == null || poaItem.getItemQuantity().intValue() != poItem.getItemQuantity().intValue()) {
                changed = true;
            }
            if (!poaItem.getItemUnitOfMeasureCode().equals(poItem.getItemUnitOfMeasureCode())) {
                changed = true;
            }
            if (poaItem.getItemUnitPrice() == null || poaItem.getItemUnitPrice().floatValue() != poItem.getItemUnitPrice().floatValue()) {
                changed = true;
            }
            if (poaItem.getTotalAmount().floatValue() != poItem.getTotalAmount().floatValue()) {
                changed = true;
            }
            if (poaItem.getItemAssignedToTradeInIndicator() != poItem.getItemAssignedToTradeInIndicator()) {
                changed = true;
            }
            if ((poaItem.getItemCatalogNumber() != null && !poaItem.getItemCatalogNumber().equals(poItem.getItemCatalogNumber())) || (poItem.getItemCatalogNumber() != null && !poItem.getItemCatalogNumber().equals(poaItem.getItemCatalogNumber()))) {
                changed = true;
            }
            if ((poaItem.getItemDescription() != null && !poaItem.getItemDescription().equals(poItem.getItemDescription())) || (poItem.getItemDescription() != null && !poItem.getItemDescription().equals(poaItem.getItemDescription()))) {
                changed = true;
            }
            if ((poaItem.getExtendedPrice() != null && poItem.getExtendedPrice() != null && poaItem.getExtendedPrice().floatValue() != poItem.getExtendedPrice().floatValue()) || (poaItem.getExtendedPrice() != null && poaItem.getExtendedPrice().floatValue() != 0 && poItem.getExtendedPrice() == null) || (poaItem.getExtendedPrice() == null && poItem.getExtendedPrice() != null && poItem.getExtendedPrice().floatValue() != 0)) {
                changed = true;
            }
            if ((poaItem.getItemTaxAmount() != null && poItem.getItemTaxAmount() != null && poaItem.getItemTaxAmount().floatValue() != poItem.getItemTaxAmount().floatValue()) || (poaItem.getItemTaxAmount() != null && poaItem.getItemTaxAmount().floatValue() != 0 && poItem.getItemTaxAmount() != null) || (poaItem.getItemTaxAmount() == null && poItem.getItemTaxAmount() != null && poItem.getItemTaxAmount().floatValue() != 0)) {
                changed = true;
            }
            break;
        }
    }
    return changed;
}
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