Search in sources :

Example 36 with PurApItem

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

the class CuPaymentRequestServiceImpl method addTaxItem.

@Override
protected PurApItem addTaxItem(PaymentRequestDocument preq, String itemTypeCode, BigDecimal taxableAmount) {
    PurApItem item = super.addTaxItem(preq, itemTypeCode, taxableAmount);
    PurApAccountingLine taxLine = item.getSourceAccountingLines().get(0);
    // KFSPTS-1891.  added to fix validation required field error. especially after calculate tax
    if (taxLine.getAccountLinePercent() == null) {
        taxLine.setAccountLinePercent(BigDecimal.ZERO);
    }
    return item;
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)

Example 37 with PurApItem

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

the class CuRequisitionDocument method getAccountsForAwardRouting.

public List<Account> getAccountsForAwardRouting() {
    List<Account> accounts = new ArrayList<Account>();
    ParameterService parameterService = SpringContext.getBean(ParameterService.class);
    for (PurApItem item : (List<PurApItem>) this.getItems()) {
        for (PurApAccountingLine accountingLine : item.getSourceAccountingLines()) {
            if (isObjectCodeAllowedForAwardRouting(accountingLine, parameterService)) {
                if (ObjectUtils.isNull(accountingLine.getAccount())) {
                    accountingLine.refreshReferenceObject("account");
                }
                if (accountingLine.getAccount() != null && !accounts.contains(accountingLine.getAccount())) {
                    accounts.add(accountingLine.getAccount());
                }
            }
        }
    }
    return accounts;
}
Also used : RequisitionAccount(org.kuali.kfs.module.purap.businessobject.RequisitionAccount) Account(org.kuali.kfs.coa.businessobject.Account) 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) ArrayList(java.util.ArrayList)

Example 38 with PurApItem

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

the class CuPurchaseOrderAmendmentDocumentPresentationController method getEditModes.

@Override
public Set<String> getEditModes(Document document) {
    Set<String> editModes = super.getEditModes(document);
    PurchaseOrderDocument poDocument = (PurchaseOrderDocument) document;
    if (PurapConstants.PurchaseOrderStatuses.APPDOC_CHANGE_IN_PROCESS.equals(poDocument.getApplicationDocumentStatus())) {
        WorkflowDocument workflowDocument = poDocument.getFinancialSystemDocumentHeader().getWorkflowDocument();
        // amendment doc needs to lock its field for initiator while enroute
        if (workflowDocument.isInitiated() || workflowDocument.isSaved() || workflowDocument.isCompletionRequested()) {
            editModes.add(PurchaseOrderEditMode.AMENDMENT_ENTRY);
        }
    }
    // KFSUPGRADE-339
    if (PurchaseOrderStatuses.APPDOC_AWAITING_FISCAL_REVIEW.equals(((PurchaseOrderDocument) document).getApplicationDocumentStatus())) {
        editModes.add(PurchaseOrderEditMode.AMENDMENT_ENTRY);
    }
    if (SpringContext.getBean(PurapService.class).isDocumentStoppedInRouteNode((PurchasingAccountsPayableDocument) document, "New Unordered Items")) {
        editModes.add(PurchaseOrderEditMode.UNORDERED_ITEM_ACCOUNT_ENTRY);
    }
    boolean showDisableRemoveAccounts = true;
    PurchaseOrderAmendmentDocument purchaseOrderAmendmentDocument = (PurchaseOrderAmendmentDocument) document;
    List<PurApItem> aboveTheLinePOItems = PurApItemUtils.getAboveTheLineOnly(purchaseOrderAmendmentDocument.getItems());
    PurchaseOrderDocument po = (PurchaseOrderDocument) document;
    boolean containsUnpaidPaymentRequestsOrCreditMemos = po.getContainsUnpaidPaymentRequestsOrCreditMemos();
    ItemLoop: for (PurApItem poItem : aboveTheLinePOItems) {
        boolean acctLinesEditable = allowAccountingLinesAreEditable((PurchaseOrderItem) poItem, containsUnpaidPaymentRequestsOrCreditMemos);
        for (PurApAccountingLine poAccoutingLine : poItem.getSourceAccountingLines()) {
            if (!acctLinesEditable) {
                showDisableRemoveAccounts = false;
                break ItemLoop;
            }
        }
    }
    if (!showDisableRemoveAccounts) {
        editModes.add(PurchaseOrderEditMode.DISABLE_REMOVE_ACCTS);
    }
    // KFSPTS-985
    if (document instanceof PurchaseOrderDocument && !editModes.contains(RequisitionEditMode.DISABLE_SETUP_ACCT_DISTRIBUTION) && !hasEmptyAcctline((PurchaseOrderDocument) document)) {
        editModes.add(RequisitionEditMode.DISABLE_SETUP_ACCT_DISTRIBUTION);
    }
    return editModes;
}
Also used : PurchaseOrderAmendmentDocument(org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument) PurchaseOrderItem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem) PurapService(org.kuali.kfs.module.purap.document.service.PurapService) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument)

