Search in sources :

Example 6 with MessageMap

use of org.kuali.kfs.krad.util.MessageMap in project cu-kfs by CU-CommunityApps.

the class PaymentRequestWireTransferValidation method validate.

/**
 * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
 */
public boolean validate(AttributedDocumentEvent event) {
    LOG.debug("validate start");
    boolean isValid = true;
    PaymentRequestDocument document = (PaymentRequestDocument) accountingDocumentForValidation;
    PaymentRequestWireTransfer wireTransfer = ((CuPaymentRequestDocument) document).getPreqWireTransfer();
    if (!PaymentMethod.PM_CODE_WIRE.equals(((CuPaymentRequestDocument) document).getPaymentMethodCode())) {
        return isValid;
    }
    MessageMap errors = GlobalVariables.getMessageMap();
    errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
    errors.addToErrorPath(CUPurapPropertyConstants.PREQ_WIRE_TRANSFER);
    isValid &= isValid(wireTransfer.getPreqBankName(), CUPurapConstants.LABEL_BANK_NAME, CUPurapPropertyConstants.PREQ_BANK_NAME);
    isValid &= isValid(wireTransfer.getPreqBankCityName(), CUPurapConstants.LABEL_BANK_CITY, CUPurapPropertyConstants.PREQ_BANK_CITY_NAME);
    isValid &= isValid(wireTransfer.getPreqBankCountryCode(), CUPurapConstants.LABEL_BANK_COUNTRY, CUPurapPropertyConstants.PREQ_BANK_COUNTRY_CODE);
    isValid &= isValid(wireTransfer.getPreqCurrencyTypeName(), CUPurapConstants.LABEL_CURRENCY, CUPurapPropertyConstants.PREQ_CURRENCY_TYPE_NAME);
    isValid &= isValid(wireTransfer.getPreqPayeeAccountNumber(), CUPurapConstants.LABEL_BANK_ACCT_NUMBER, CUPurapPropertyConstants.PREQ_PAYEE_ACCT_NUMBER);
    isValid &= isValid(wireTransfer.getPreqPayeeAccountName(), CUPurapConstants.LABEL_BANK_ACCT_NAME, CUPurapPropertyConstants.PREQ_PAYEE_ACCT_NAME);
    if (KFSConstants.COUNTRY_CODE_UNITED_STATES.equals(wireTransfer.getPreqBankCountryCode()) && StringUtils.isBlank(wireTransfer.getPreqBankRoutingNumber())) {
        errors.putError(CUPurapPropertyConstants.PREQ_BANK_ROUTING_NUMBER, KFSKeyConstants.ERROR_PAYMENT_SOURCE_BANK_ROUTING_NUMBER);
        isValid = false;
    }
    if (KFSConstants.COUNTRY_CODE_UNITED_STATES.equals(wireTransfer.getPreqBankCountryCode()) && StringUtils.isBlank(wireTransfer.getPreqBankStateCode())) {
        errors.putError(CUPurapPropertyConstants.PREQ_BANK_STATE_CODE, KFSKeyConstants.ERROR_REQUIRED, "Bank State");
        isValid = false;
    }
    errors.removeFromErrorPath(CUPurapPropertyConstants.PREQ_WIRE_TRANSFER);
    errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
    return isValid;
}
Also used : PaymentRequestWireTransfer(edu.cornell.kfs.module.purap.businessobject.PaymentRequestWireTransfer) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) MessageMap(org.kuali.kfs.krad.util.MessageMap)

Example 7 with MessageMap

use of org.kuali.kfs.krad.util.MessageMap in project cu-kfs by CU-CommunityApps.

the class CreditMemoForeignDraftValidation method validate.

/**
 * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
 */
public boolean validate(AttributedDocumentEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("validate start");
    }
    boolean isValid = true;
    VendorCreditMemoDocument document = (VendorCreditMemoDocument) accountingDocumentForValidation;
    if (!PaymentMethod.PM_CODE_FOREIGN_DRAFT.equals(((CuVendorCreditMemoDocument) document).getPaymentMethodCode())) {
        return true;
    }
    MessageMap errors = GlobalVariables.getMessageMap();
    errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
    errors.addToErrorPath(CUPurapPropertyConstants.CM_WIRE_TRANSFER);
    /* currency type code required */
    if (StringUtils.isBlank(((CuVendorCreditMemoDocument) document).getCmWireTransfer().getCmForeignCurrencyTypeCode())) {
        errors.putError(CUPurapPropertyConstants.CM_FD_CURRENCY_TYPE_CODE, KFSKeyConstants.ERROR_PAYMENT_SOURCE_CURRENCY_TYPE_CODE);
        isValid = false;
    }
    /* currency type name required */
    if (StringUtils.isBlank(((CuVendorCreditMemoDocument) document).getCmWireTransfer().getCmForeignCurrencyTypeName())) {
        errors.putError(CUPurapPropertyConstants.CM_FD_CURRENCY_TYPE_NAME, KFSKeyConstants.ERROR_PAYMENT_SOURCE_CURRENCY_TYPE_NAME);
        isValid = false;
    }
    errors.removeFromErrorPath(CUPurapPropertyConstants.CM_WIRE_TRANSFER);
    errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
    return isValid;
}
Also used : CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) MessageMap(org.kuali.kfs.krad.util.MessageMap)

