Search in sources :

Example 11 with ParameterEvaluator

use of org.kuali.rice.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, DisbursementVoucherDocument.USE_DEFAULT_EMPLOYEE_ADDRESS_PARAMETER_NAME) && parameterService.getParameterValueAsBoolean(DisbursementVoucherDocument.class, DisbursementVoucherDocument.USE_DEFAULT_EMPLOYEE_ADDRESS_PARAMETER_NAME)) {
        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("");
        }
    }
    // KFSMI-8935: When an employee is inactive, the Payment Type field on DV documents should display the message "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().setDisbVchrAlienPaymentCode(false);
        }
    }
    // Determine if employee is a research subject
    ParameterEvaluator researchPaymentReasonCodeEvaluator = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(DisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_PAYMENT_REASONS_PARM_NM, this.getDvPayeeDetail().getDisbVchrPaymentReasonCode());
    if (researchPaymentReasonCodeEvaluator.evaluationSucceeds()) {
        if (getParameterService().parameterExists(DisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT_PARM_NM)) {
            String researchPayLimit = getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT_PARM_NM);
            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.rice.kim.api.identity.address.EntityAddress) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) ParameterEvaluator(org.kuali.rice.core.api.parameter.ParameterEvaluator) ParameterEvaluatorService(org.kuali.rice.core.api.parameter.ParameterEvaluatorService) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Example 12 with ParameterEvaluator

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

the class CuBalanceDaoOjb method findReversionBalancesForFiscalYear.

/**
 * Returns a list of balances to return for the Organization Reversion year end job to process
 *
 * @param year the university fiscal year to find balances for
 * @param endOfYear if true, use currrent year accounts, otherwise use prior year accounts
 * @return an Iterator of Balances to process
 * @see org.kuali.kfs.gl.dataaccess.BalanceDao#findOrganizationReversionBalancesForFiscalYear(java.lang.Integer, boolean,
 *      org.kuali.kfs.sys.businessobject.SystemOptions, java.util.List)
 */
@SuppressWarnings({ "deprecation", "unchecked" })
public Iterator<Balance> findReversionBalancesForFiscalYear(Integer year, boolean endOfYear, SystemOptions options, List<ParameterEvaluator> parameterEvaluators) {
    LOG.debug("findReversionBalancesForFiscalYear() started");
    Criteria c = new Criteria();
    c.addEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, year);
    for (ParameterEvaluator parameterEvaluator : parameterEvaluators) {
        String currentRule = parameterEvaluator.getValue();
        if (endOfYear) {
            currentRule = currentRule.replaceAll("account\\.", "priorYearAccount.");
        }
        if (StringUtils.isNotBlank(currentRule)) {
            String propertyName = StringUtils.substringBefore(currentRule, "=");
            List<String> ruleValues = Arrays.asList(StringUtils.substringAfter(currentRule, "=").split(";"));
            if (propertyName != null && propertyName.length() > 0 && ruleValues.size() > 0 && !StringUtils.isBlank(ruleValues.get(0))) {
                if (parameterEvaluator.constraintIsAllow()) {
                    c.addIn(propertyName, ruleValues);
                } else {
                    c.addNotIn(propertyName, ruleValues);
                }
            }
        }
    }
    // we only ever calculate on CB, AC, and encumbrance types, so let's only select those
    List<String> reversionBalancesToSelect = new ArrayList<String>();
    reversionBalancesToSelect.add(options.getActualFinancialBalanceTypeCd());
    reversionBalancesToSelect.add(options.getFinObjTypeExpenditureexpCd());
    reversionBalancesToSelect.add(options.getCostShareEncumbranceBalanceTypeCd());
    reversionBalancesToSelect.add(options.getIntrnlEncumFinBalanceTypCd());
    reversionBalancesToSelect.add(KFSConstants.BALANCE_TYPE_CURRENT_BUDGET);
    c.addIn(KFSPropertyConstants.BALANCE_TYPE_CODE, reversionBalancesToSelect);
    QueryByCriteria query = QueryFactory.newQuery(Balance.class, c);
    query.addOrderByAscending(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
    query.addOrderByAscending(KFSPropertyConstants.ACCOUNT_NUMBER);
    query.addOrderByAscending(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
    query.addOrderByAscending(KFSPropertyConstants.OBJECT_CODE);
    query.addOrderByAscending(KFSPropertyConstants.SUB_OBJECT_CODE);
    query.addOrderByAscending(KFSPropertyConstants.BALANCE_TYPE_CODE);
    query.addOrderByAscending(KFSPropertyConstants.OBJECT_TYPE_CODE);
    return getPersistenceBrokerTemplate().getIteratorByQuery(query);
}
Also used : QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) ArrayList(java.util.ArrayList) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) Criteria(org.apache.ojb.broker.query.Criteria) ParameterEvaluator(org.kuali.rice.core.api.parameter.ParameterEvaluator)

Example 13 with ParameterEvaluator

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

the class CuBalanceServiceImpl method findReversionBalancesForFiscalYear.

