Search in sources :

Example 6 with ParameterEvaluator

use of org.kuali.kfs.core.api.parameter.ParameterEvaluator in project cu-kfs by CU-CommunityApps.

the class WebServiceCredentialAuthorizer method canMaintain.

@Override
public boolean canMaintain(Object dataObject, Person user) {
    if (!super.canMaintain(dataObject, user)) {
        return false;
    }
    WebServiceCredential webServiceCredential = (WebServiceCredential) dataObject;
    ParameterEvaluator parameterEvaluator = getParameterEvaluatorService().getParameterEvaluator(WebServiceCredential.class, CUKFSParameterKeyConstants.NON_EDITABLE_CREDENTIAL_VALUES, webServiceCredential.getCredentialGroupCode(), webServiceCredential.getCredentialKey());
    return !parameterEvaluator.evaluationSucceeds();
}
Also used : WebServiceCredential(edu.cornell.kfs.sys.businessobject.WebServiceCredential) ParameterEvaluator(org.kuali.kfs.core.api.parameter.ParameterEvaluator)

Example 7 with ParameterEvaluator

use of org.kuali.kfs.core.api.parameter.ParameterEvaluator in project cu-kfs by CU-CommunityApps.

the class AccountGlobalRule method checkSubFundGroup.

/**
 * This method checks to see if any SubFund Group rules were violated Specifically: if SubFundGroup is empty or not "PFCMR" we
 * cannot have a campus code or building code if SubFundGroup is "PFCMR" then campus code and building code "must" be entered
 * and be valid codes
 *
 * @param maintenanceDocument
 * @return false on rules violation
 */
protected boolean checkSubFundGroup(AccountGlobalDetail detail) {
    LOG.info("checkSubFundGroup called");
    boolean success = true;
    String subFundGroupCode = newAccountGlobal.getSubFundGroupCode();
    Account account = detail.getAccount();
    String errorPath = KFSPropertyConstants.ACCOUNT_CHANGE_DETAILS;
    if (account.getAccountDescription() != null) {
        String campusCode = account.getAccountDescription().getCampusCode();
        String buildingCode = account.getAccountDescription().getBuildingCode();
        // check if sub fund group code is blank
        if (StringUtils.isBlank(subFundGroupCode)) {
            // check if campus code and building code are NOT blank
            if (StringUtils.isNotBlank(campusCode) || StringUtils.isNotBlank(buildingCode)) {
                // if sub_fund_grp_cd is blank, campus code should NOT be entered
                if (StringUtils.isNotBlank(campusCode)) {
                    putFieldError(errorPath, COAKeyConstants.ERROR_DOCUMENT_ACCMAINT_BLANK_SUBFUNDGROUP_WITH_CAMPUS_CD_FOR_BLDG, subFundGroupCode);
                    success &= false;
                }
                // if sub_fund_grp_cd is blank, then bldg_cd should NOT be entered
                if (StringUtils.isNotBlank(buildingCode)) {
                    putFieldError(errorPath, COAKeyConstants.ERROR_DOCUMENT_ACCMAINT_BLANK_SUBFUNDGROUP_WITH_BUILDING_CD, subFundGroupCode);
                    success &= false;
                }
            } else {
                // if all sub fund group, campus code, building code are all blank return true
                return success;
            }
        } else if (StringUtils.isNotBlank(subFundGroupCode) && ObjectUtils.isNotNull(account.getSubFundGroup())) {
            // Attempt to get the right SubFundGroup code to check the following logic with. If the value isn't available, go
            // ahead
            // and die, as this indicates a mis-configured application, and important business rules wont be implemented without it.
            ParameterEvaluator evaluator = /*REFACTORME*/
            SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(Account.class, ACCT_CAPITAL_SUBFUNDGROUP, subFundGroupCode.trim());
            if (evaluator.evaluationSucceeds()) {
                // if sub_fund_grp_cd is 'PFCMR' then campus_cd must be entered
                if (StringUtils.isBlank(campusCode)) {
                    putFieldError(errorPath, COAKeyConstants.ERROR_DOCUMENT_ACCMAINT_CAMS_SUBFUNDGROUP_WITH_MISSING_CAMPUS_CD_FOR_BLDG, subFundGroupCode);
                    success &= false;
                }
                // if sub_fund_grp_cd is 'PFCMR' then bldg_cd must be entered
                if (StringUtils.isBlank(buildingCode)) {
                    putFieldError(errorPath, COAKeyConstants.ERROR_DOCUMENT_ACCMAINT_CAMS_SUBFUNDGROUP_WITH_MISSING_BUILDING_CD, subFundGroupCode);
                    success &= false;
                }
            } else {
                // if sub_fund_grp_cd is NOT 'PFCMR', campus code should NOT be entered
                if (StringUtils.isNotBlank(campusCode)) {
                    putFieldError(KFSPropertyConstants.ACCOUNT_DESCRIPTION + "." + KFSPropertyConstants.CAMPUS_CODE, COAKeyConstants.ERROR_DOCUMENT_ACCMAINT_NONCAMS_SUBFUNDGROUP_WITH_CAMPUS_CD_FOR_BLDG, subFundGroupCode);
                    success &= false;
                }
                // if sub_fund_grp_cd is NOT 'PFCMR' then bldg_cd should NOT be entered
                if (StringUtils.isNotBlank(buildingCode)) {
                    putFieldError(KFSPropertyConstants.ACCOUNT_DESCRIPTION + "." + KFSPropertyConstants.BUILDING_CODE, COAKeyConstants.ERROR_DOCUMENT_ACCMAINT_NONCAMS_SUBFUNDGROUP_WITH_BUILDING_CD, subFundGroupCode);
                    success &= false;
                }
            }
        }
    }
    return success;
}
Also used : AppropriationAccount(edu.cornell.kfs.coa.businessobject.AppropriationAccount) Account(org.kuali.kfs.coa.businessobject.Account) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) ParameterEvaluator(org.kuali.kfs.core.api.parameter.ParameterEvaluator)

