Search in sources :

Example 1 with DictionaryValidationService

use of org.kuali.kfs.kns.service.DictionaryValidationService in project cu-kfs by CU-CommunityApps.

the class FinancialSystemSearchableAttribute method validateDocumentAttributeCriteria.

@Override
public List<RemotableAttributeError> validateDocumentAttributeCriteria(ExtensionDefinition extensionDefinition, DocumentSearchCriteria documentSearchCriteria) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("validateDocumentAttributeCriteria( " + extensionDefinition + ", " + documentSearchCriteria + " )");
    }
    // this list is irrelevant. the validation errors are put on the stack in the validationService.
    List<RemotableAttributeError> errors = super.validateDocumentAttributeCriteria(extensionDefinition, documentSearchCriteria);
    DictionaryValidationService validationService = SpringContext.getBean(DictionaryValidationService.class);
    Map<String, List<String>> paramMap = documentSearchCriteria.getDocumentAttributeValues();
    for (String key : paramMap.keySet()) {
        List<String> values = paramMap.get(key);
        if (values != null && !values.isEmpty()) {
            for (String value : values) {
                if (!StringUtils.isEmpty(value)) {
                    if (magicFields.containsKey(key)) {
                        validationService.validateAttributeFormat(magicFields.get(key), key, value, key);
                    }
                }
            }
        }
    }
    retrieveValidationErrorsFromGlobalVariables(errors);
    return errors;
}
Also used : DictionaryValidationService(org.kuali.kfs.kns.service.DictionaryValidationService) RemotableAttributeError(org.kuali.rice.core.api.uif.RemotableAttributeError) List(java.util.List) ArrayList(java.util.ArrayList) DocumentAttributeString(org.kuali.rice.kew.api.document.attribute.DocumentAttributeString)

Example 2 with DictionaryValidationService

use of org.kuali.kfs.kns.service.DictionaryValidationService in project cu-kfs by CU-CommunityApps.

the class KualiAccountingDocumentActionBase method isValidSalesTaxEntered.

/**
 * This method checks to see if the sales tax information was put into the accounting line
 *
 * @param accountingLine
 * @return true if entered correctly, false otherwise
 */
protected boolean isValidSalesTaxEntered(AccountingLine accountingLine, boolean source, boolean newLine, int index) {
    boolean valid = true;
    DictionaryValidationService dictionaryValidationService = SpringContext.getBean(DictionaryValidationService.class);
    BusinessObjectService boService = SpringContext.getBean(BusinessObjectService.class);
    String objCd = accountingLine.getFinancialObjectCode();
    String account = accountingLine.getAccountNumber();
    SalesTax salesTax = accountingLine.getSalesTax();
    String pathPrefix = "";
    if (source && !newLine) {
        pathPrefix = "document." + KFSConstants.EXISTING_SOURCE_ACCT_LINE_PROPERTY_NAME + "[" + index + "]";
    } else if (!source && !newLine) {
        pathPrefix = "document." + KFSConstants.EXISTING_TARGET_ACCT_LINE_PROPERTY_NAME + "[" + index + "]";
    } else if (source && newLine) {
        pathPrefix = KFSConstants.NEW_SOURCE_ACCT_LINE_PROPERTY_NAME;
    } else if (!source && newLine) {
        pathPrefix = KFSConstants.NEW_TARGET_ACCT_LINE_PROPERTY_NAME;
    }
    GlobalVariables.getMessageMap().addToErrorPath(pathPrefix);
    if (ObjectUtils.isNull(salesTax)) {
        valid &= false;
        GlobalVariables.getMessageMap().putError("salesTax.chartOfAccountsCode", ERROR_DOCUMENT_ACCOUNTING_LINE_SALES_TAX_REQUIRED, account, objCd);
    } else {
        if (StringUtils.isBlank(salesTax.getChartOfAccountsCode())) {
            valid &= false;
            GlobalVariables.getMessageMap().putError("salesTax.chartOfAccountsCode", ERROR_REQUIRED, "Chart of Accounts");
        }
        if (StringUtils.isBlank(salesTax.getAccountNumber())) {
            valid &= false;
            GlobalVariables.getMessageMap().putError("salesTax.accountNumber", ERROR_REQUIRED, "Account Number");
        }
        if (salesTax.getFinancialDocumentGrossSalesAmount() == null) {
            valid &= false;
            GlobalVariables.getMessageMap().putError("salesTax.financialDocumentGrossSalesAmount", ERROR_REQUIRED, "Gross Sales Amount");
        }
        if (salesTax.getFinancialDocumentTaxableSalesAmount() == null) {
            valid &= false;
            GlobalVariables.getMessageMap().putError("salesTax.financialDocumentTaxableSalesAmount", ERROR_REQUIRED, "Taxable Sales Amount");
        }
        if (salesTax.getFinancialDocumentSaleDate() == null) {
            valid &= false;
            GlobalVariables.getMessageMap().putError("salesTax.financialDocumentSaleDate", ERROR_REQUIRED, "Sale Date");
        }
        if (StringUtils.isNotBlank(salesTax.getChartOfAccountsCode()) && StringUtils.isNotBlank(salesTax.getAccountNumber())) {
            if (boService.getReferenceIfExists(salesTax, "account") == null) {
                valid &= false;
                GlobalVariables.getMessageMap().putError("salesTax.accountNumber", ERROR_DOCUMENT_ACCOUNTING_LINE_SALES_TAX_INVALID_ACCOUNT, salesTax.getChartOfAccountsCode(), salesTax.getAccountNumber());
            }
        }
        if (!valid) {
            GlobalVariables.getMessageMap().putError("salesTax.chartOfAccountsCode", ERROR_DOCUMENT_ACCOUNTING_LINE_SALES_TAX_REQUIRED, account, objCd);
        }
    }
    GlobalVariables.getMessageMap().removeFromErrorPath(pathPrefix);
    return valid;
}
Also used : DictionaryValidationService(org.kuali.kfs.kns.service.DictionaryValidationService) SalesTax(org.kuali.kfs.fp.businessobject.SalesTax) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 3 with DictionaryValidationService