Example 8 with MessageMap

use of org.kuali.kfs.krad.util.MessageMap in project cu-kfs by CU-CommunityApps.

the class CreditMemoWireTransferValidation method validate.

/**
 * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
 */
public boolean validate(AttributedDocumentEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("validate start");
    }
    boolean isValid = true;
    VendorCreditMemoDocument document = (VendorCreditMemoDocument) accountingDocumentForValidation;
    CreditMemoWireTransfer wireTransfer = ((CuVendorCreditMemoDocument) document).getCmWireTransfer();
    if (!PaymentMethod.PM_CODE_WIRE.equals(((CuVendorCreditMemoDocument) document).getPaymentMethodCode())) {
        return isValid;
    }
    MessageMap errors = GlobalVariables.getMessageMap();
    errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
    errors.addToErrorPath(CUPurapPropertyConstants.CM_WIRE_TRANSFER);
    isValid &= isValid(wireTransfer.getCmBankName(), CUPurapConstants.LABEL_BANK_NAME, CUPurapPropertyConstants.CM_BANK_NAME);
    isValid &= isValid(wireTransfer.getCmBankCityName(), CUPurapConstants.LABEL_BANK_CITY, CUPurapPropertyConstants.CM_BANK_CITY_NAME);
    isValid &= isValid(wireTransfer.getCmBankCountryCode(), CUPurapConstants.LABEL_BANK_COUNTRY, CUPurapPropertyConstants.CM_BANK_COUNTRY_CODE);
    isValid &= isValid(wireTransfer.getCmCurrencyTypeName(), CUPurapConstants.LABEL_CURRENCY, CUPurapPropertyConstants.CM_CURRENCY_TYPE_NAME);
    isValid &= isValid(wireTransfer.getCmPayeeAccountNumber(), CUPurapConstants.LABEL_BANK_ACCT_NUMBER, CUPurapPropertyConstants.CM_PAYEE_ACCT_NUMBER);
    isValid &= isValid(wireTransfer.getCmPayeeAccountName(), CUPurapConstants.LABEL_BANK_ACCT_NAME, CUPurapPropertyConstants.CM_PAYEE_ACCT_NAME);
    if (KFSConstants.COUNTRY_CODE_UNITED_STATES.equals(wireTransfer.getCmBankCountryCode()) && StringUtils.isBlank(wireTransfer.getCmBankRoutingNumber())) {
        errors.putError(CUPurapPropertyConstants.CM_BANK_ROUTING_NUMBER, KFSKeyConstants.ERROR_PAYMENT_SOURCE_BANK_ROUTING_NUMBER);
        isValid = false;
    }
    if (KFSConstants.COUNTRY_CODE_UNITED_STATES.equals(wireTransfer.getCmBankCountryCode()) && StringUtils.isBlank(wireTransfer.getCmBankStateCode())) {
        errors.putError(CUPurapPropertyConstants.CM_BANK_STATE_CODE, KFSKeyConstants.ERROR_REQUIRED, "Bank State");
        isValid = false;
    }
    errors.removeFromErrorPath(CUPurapPropertyConstants.CM_WIRE_TRANSFER);
    errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
    return isValid;
}
Also used : CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) CreditMemoWireTransfer(edu.cornell.kfs.module.purap.businessobject.CreditMemoWireTransfer) MessageMap(org.kuali.kfs.krad.util.MessageMap)

Example 9 with MessageMap

use of org.kuali.kfs.krad.util.MessageMap in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestProcessItemValidation method validateAboveTheLineItems.

