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;
}
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;
}
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;
}
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;
}
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();
}
Aggregations