use of org.kuali.kfs.kns.service.DictionaryValidationService in project cu-kfs by CU-CommunityApps.

the class AccountGlobalRule method checkContractControlAccountNumberRequired.

/**
 * This method checks to make sure that if the contract control account exists it is the same as the Account that we are working
 * on
 *
 * @param newAccount
 * @return false if the contract control account is entered and is not the same as the account we are maintaining
 */
protected boolean checkContractControlAccountNumberRequired(CuAccountGlobal newAccount) {
    boolean result = true;
    if (ObjectUtils.isNull(newAccount.getContractControlFinCoaCode())) {
        return result;
    }
    if (ObjectUtils.isNull(newAccount.getContractControlAccountNumber())) {
        return result;
    }
    // if no account global details exist then don't validate
    if (ObjectUtils.isNull(newAccount.getAccountGlobalDetails()) || newAccount.getAccountGlobalDetails().size() == 0) {
        return true;
    }
    if (newAccount.getAccountGlobalDetails().size() == 1) {
        if ((newAccount.getContractControlFinCoaCode().equals(newAccount.getChartOfAccountsCode())) && (newAccount.getContractControlAccountNumber().equals(newAccount.getAccountGlobalDetails().get(0).getAccountNumber()))) {
            return true;
        }
    }
    // do an existence/active test
    DictionaryValidationService dvService = super.getDictionaryValidationService();
    boolean referenceExists = dvService.validateReferenceExists(newAccount, KFSPropertyConstants.CONTRACT_CONTROL_ACCOUNT);
    if (!referenceExists) {
        putFieldError(KFSPropertyConstants.CONTRACT_CONTROL_ACCOUNT_NUMBER, KFSKeyConstants.ERROR_EXISTENCE, "Contract Control Account: " + newAccount.getContractControlFinCoaCode() + "-" + newAccount.getContractControlAccountNumber());
        result &= false;
    }
    return result;
}
Also used : DictionaryValidationService(org.kuali.kfs.kns.service.DictionaryValidationService)

Example 4 with DictionaryValidationService

use of org.kuali.kfs.kns.service.DictionaryValidationService in project cu-kfs by CU-CommunityApps.

the class AccountGlobalRule method checkContinuationAccount.

/**
 * This method validates that a continuation account is required and that the values provided exist
 *
 * @param document An instance of the maintenance document being validated.
 * @param newExpDate The expiration date assigned to the account being validated for submission.
 * @return True if the continuation account values are valid for the associated account, false otherwise.
 */
