Search in sources :

Example 1 with PurApItem

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

the class CuRequisitionDocument method isAwardReviewRequired.

protected boolean isAwardReviewRequired() {
    boolean requiresAwardReview = false;
    this.getAccountsForRouting();
    ParameterService parameterService = SpringContext.getBean(ParameterService.class);
    // If the award amount is less than the threshold, then there's no reason to review the object codes, return false
    if (!isAwardAmountGreaterThanThreshold()) {
        return requiresAwardReview;
    }
    for (PurApItem item : (List<PurApItem>) this.getItems()) {
        for (PurApAccountingLine accountingLine : item.getSourceAccountingLines()) {
            requiresAwardReview = isObjectCodeAllowedForAwardRouting(accountingLine, parameterService);
            // level.
            if (requiresAwardReview) {
                return requiresAwardReview;
            }
        }
    }
    return requiresAwardReview;
}
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) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with PurApItem

use of org.kuali.kfs.module.purap.businessobject.PurApItem 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 3 with PurApItem

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

the class PurchasingActionBase method deleteSourceLine.

/**
 * @see org.kuali.kfs.sys.web.struts.KualiAccountingDocumentActionBase#deleteSourceLine(org.apache.struts.action.ActionMapping,
 *      org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward deleteSourceLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
    String[] indexes = getSelectedLineForAccounts(request);
    int itemIndex = Integer.parseInt(indexes[0]);
    int accountIndex = Integer.parseInt(indexes[1]);
    if (itemIndex == -2) {
        purchasingForm.getAccountDistributionsourceAccountingLines().remove(accountIndex);
    } else {
        PurApItem item = ((PurchasingAccountsPayableDocument) purchasingForm.getDocument()).getItem((itemIndex));
        item.getSourceAccountingLines().remove(accountIndex);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)

Example 4 with PurApItem

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

the class PurchasingActionBase method addItem.

/**
 * Add a new item to the document.
 *
 * @param mapping An ActionMapping
 * @param form An ActionForm
 * @param request The HttpServletRequest
 * @param response The HttpServletResponse
 * @return An ActionForward
 * @throws Exception
 */
@SuppressWarnings("unchecked")
public ActionForward addItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
    PurApItem item = purchasingForm.getNewPurchasingItemLine();
    PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();
    boolean rulePassed = SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedAddPurchasingAccountsPayableItemEvent("", purDocument, item));
    if (rulePassed) {
        item = purchasingForm.getAndResetNewPurchasingItemLine();
        purDocument.addItem(item);
        // KFSPTS-985
        if (((PurchasingDocumentBase) purDocument).isIntegratedWithFavoriteAccount()) {
            populatePrimaryFavoriteAccount(item.getSourceAccountingLines(), getAccountClassFromNewPurApAccountingLine(purchasingForm));
        }
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) AttributedAddPurchasingAccountsPayableItemEvent(org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingAccountsPayableItemEvent) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) PurchasingDocumentBase(org.kuali.kfs.module.purap.document.PurchasingDocumentBase)

Example 5 with PurApItem

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

the class PurchasingActionBase method removeAccounts.

/**
 * Clear out the accounting lines from all the items.
 *
 * @param mapping An ActionMapping
 * @param form An ActionForm
 * @param request The HttpServletRequest
 * @param response The HttpServletResponse
 * @return An ActionForward
 * @throws Exception
 */
public ActionForward removeAccounts(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingAccountsPayableFormBase purchasingForm = (PurchasingAccountsPayableFormBase) form;
    Object question = request.getParameter(PurapConstants.QUESTION_INDEX);
    Object buttonClicked = request.getParameter(KFSConstants.QUESTION_CLICKED_BUTTON);
    if (question == null) {
        String questionText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(PurapConstants.QUESTION_REMOVE_ACCOUNTS);
        return this.performQuestionWithoutInput(mapping, form, request, response, PurapConstants.REMOVE_ACCOUNTS_QUESTION, questionText, KFSConstants.CONFIRMATION_QUESTION, KFSConstants.ROUTE_METHOD, "0");
    } else if (ConfirmationQuestion.YES.equals(buttonClicked)) {
        for (PurApItem item : ((PurchasingAccountsPayableDocument) purchasingForm.getDocument()).getItems()) {
            item.getSourceAccountingLines().clear();
        }
        KNSGlobalVariables.getMessageList().add(PurapKeyConstants.PURAP_GENERAL_ACCOUNTS_REMOVED);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) ConfigurationService(org.kuali.rice.core.api.config.property.ConfigurationService)

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