Search in sources :

Example 26 with PurApAccountingLine

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

use of org.kuali.kfs.module.purap.businessobject.PurApAccountingLine 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)

Aggregations

PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)27 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)17 ArrayList (java.util.ArrayList)9 List (java.util.List)7 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)7 BigDecimal (java.math.BigDecimal)6 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)5 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)5 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)4 IWantAccount (edu.cornell.kfs.module.purap.businessobject.IWantAccount)3 PurchaseOrderAmendmentDocument (org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument)3 PurchasingAccountsPayableDocument (org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)3 KfsParameterConstants (org.kuali.kfs.sys.service.impl.KfsParameterConstants)3 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)3 Account (org.kuali.kfs.coa.businessobject.Account)2 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)2 PurchasingItemBase (org.kuali.kfs.module.purap.businessobject.PurchasingItemBase)2 RequisitionAccount (org.kuali.kfs.module.purap.businessobject.RequisitionAccount)2 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)2 PurchasingAccountsPayableDocumentBase (org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocumentBase)2