protected boolean validateAboveTheLineItems(PaymentRequestItem item, String identifierString, boolean isReceivingDocumentRequiredIndicator, PaymentRequestDocument paymentRequestDocument) {
    boolean valid = true;
    // Currently Quantity is allowed to be NULL on screen;
    // must be either a positive number or NULL for DB
    MessageMap errorMap = GlobalVariables.getMessageMap();
    errorMap.clearErrorPath();
    if (ObjectUtils.isNotNull(item.getItemQuantity())) {
        if (item.getItemQuantity().isNegative()) {
            // if quantity is negative give an error
            valid = false;
            errorMap.putError(PurapConstants.ITEM_TAB_ERRORS, PurapKeyConstants.ERROR_ITEM_AMOUNT_BELOW_ZERO, ItemFields.INVOICE_QUANTITY, identifierString);
        }
        if (!isReceivingDocumentRequiredIndicator) {
            // KFSPTS-1719, KFSUPGRADE-485 : add isnoqtyitem check
            if (!item.getPurchaseOrderItem().isNoQtyItem() && item.getPoOutstandingQuantity().isLessThan(item.getItemQuantity())) {
                valid = false;
                errorMap.putError(PurapConstants.ITEM_TAB_ERRORS, PurapKeyConstants.ERROR_ITEM_QUANTITY_TOO_MANY, ItemFields.INVOICE_QUANTITY, identifierString, ItemFields.OPEN_QUANTITY);
            }
        }
    }
    if (ObjectUtils.isNotNull(item.getExtendedPrice()) && item.getExtendedPrice().isPositive() && ObjectUtils.isNotNull(item.getPoOutstandingQuantity()) && item.getPoOutstandingQuantity().isPositive()) {
        // here we must require the user to enter some value for quantity if they want a credit amount associated
        if (ObjectUtils.isNull(item.getItemQuantity()) || item.getItemQuantity().isZero()) {
            // here we have a user not entering a quantity with an extended amount but the PO has a quantity...require user to
            // enter a quantity
            valid = false;
            errorMap.putError(PurapConstants.ITEM_TAB_ERRORS, PurapKeyConstants.ERROR_ITEM_QUANTITY_REQUIRED, ItemFields.INVOICE_QUANTITY, identifierString, ItemFields.OPEN_QUANTITY);
        }
    }
    // check that non-quantity based items are not trying to pay on a zero encumbrance amount (check only prior to ap approval)
    if ((ObjectUtils.isNull(paymentRequestDocument.getPurapDocumentIdentifier())) || (PurapConstants.PaymentRequestStatuses.APPDOC_IN_PROCESS.equals(paymentRequestDocument.getApplicationDocumentStatus()))) {
        // RICE20 : needed? :  !purapService.isFullDocumentEntryCompleted(item.getPaymentRequest())) {
        if ((item.getItemType().isAmountBasedGeneralLedgerIndicator()) && ((item.getExtendedPrice() != null) && item.getExtendedPrice().isNonZero())) {
            if (item.getPoOutstandingAmount() == null || item.getPoOutstandingAmount().isZero()) {
                valid = false;
                errorMap.putError(PurapConstants.ITEM_TAB_ERRORS, PurapKeyConstants.ERROR_ITEM_AMOUNT_ALREADY_PAID, identifierString);
            }
        }
    }
    return valid;
}
Also used : MessageMap(org.kuali.kfs.krad.util.MessageMap)

Example 10 with MessageMap

use of org.kuali.kfs.krad.util.MessageMap in project cu-kfs by CU-CommunityApps.

the class WebUtils method reuseErrorMapFromPreviousRequest.

public static void reuseErrorMapFromPreviousRequest(KualiDocumentFormBase kualiDocumentFormBase) {
    if (kualiDocumentFormBase.getMessageMapFromPreviousRequest() == null) {
        LOG.error("Error map from previous request is null!");
        return;
    }
    MessageMap errorMapFromGlobalVariables = GlobalVariables.getMessageMap();
    if (kualiDocumentFormBase.getMessageMapFromPreviousRequest() == errorMapFromGlobalVariables) {
        // if we've switched them already, then return early and do nothing
        return;
    }
    if (!errorMapFromGlobalVariables.hasNoErrors()) {
        throw new RuntimeException("Cannot replace error map because it is not empty");
    }
    GlobalVariables.setMessageMap(kualiDocumentFormBase.getMessageMapFromPreviousRequest());
    GlobalVariables.getMessageMap().clearErrorPath();
}
Also used : MessageMap(org.kuali.kfs.krad.util.MessageMap)

Aggregations

MessageMap (org.kuali.kfs.krad.util.MessageMap)25 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)5 UserSession (org.kuali.kfs.krad.UserSession)4 Person (org.kuali.rice.kim.api.identity.Person)4 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)3 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)3 ValidationException (org.kuali.kfs.krad.exception.ValidationException)3 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)3 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)3 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)2 CuVendorCreditMemoDocument (edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 DisbursementVoucherPayeeDetail (org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail)2 MaintenanceDocument (org.kuali.kfs.krad.maintenance.MaintenanceDocument)2 DocumentService (org.kuali.kfs.krad.service.DocumentService)2 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)2 PurchasingDocument (org.kuali.kfs.module.purap.document.PurchasingDocument)2 VendorCreditMemoDocument (org.kuali.kfs.module.purap.document.VendorCreditMemoDocument)2 ParseException (org.kuali.kfs.sys.exception.ParseException)2