protected boolean checkContinuationAccount(MaintenanceDocument document, Date newExpDate) {
    LOG.info("checkContinuationAccount called");
    boolean result = true;
    boolean continuationAccountIsValid = true;
    // make sure both coaCode and accountNumber are filled out
    if (ObjectUtils.isNotNull(newExpDate)) {
        if (!checkEmptyValue(newAccountGlobal.getContinuationAccountNumber())) {
            putFieldError("continuationAccountNumber", KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_CONTINUATION_ACCT_REQD_IF_EXP_DATE_COMPLETED);
            continuationAccountIsValid = false;
        }
        if (!checkEmptyValue(newAccountGlobal.getContinuationFinChrtOfAcctCd())) {
            putFieldError("continuationFinChrtOfAcctCd", KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_CONTINUATION_FINCODE_REQD_IF_EXP_DATE_COMPLETED);
            continuationAccountIsValid = false;
        }
    }
    // if both fields aren't present, then we're done
    if (continuationAccountIsValid && ObjectUtils.isNotNull(newAccountGlobal.getContinuationAccountNumber()) && ObjectUtils.isNotNull(newAccountGlobal.getContinuationFinChrtOfAcctCd())) {
        // do an existence/active test
        DictionaryValidationService dvService = super.getDictionaryValidationService();
        boolean referenceExists = dvService.validateReferenceExists(newAccountGlobal, "continuationAccount");
        if (!referenceExists) {
            putFieldError("continuationAccountNumber", KFSKeyConstants.ERROR_EXISTENCE, "Continuation Account: " + newAccountGlobal.getContinuationFinChrtOfAcctCd() + "-" + newAccountGlobal.getContinuationAccountNumber());
            continuationAccountIsValid = false;
        }
    }
    if (continuationAccountIsValid) {
        result = true;
    } else {
        List<AccountGlobalDetail> gAcctDetails = newAccountGlobal.getAccountGlobalDetails();
        for (AccountGlobalDetail detail : gAcctDetails) {
            if (null != detail.getAccountNumber() && null != newAccountGlobal.getContinuationAccountNumber()) {
                result &= detail.getAccountNumber().equals(newAccountGlobal.getContinuationAccountNumber());
                result &= detail.getChartOfAccountsCode().equals(newAccountGlobal.getContinuationFinChrtOfAcctCd());
            }
        }
    }
    return result;
}
Also used : DictionaryValidationService(org.kuali.kfs.kns.service.DictionaryValidationService) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail)

Example 5 with DictionaryValidationService

use of org.kuali.kfs.kns.service.DictionaryValidationService in project cu-kfs by CU-CommunityApps.

the class AccountGlobalRule method checkContractControlAccountNumberRequired.

/**
 * This method checks to make sure that if the contract control account exists it is the same as the Account that we are working
 * on
 *
 * @param newAccount
 * @return false if the contract control account is entered and is not the same as the account we are maintaining
 */
protected boolean checkContractControlAccountNumberRequired(CuAccountGlobal newAccount, Account oldAccount) {
    boolean result = true;
    if (ObjectUtils.isNull(newAccount.getContractControlFinCoaCode())) {
        return result;
    }
    if (ObjectUtils.isNull(newAccount.getContractControlAccountNumber())) {
        return result;
    }
    // do an existence/active test
    DictionaryValidationService dvService = super.getDictionaryValidationService();
    boolean referenceExists = dvService.validateReferenceExists(newAccount, KFSPropertyConstants.CONTRACT_CONTROL_ACCOUNT);
    if (!referenceExists) {
        putFieldError(KFSPropertyConstants.CONTRACT_CONTROL_ACCOUNT_NUMBER, KFSKeyConstants.ERROR_EXISTENCE, "Contract Control Account: " + newAccount.getContractControlFinCoaCode() + "-" + newAccount.getContractControlAccountNumber());
        result &= false;
    }
    return result;
}
Also used : DictionaryValidationService(org.kuali.kfs.kns.service.DictionaryValidationService)

Aggregations

DictionaryValidationService (org.kuali.kfs.kns.service.DictionaryValidationService)6 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AccountGlobalDetail (org.kuali.kfs.coa.businessobject.AccountGlobalDetail)1 SalesTax (org.kuali.kfs.fp.businessobject.SalesTax)1 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)1 RemotableAttributeError (org.kuali.rice.core.api.uif.RemotableAttributeError)1 DocumentAttributeString (org.kuali.rice.kew.api.document.attribute.DocumentAttributeString)1