Example 39 with PurApItem

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

the class CuLineItemQuantityNotZero method validate.

public boolean validate(AttributedDocumentEvent event) {
    boolean valid = true;
    PaymentRequestDocument document = (PaymentRequestDocument) event.getDocument();
    GlobalVariables.getMessageMap().clearErrorPath();
    GlobalVariables.getMessageMap().addToErrorPath(KFSPropertyConstants.DOCUMENT);
    int i = 0;
    for (PurApItem item : (List<PurApItem>) document.getItems()) {
        KualiDecimal itemQuantity = item.getItemQuantity();
        if (!((PaymentRequestItem) item).isNoQtyItem() && itemQuantity != null) {
            if (!itemQuantity.isNonZero()) {
                GlobalVariables.getMessageMap().putError("item[" + i + "].itemQuantity", PurapKeyConstants.ERROR_PAYMENT_REQUEST_LINE_ITEM_QUANTITY_ZERO);
                GlobalVariables.getMessageMap().clearErrorPath();
                valid = false;
                break;
            }
            i++;
        }
    }
    return valid;
}
Also used : PaymentRequestItem(org.kuali.kfs.module.purap.businessobject.PaymentRequestItem) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) List(java.util.List)

Example 40 with PurApItem

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

the class PurchasingProcessItemValidation method validate.

/* (non-Javadoc)
	 * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
	 */
public boolean validate(AttributedDocumentEvent event) {
    boolean valid = true;
    PurchasingDocument purDocument = (PurchasingDocument) event.getDocument();
    MessageMap errorMap = GlobalVariables.getMessageMap();
    errorMap.clearErrorPath();
    // errorMap.addToErrorPath(PurapConstants.ITEM_TAB_ERRORS);
    // KFSPTS-1719 :  remove this validation
    // // Check that item isn't a non-qty item on an e-invoice vendor order
    // Check that there aren't any req items that already have non-qty values entered
    List<PurApItem> reqItems = purDocument.getItems();
    // KFSPTS-2096
    if (!reqItems.isEmpty()) {
        String itemTypeCode = KFSConstants.EMPTY_STRING;
        int i = 0;
        for (PurApItem item : reqItems) {
            if (StringUtils.isEmpty(itemTypeCode) && (PurapConstants.ItemTypeCodes.ITEM_TYPE_SERVICE_CODE.equalsIgnoreCase(item.getItemTypeCode()) || PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE.equalsIgnoreCase(item.getItemTypeCode()))) {
                itemTypeCode = item.getItemTypeCode();
            }
            if (StringUtils.isNotBlank(itemTypeCode) && (PurapConstants.ItemTypeCodes.ITEM_TYPE_SERVICE_CODE.equalsIgnoreCase(item.getItemTypeCode()) || PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE.equalsIgnoreCase(item.getItemTypeCode())) && !itemTypeCode.equalsIgnoreCase(item.getItemTypeCode())) {
                // Throw error that mix qty and no-qty
                // errorMap.addToErrorPath("document.item["+ i + "].itemTypeCode");
                errorMap.putError("document.item[" + i + "].itemTypeCode", CUPurapKeyConstants.PURAP_MIX_ITEM_QTY_NONQTY);
                // errorMap.removeFromErrorPath("document.item["+ i + "].itemTypeCode");
                valid &= false;
            }
            if (PurapConstants.ItemTypeCodes.ITEM_TYPE_SERVICE_CODE.equalsIgnoreCase(item.getItemTypeCode()) || PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE.equalsIgnoreCase(item.getItemTypeCode())) {
                i++;
            }
        }
    }
    // errorMap.clearErrorPath();
    return valid;
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) MessageMap(org.kuali.kfs.krad.util.MessageMap)

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