Example 8 with ParameterEvaluator

use of org.kuali.kfs.core.api.parameter.ParameterEvaluator in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherDocument method templateEmployee.

/**
 * Convenience method to set dv payee detail fields based on a given Employee.
 *
 * @param employee
 */
public void templateEmployee(Person employee) {
    if (employee == null) {
        return;
    }
    this.getDvPayeeDetail().setDisbursementVoucherPayeeTypeCode(KFSConstants.PaymentPayeeTypes.EMPLOYEE);
    this.getDvPayeeDetail().setDisbVchrPayeeIdNumber(employee.getEmployeeId());
    this.getDvPayeeDetail().setDisbVchrPayeePersonName(employee.getName());
    final ParameterService parameterService = this.getParameterService();
    if (parameterService.parameterExists(DisbursementVoucherDocument.class, FPParameterConstants.USE_DEFAULT_EMPLOYEE_ADDRESS) && parameterService.getParameterValueAsBoolean(DisbursementVoucherDocument.class, FPParameterConstants.USE_DEFAULT_EMPLOYEE_ADDRESS)) {
        this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(employee.getAddressLine1Unmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(employee.getAddressLine2Unmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeCityName(employee.getAddressCityUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeStateCode(employee.getAddressStateProvinceCodeUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeZipCode(employee.getAddressPostalCodeUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(employee.getAddressCountryCodeUnmasked());
    } else {
        final EntityAddress address = getNonDefaultAddress(employee);
        if (address != null) {
            this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(address.getLine1Unmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(address.getLine2Unmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeCityName(address.getCityUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeStateCode(address.getStateProvinceCodeUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeZipCode(address.getPostalCodeUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(address.getCountryCodeUnmasked());
        } else {
            this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr("");
            this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr("");
            this.getDvPayeeDetail().setDisbVchrPayeeCityName("");
            this.getDvPayeeDetail().setDisbVchrPayeeStateCode("");
            this.getDvPayeeDetail().setDisbVchrPayeeZipCode("");
            this.getDvPayeeDetail().setDisbVchrPayeeCountryCode("");
        }
    }
    // "Is this payee an employee" = No
    if (employee.isActive()) {
        this.getDvPayeeDetail().setDisbVchrPayeeEmployeeCode(true);
    } else {
        this.getDvPayeeDetail().setDisbVchrPayeeEmployeeCode(false);
    }
    // I'm assuming that if a tax id type code other than 'TAX' is present, then the employee must be foreign
    for (String externalIdentifierTypeCode : employee.getExternalIdentifiers().keySet()) {
        if (KimConstants.PersonExternalIdentifierTypes.TAX.equals(externalIdentifierTypeCode)) {
            this.getDvPayeeDetail().setDisbVchrNonresidentPaymentCode(false);
        }
    }
    // Determine if employee is a research subject
    ParameterEvaluator researchPaymentReasonCodeEvaluator = /*REFACTORME*/
    SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(DisbursementVoucherDocument.class, FPParameterConstants.RESEARCH_PAYMENT_REASONS, this.getDvPayeeDetail().getDisbVchrPaymentReasonCode());
    if (researchPaymentReasonCodeEvaluator.evaluationSucceeds()) {
        if (getParameterService().parameterExists(DisbursementVoucherDocument.class, FPParameterConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT)) {
            String researchPayLimit = getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, FPParameterConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT);
            if (StringUtils.isNotBlank(researchPayLimit)) {
                KualiDecimal payLimit = new KualiDecimal(researchPayLimit);
                if (getDisbVchrCheckTotalAmount().isLessThan(payLimit)) {
                    this.getDvPayeeDetail().setDvPayeeSubjectPaymentCode(true);
                }
            }
        }
    }
    this.disbVchrPayeeTaxControlCode = "";
    this.disbVchrPayeeW9CompleteCode = true;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) EntityAddress(org.kuali.kfs.kim.impl.identity.address.EntityAddress) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) ParameterEvaluator(org.kuali.kfs.core.api.parameter.ParameterEvaluator) ParameterEvaluatorService(org.kuali.kfs.core.api.parameter.ParameterEvaluatorService)

Example 9 with ParameterEvaluator

use of org.kuali.kfs.core.api.parameter.ParameterEvaluator in project cu-kfs by CU-CommunityApps.

the class GlLineServiceImpl method createAssetGlobal.

/**
 * Creates asset global
 *
 * @param entry    GeneralLedgerEntry
 * @param maintDoc MaintenanceDocument
 * @return AssetGlobal
 */
protected AssetGlobal createAssetGlobal(GeneralLedgerEntry entry, MaintenanceDocument maintDoc) {
    AssetGlobal assetGlobal = new AssetGlobal();
    assetGlobal.setOrganizationOwnerChartOfAccountsCode(entry.getChartOfAccountsCode());
    assetGlobal.setOrganizationOwnerAccountNumber(entry.getAccountNumber());
    assetGlobal.setDocumentNumber(maintDoc.getDocumentNumber());
    assetGlobal.setConditionCode(CamsConstants.Asset.CONDITION_CODE_E);
    // year end changes
    String docType = DocumentTypeName.ASSET_ADD_GLOBAL;
    ParameterEvaluator evaluator = parameterEvaluatorService.getParameterEvaluator(KFSConstants.CoreModuleNamespaces.KFS, KfsParameterConstants.YEAR_END_ACCOUNTING_PERIOD_PARAMETER_NAMES.DETAIL_PARAMETER_TYPE, KfsParameterConstants.YEAR_END_ACCOUNTING_PERIOD_PARAMETER_NAMES.FISCAL_PERIOD_SELECTION_DOCUMENT_TYPES, docType);
    if (evaluator.evaluationSucceeds()) {
        Integer closingYear = Integer.valueOf(parameterService.getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, GLParameterConstants.ANNUAL_CLOSING_FISCAL_YEAR));
        if (entry.getUniversityFiscalYear().equals(closingYear + 1)) {
            // default asset global year end accounting period drop down to current period instead of closing
            // period(period 13)
            assetGlobal.setAccountingPeriodCompositeString("");
        }
    }
    return assetGlobal;
}
Also used : AssetGlobal(org.kuali.kfs.module.cam.businessobject.AssetGlobal) ParameterEvaluator(org.kuali.kfs.core.api.parameter.ParameterEvaluator)

Example 10 with ParameterEvaluator

use of org.kuali.kfs.core.api.parameter.ParameterEvaluator in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherDocument method templateEmployee.

public void templateEmployee(Person employee) {
    if (employee == null) {
        return;
    }
    this.getDvPayeeDetail().setDisbursementVoucherPayeeTypeCode(KFSConstants.PaymentPayeeTypes.EMPLOYEE);
    if (StringUtils.isNotBlank(employee.getEmployeeId())) {
        this.getDvPayeeDetail().setDisbVchrPayeeIdNumber(employee.getEmployeeId());
        ((CuDisbursementVoucherPayeeDetailExtension) this.getDvPayeeDetail().getExtension()).setDisbVchrPayeeIdType(CuDisbursementVoucherConstants.DV_PAYEE_ID_TYP_EMPL);
    } else {
        this.getDvPayeeDetail().setDisbVchrPayeeIdNumber(employee.getPrincipalId());
        ((CuDisbursementVoucherPayeeDetailExtension) this.getDvPayeeDetail().getExtension()).setDisbVchrPayeeIdType(CuDisbursementVoucherConstants.DV_PAYEE_ID_TYP_ENTITY);
    }
    ((CuDisbursementVoucherPayeeDetailExtension) this.getDvPayeeDetail().getExtension()).setPayeeTypeSuffix(StringUtils.EMPTY);
    // Changed this from employee.getName to employee.getNameUnmasked() otherwise "Xxxxxx" appears on the DV!
    this.getDvPayeeDetail().setDisbVchrPayeePersonName(employee.getNameUnmasked());
    final ParameterService parameterService = this.getParameterService();
    if (parameterService.parameterExists(DisbursementVoucherDocument.class, FPParameterConstants.USE_DEFAULT_EMPLOYEE_ADDRESS) && parameterService.getParameterValueAsBoolean(DisbursementVoucherDocument.class, FPParameterConstants.USE_DEFAULT_EMPLOYEE_ADDRESS)) {
        this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(employee.getAddressLine1Unmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(employee.getAddressLine2Unmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeCityName(employee.getAddressCityUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeStateCode(employee.getAddressStateProvinceCodeUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeZipCode(employee.getAddressPostalCodeUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(employee.getAddressCountryCodeUnmasked());
    } else {
        final EntityAddress address = getNonDefaultAddress(employee);
        if (address != null) {
            this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(address.getLine1Unmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(address.getLine2Unmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeCityName(address.getCityUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeStateCode(address.getStateProvinceCodeUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeZipCode(address.getPostalCodeUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(address.getCountryCodeUnmasked());
        } else {
            this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr("");
            this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr("");
            this.getDvPayeeDetail().setDisbVchrPayeeCityName("");
            this.getDvPayeeDetail().setDisbVchrPayeeStateCode("");
            this.getDvPayeeDetail().setDisbVchrPayeeZipCode("");
            this.getDvPayeeDetail().setDisbVchrPayeeCountryCode("");
        }
    }
    // "Is this payee an employee" = No
    if (employee.isActive()) {
        this.getDvPayeeDetail().setDisbVchrPayeeEmployeeCode(true);
    } else {
        this.getDvPayeeDetail().setDisbVchrPayeeEmployeeCode(false);
    }
    // I'm assuming that if a tax id type code other than 'TAX' is present, then the employee must be foreign
    for (String externalIdentifierTypeCode : employee.getExternalIdentifiers().keySet()) {
        if (KimConstants.PersonExternalIdentifierTypes.TAX.equals(externalIdentifierTypeCode)) {
            this.getDvPayeeDetail().setDisbVchrNonresidentPaymentCode(false);
        }
    }
    // Determine if employee is a research subject
    ParameterEvaluator researchPaymentReasonCodeEvaluator = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(DisbursementVoucherDocument.class, FPParameterConstants.RESEARCH_PAYMENT_REASONS, this.getDvPayeeDetail().getDisbVchrPaymentReasonCode());
    if (researchPaymentReasonCodeEvaluator.evaluationSucceeds()) {
        if (getParameterService().parameterExists(DisbursementVoucherDocument.class, FPParameterConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT)) {
            String researchPayLimit = getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, FPParameterConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT);
            if (StringUtils.isNotBlank(researchPayLimit)) {
                KualiDecimal payLimit = new KualiDecimal(researchPayLimit);
                if (getDisbVchrCheckTotalAmount().isLessThan(payLimit)) {
                    this.getDvPayeeDetail().setDvPayeeSubjectPaymentCode(true);
                }
            }
        }
    }
    this.disbVchrPayeeTaxControlCode = "";
    this.disbVchrPayeeW9CompleteCode = true;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) CuDisbursementVoucherPayeeDetailExtension(edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetailExtension) EntityAddress(org.kuali.kfs.kim.impl.identity.address.EntityAddress) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) ParameterEvaluator(org.kuali.kfs.core.api.parameter.ParameterEvaluator) ParameterEvaluatorService(org.kuali.kfs.core.api.parameter.ParameterEvaluatorService) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Aggregations

ParameterEvaluator (org.kuali.kfs.core.api.parameter.ParameterEvaluator)18 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)9 ParameterEvaluatorService (org.kuali.kfs.core.api.parameter.ParameterEvaluatorService)8 ArrayList (java.util.ArrayList)5 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)5 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)4 EntityAddress (org.kuali.kfs.kim.impl.identity.address.EntityAddress)4 CuDisbursementVoucherPayeeDetailExtension (edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetailExtension)3 List (java.util.List)3 AccountingLine (org.kuali.kfs.sys.businessobject.AccountingLine)3 CuDisbursementVoucherPayeeDetail (edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail)2 AppropriationAccount (edu.cornell.kfs.coa.businessobject.AppropriationAccount)1 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)1 CuBalanceDao (edu.cornell.kfs.gl.dataaccess.CuBalanceDao)1 WebServiceCredential (edu.cornell.kfs.sys.businessobject.WebServiceCredential)1 Criteria (org.apache.ojb.broker.query.Criteria)1 QueryByCriteria (org.apache.ojb.broker.query.QueryByCriteria)1 Account (org.kuali.kfs.coa.businessobject.Account)1 IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount)1 DataDictionaryService (org.kuali.kfs.datadictionary.legacy.DataDictionaryService)1