/**
 * Returns all of the balances to be forwarded for the organization reversion process
 * @param year the year of balances to find
 * @param endOfYear whether the organization reversion process is running end of year (before the fiscal year change over) or
 *        beginning of year (after the fiscal year change over)
 * @return an iterator of balances to put through the strenuous organization reversion process
 * @see org.kuali.kfs.gl.service.BalanceService#findOrganizationReversionBalancesForFiscalYear(java.lang.Integer, boolean)
 */
public Iterator<Balance> findReversionBalancesForFiscalYear(Integer year, boolean endOfYear) {
    SystemOptions options = SpringContext.getBean(OptionsService.class).getOptions(year);
    List<ParameterEvaluator> parameterEvaluators = new ArrayList<ParameterEvaluator>();
    int i = 1;
    boolean moreParams = true;
    while (moreParams) {
        if (parameterService.parameterExists(Reversion.class, PARAMETER_PREFIX + i)) {
            ParameterEvaluator parameterEvaluator = /*REFACTORME*/
            SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(Reversion.class, PARAMETER_PREFIX + i);
            parameterEvaluators.add(parameterEvaluator);
        } else {
            moreParams = false;
        }
        i++;
    }
    return ((CuBalanceDao) balanceDao).findReversionBalancesForFiscalYear(year, endOfYear, options, parameterEvaluators);
}
Also used : OptionsService(org.kuali.kfs.sys.service.OptionsService) ArrayList(java.util.ArrayList) SystemOptions(org.kuali.kfs.sys.businessobject.SystemOptions) ParameterEvaluator(org.kuali.rice.core.api.parameter.ParameterEvaluator) ParameterEvaluatorService(org.kuali.rice.core.api.parameter.ParameterEvaluatorService) CuBalanceDao(edu.cornell.kfs.gl.dataaccess.CuBalanceDao)

Example 14 with ParameterEvaluator

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

the class KualiAccountingDocumentActionBase method isSalesTaxRequired.

/**
 * This method checks to see if this doctype needs sales tax If it does then it checks to see if the account and object code
 * require sales tax If it does then it returns true. Note - this is hackish as we shouldn't have to call rules directly from
 * the action class But we need to in this instance because we are copying the lines before calling rules and need a way to
 * modify them before they go on
 *
 * @param accountingLine
 * @return true if sales tax check is needed, false otherwise
 */
protected boolean isSalesTaxRequired(AccountingDocument financialDocument, AccountingLine accountingLine) {
    boolean required = false;
    String docType = SpringContext.getBean(DataDictionaryService.class).getDocumentTypeNameByClass(financialDocument.getClass());
    // first we need to check just the doctype to see if it needs the sales tax check
    ParameterService parameterService = SpringContext.getBean(ParameterService.class);
    // apply the rule, see if it fails
    ParameterEvaluator docTypeSalesTaxCheckEvaluator = /*REFACTORME*/
    SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(KfsParameterConstants.FINANCIAL_PROCESSING_DOCUMENT.class, APPLICATION_PARAMETER.DOCTYPE_SALES_TAX_CHECK, docType);
    if (docTypeSalesTaxCheckEvaluator.evaluationSucceeds()) {
        required = true;
    }
    // second we need to check the account and object code combination to see if it needs sales tax
    if (required) {
        // get the object code and account
        String objCd = accountingLine.getFinancialObjectCode();
        String account = accountingLine.getAccountNumber();
        if (!StringUtils.isEmpty(objCd) && !StringUtils.isEmpty(account)) {
            String compare = account + ":" + objCd;
            ParameterEvaluator salesTaxApplicableAcctAndObjectEvaluator = /*REFACTORME*/
            SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(KfsParameterConstants.FINANCIAL_PROCESSING_DOCUMENT.class, APPLICATION_PARAMETER.SALES_TAX_APPLICABLE_ACCOUNTS_AND_OBJECT_CODES, compare);
            if (!salesTaxApplicableAcctAndObjectEvaluator.evaluationSucceeds()) {
                required = false;
            }
        } else {
            // the two fields are currently empty and we don't need to check yet
            required = false;
        }
    }
    return required;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) KfsParameterConstants(org.kuali.kfs.sys.service.impl.KfsParameterConstants) ParameterEvaluator(org.kuali.rice.core.api.parameter.ParameterEvaluator) ParameterEvaluatorService(org.kuali.rice.core.api.parameter.ParameterEvaluatorService) DataDictionaryService(org.kuali.kfs.kns.service.DataDictionaryService)

Aggregations

ParameterEvaluator (org.kuali.rice.core.api.parameter.ParameterEvaluator)14 ParameterEvaluatorService (org.kuali.rice.core.api.parameter.ParameterEvaluatorService)8 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)7 ArrayList (java.util.ArrayList)5 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)5 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)4 CuDisbursementVoucherPayeeDetailExtension (edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetailExtension)3 List (java.util.List)3 AccountingLine (org.kuali.kfs.sys.businessobject.AccountingLine)3 EntityAddress (org.kuali.rice.kim.api.identity.address.EntityAddress)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 RecurringDisbursementVoucherDocument (edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument)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