use of org.kuali.kfs.krad.util.MessageMap in project cu-kfs by CU-CommunityApps.
the class FavoriteAccountLineBuilderTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
userProcurementProfileValidationService = new UserProcurementProfileValidationServiceImpl();
userFavoriteAccountService = new ExtendedTestUserFavoriteAccountService();
reqsAccounts = new ArrayList<PurApAccountingLine>();
poAccounts = new ArrayList<PurApAccountingLine>();
reqsItem = new RequisitionItem();
poItem = new PurchaseOrderItem();
reqsDoc = getMockedDocument(CuRequisitionDocument.class);
poDoc = getMockedDocument(PurchaseOrderDocument.class);
iwntDoc = getMockedDocument(IWantDocument.class);
iwntDoc.setAccounts(new ArrayList<IWantAccount>());
// Favorite Account with only some fields populated.
testFavoriteAccount = new FavoriteAccount();
testFavoriteAccount.setAccountLineIdentifier(TEST_FAVORITE_ACCOUNT_LINE_ID);
testFavoriteAccount.setUserProfileId(TEST_USER_PROFILE_ID);
testFavoriteAccount.setChartOfAccountsCode(TEST_CHART_CODE);
testFavoriteAccount.setAccountNumber(TEST_ACCOUNT_NUMBER);
testFavoriteAccount.setFinancialObjectCode(TEST_OBJECT_CODE);
// Favorite Account with all fields populated (except reference objects or object ID or version number).
testAltFavoriteAccount = new FavoriteAccount();
testAltFavoriteAccount.setAccountLineIdentifier(TEST_ALT_FAVORITE_ACCOUNT_LINE_ID);
testAltFavoriteAccount.setUserProfileId(TEST_ALT_USER_PROFILE_ID);
testAltFavoriteAccount.setChartOfAccountsCode(TEST_ALT_CHART_CODE);
testAltFavoriteAccount.setAccountNumber(TEST_ALT_ACCOUNT_NUMBER);
testAltFavoriteAccount.setSubAccountNumber(TEST_ALT_SUB_ACCOUNT_NUMBER);
testAltFavoriteAccount.setFinancialObjectCode(TEST_ALT_OBJECT_CODE);
testAltFavoriteAccount.setFinancialSubObjectCode(TEST_ALT_SUB_OBJECT_CODE);
testAltFavoriteAccount.setProjectCode(TEST_ALT_PROJECT_CODE);
testAltFavoriteAccount.setOrganizationReferenceId(TEST_ALT_ORG_REF_ID);
GlobalVariables.setMessageMap(new MessageMap());
}
use of org.kuali.kfs.krad.util.MessageMap 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;
}
use of org.kuali.kfs.krad.util.MessageMap in project cu-kfs by CU-CommunityApps.
the class CuPurchasingProcessVendorValidation method validate.
@Override
public boolean validate(AttributedDocumentEvent event) {
boolean valid = true;
PurchasingDocument purDocument = (PurchasingDocument) event.getDocument();
MessageMap errorMap = GlobalVariables.getMessageMap();
errorMap.clearErrorPath();
errorMap.addToErrorPath(PurapConstants.VENDOR_ERRORS);
if (!purDocument.getRequisitionSourceCode().equals(PurapConstants.RequisitionSources.B2B)) {
// CU enhancement here. Replaced foundation implementation block
if ((purDocument.getVendorHeaderGeneratedIdentifier() != null) && (!(isDocumentInNodeWhereMopotDataValidationIsBypassed(purDocument))) && (purDocument.getPurchaseOrderTransmissionMethodCode().equals(CUPurapConstants.POTransmissionMethods.EMAIL) || purDocument.getPurchaseOrderTransmissionMethodCode().equals(PurapConstants.POTransmissionMethods.FAX) || purDocument.getPurchaseOrderTransmissionMethodCode().equals(CUPurapConstants.POTransmissionMethods.MANUAL))) {
valid &= this.validateDataForMethodOfPOTransmissionExistsOnVendorAddress(purDocument);
// called routine took care of presenting error message to user
}
}
VendorDetail vendorDetail = getVendorService().getVendorDetail(purDocument.getVendorHeaderGeneratedIdentifier(), purDocument.getVendorDetailAssignedIdentifier());
if (ObjectUtils.isNull(vendorDetail)) {
return valid;
}
VendorHeader vendorHeader = vendorDetail.getVendorHeader();
// make sure that the vendor is not debarred
if (vendorDetail.isVendorDebarred()) {
if (getParameterService().getParameterValueAsBoolean(KFSConstants.OptionalModuleNamespaces.PURCHASING_ACCOUNTS_PAYABLE, "Requisition", PurapParameterConstants.SHOW_DEBARRED_VENDOR_WARNING_IND)) {
if (StringUtils.isEmpty(((PurchasingDocumentBase) purDocument).getJustification())) {
errorMap.putWarning(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.WARNING_DEBARRED_VENDOR, vendorDetail.getVendorName());
valid &= false;
}
} else {
errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_DEBARRED_VENDOR);
valid &= false;
}
}
// make sure that the vendor is of allowed type
List<String> allowedVendorTypes = new ArrayList<String>(getParameterService().getParameterValuesAsString(KfsParameterConstants.PURCHASING_DOCUMENT.class, PurapRuleConstants.PURAP_VENDOR_TYPE_ALLOWED_ON_REQ_AND_PO));
if (allowedVendorTypes != null && !allowedVendorTypes.isEmpty()) {
if (ObjectUtils.isNotNull(vendorHeader) && ObjectUtils.isNotNull(vendorHeader.getVendorTypeCode()) && !allowedVendorTypes.contains(vendorHeader.getVendorTypeCode())) {
valid &= false;
errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_INVALID_VENDOR_TYPE);
}
}
// make sure that the vendor is active
if (!vendorDetail.isActiveIndicator()) {
valid &= false;
errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_INACTIVE_VENDOR);
}
// make sure that the vendor contract is active and not expired.
// KFSUPGRADE-266 remove kfsmi-8690/kfscntrb-929
// if (ObjectUtils.isNotNull(purDocument.getVendorContractGeneratedIdentifier())) {
// VendorContract vendorContract = SpringContext.getBean(BusinessObjectService.class).findBySinglePrimaryKey(VendorContract.class, purDocument.getVendorContractGeneratedIdentifier());
// Date currentDate = SpringContext.getBean(DateTimeService.class).getCurrentSqlDate();
//
// if (currentDate.compareTo(vendorContract.getVendorContractEndDate()) > 0 || !vendorContract.isActive()) {
// valid &= false;
// errorMap.putError(VendorPropertyConstants.VENDOR_CONTRACT_NAME, PurapKeyConstants.ERROR_INACTIVE_OR_EXPIRED_VENDOR_CONTRACT);
// }
// }
// validate vendor address
getPostalCodeValidationService().validateAddress(purDocument.getVendorCountryCode(), purDocument.getVendorStateCode(), purDocument.getVendorPostalCode(), PurapPropertyConstants.VENDOR_STATE_CODE, PurapPropertyConstants.VENDOR_POSTAL_CODE);
errorMap.clearErrorPath();
return valid;
}
use of org.kuali.kfs.krad.util.MessageMap in project cu-kfs by CU-CommunityApps.
the class CuPaymentRequestTaxAreaValidation method validateTaxRates.
protected boolean validateTaxRates(PaymentRequestDocument preq) {
boolean valid = true;
String code = preq.getTaxClassificationCode();
BigDecimal fedrate = preq.getTaxFederalPercent();
BigDecimal strate = preq.getTaxStatePercent();
MessageMap errorMap = GlobalVariables.getMessageMap();
// only test the cases when income class and tax rates aren't empty/N
if (StringUtils.isEmpty(code) || StringUtils.equalsIgnoreCase(code, "N") || fedrate == null || strate == null) {
return true;
}
// validate that the federal and state tax rates are among the allowed set
// (ArrayList<BigDecimal>) federalTaxRates.get(code);
ArrayList<BigDecimal> fedrates = retrieveTaxRates(code, "F");
if (!listContainsValue(fedrates, fedrate)) {
valid = false;
errorMap.putError(PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_VALUE_INVALID_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_FEDERAL_PERCENT);
}
// (ArrayList<BigDecimal>) stateTaxRates.get(code);
ArrayList<BigDecimal> strates = retrieveTaxRates(code, "S");
if (!listContainsValue(strates, strate)) {
valid = false;
errorMap.putError(PurapPropertyConstants.TAX_STATE_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_VALUE_INVALID_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_STATE_PERCENT);
}
// validate that the federal and state tax rate abide to certain relationship
if (fedrate.compareTo(new BigDecimal(0)) == 0 && strate.compareTo(new BigDecimal(0)) != 0) {
valid = false;
errorMap.putError(PurapPropertyConstants.TAX_STATE_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_RATE_MUST_ZERO_IF, PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapPropertyConstants.TAX_STATE_PERCENT);
}
return valid;
}
use of org.kuali.kfs.krad.util.MessageMap in project cu-kfs by CU-CommunityApps.
the class CuPurchaseOrderProcessVendorValidation method validate.
@Override
public boolean validate(AttributedDocumentEvent event) {
boolean valid = super.validate(event);
PurchasingAccountsPayableDocument purapDocument = (PurchasingAccountsPayableDocument) event.getDocument();
PurchaseOrderDocument poDocument = (PurchaseOrderDocument) purapDocument;
MessageMap errorMap = GlobalVariables.getMessageMap();
errorMap.clearErrorPath();
errorMap.addToErrorPath(PurapConstants.VENDOR_ERRORS);
// check to see if the vendor exists in the database, i.e. its ID is not null
Integer vendorHeaderID = poDocument.getVendorHeaderGeneratedIdentifier();
if (ObjectUtils.isNull(vendorHeaderID)) {
valid = false;
errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_NONEXIST_VENDOR);
}
// vendor active validation...
VendorDetail vendorDetail = super.getVendorService().getVendorDetail(poDocument.getVendorHeaderGeneratedIdentifier(), poDocument.getVendorDetailAssignedIdentifier());
if (ObjectUtils.isNull(vendorDetail)) {
return valid;
}
// make sure that the vendor is active
if (!vendorDetail.isActiveIndicator()) {
valid &= false;
errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_INACTIVE_VENDOR);
}
// validate vendor address
super.getPostalCodeValidationService().validateAddress(poDocument.getVendorCountryCode(), poDocument.getVendorStateCode(), poDocument.getVendorPostalCode(), PurapPropertyConstants.VENDOR_STATE_CODE, PurapPropertyConstants.VENDOR_POSTAL_CODE);
// Do checks for alternate payee vendor.
Integer alternateVendorHdrGeneratedId = poDocument.getAlternateVendorHeaderGeneratedIdentifier();
Integer alternateVendorHdrDetailAssignedId = poDocument.getAlternateVendorDetailAssignedIdentifier();
VendorDetail alternateVendor = super.getVendorService().getVendorDetail(alternateVendorHdrGeneratedId, alternateVendorHdrDetailAssignedId);
if (alternateVendor != null) {
if (alternateVendor.isVendorDebarred()) {
errorMap.putError(PurapPropertyConstants.ALTERNATE_VENDOR_NAME, PurapKeyConstants.ERROR_PURCHASE_ORDER_ALTERNATE_VENDOR_DEBARRED);
valid &= false;
}
if (StringUtils.equals(alternateVendor.getVendorHeader().getVendorTypeCode(), VendorTypes.DISBURSEMENT_VOUCHER)) {
errorMap.putError(PurapPropertyConstants.ALTERNATE_VENDOR_NAME, PurapKeyConstants.ERROR_PURCHASE_ORDER_ALTERNATE_VENDOR_DV_TYPE);
valid &= false;
}
if (!alternateVendor.isActiveIndicator()) {
errorMap.putError(PurapPropertyConstants.ALTERNATE_VENDOR_NAME, PurapKeyConstants.ERROR_PURCHASE_ORDER_ALTERNATE_VENDOR_INACTIVE, PODocumentsStrings.ALTERNATE_PAYEE_VENDOR);
valid &= false;
}
}
// make sure that the vendor contract expiration date and not marked inactive.
// KFSUPGRADE-266 remove kfsmi-8690/kfscntrb-929
// if (StringUtils.isNotBlank(poDocument.getVendorContractName())) {
// if (super.getVendorService().isVendorContractExpired(poDocument, poDocument.getVendorContractGeneratedIdentifier(), vendorDetail)) {
// errorMap.putError(VendorPropertyConstants.VENDOR_CONTRACT_END_DATE, PurapKeyConstants.ERROR_EXPIRED_CONTRACT_END_DATE);
// valid &= false;
// }
// }
errorMap.clearErrorPath();
return valid;
}
Aggregations