Search in sources :

Example 11 with ParameterService

use of org.kuali.kfs.coreservice.framework.parameter.ParameterService in project cu-kfs by CU-CommunityApps.

the class CUSimpleChartValuesFinder method getKeyValues.

/**
 * Creates a list of {@link Chart}s using their code as their key, and their code as the display value
 *
 * @see org.kuali.kfs.kns.lookup.keyvalues.KeyValuesFinder#getKeyValues()
 */
public List<KeyValue> getKeyValues() {
    parameterService = SpringContext.getBean(ParameterService.class);
    String defaultChartCode = "";
    String defaultChartCodeMethod = "";
    try {
        defaultChartCode = parameterService.getParameterValueAsString(KfsParameterConstants.FINANCIAL_SYSTEM_DOCUMENT.class, CUKFSParameterKeyConstants.DEFAULT_CHART_CODE);
        defaultChartCodeMethod = parameterService.getParameterValueAsString(KfsParameterConstants.FINANCIAL_SYSTEM_DOCUMENT.class, CUKFSParameterKeyConstants.DEFAULT_CHART_CODE_METHOD);
    } catch (Exception e) {
    // Do nothing
    }
    KeyValuesService boService = SpringContext.getBean(KeyValuesService.class);
    Collection<Chart> chartCodes = boService.findAll(Chart.class);
    List<KeyValue> chartKeyLabels = new ArrayList<KeyValue>();
    // If the DEFAULT_CHART_CODE_METHOD parameter DNE or has no value assigned to it, no default
    if (defaultChartCodeMethod.equals("")) {
        chartKeyLabels.add(new ConcreteKeyValue("", ""));
        for (Iterator<Chart> iter = chartCodes.iterator(); iter.hasNext(); ) {
            Chart element = (Chart) iter.next();
            if (element.isActive()) {
                // only show active charts
                chartKeyLabels.add(new ConcreteKeyValue(element.getChartOfAccountsCode(), element.getChartOfAccountsCode()));
            }
        }
    }
    // populate with the default chart
    if (defaultChartCodeMethod.equals("1")) {
        chartKeyLabels.add(new ConcreteKeyValue(defaultChartCode, defaultChartCode));
        for (Iterator<Chart> iter = chartCodes.iterator(); iter.hasNext(); ) {
            Chart element = (Chart) iter.next();
            if (element.isActive() && !element.getChartOfAccountsCode().equals(defaultChartCode)) {
                // only show active charts
                chartKeyLabels.add(new ConcreteKeyValue(element.getChartOfAccountsCode(), element.getChartOfAccountsCode()));
            }
        }
    }
    // populate with chart code of the user's primary department
    if (defaultChartCodeMethod.equals("2")) {
        Person currentUser = GlobalVariables.getUserSession().getPerson();
        String primaryDepartmentChartCode = SpringContext.getBean(FinancialSystemUserService.class).getPrimaryOrganization(currentUser, "KFS-SYS").getChartOfAccountsCode();
        chartKeyLabels.add(new ConcreteKeyValue(primaryDepartmentChartCode, primaryDepartmentChartCode));
        for (Iterator<Chart> iter = chartCodes.iterator(); iter.hasNext(); ) {
            Chart element = (Chart) iter.next();
            if (element.isActive() && !element.getChartOfAccountsCode().equals(primaryDepartmentChartCode)) {
                // only show active charts
                chartKeyLabels.add(new ConcreteKeyValue(element.getChartOfAccountsCode(), element.getChartOfAccountsCode()));
            }
        }
    }
    // populate with the default chart unless user's primary department has been defined
    if (defaultChartCodeMethod.equals("3")) {
        Person currentUser = GlobalVariables.getUserSession().getPerson();
        String primaryDepartmentChartCode = SpringContext.getBean(FinancialSystemUserService.class).getPrimaryOrganization(currentUser, "KFS-SYS").getChartOfAccountsCode();
        String chartUsed = null;
        if (primaryDepartmentChartCode != null && !primaryDepartmentChartCode.equals("")) {
            chartUsed = primaryDepartmentChartCode;
        } else {
            chartUsed = defaultChartCode;
        }
        chartKeyLabels.add(new ConcreteKeyValue(chartUsed, chartUsed));
        for (Iterator<Chart> iter = chartCodes.iterator(); iter.hasNext(); ) {
            Chart element = (Chart) iter.next();
            if (element.isActive() && !element.getChartOfAccountsCode().equals(chartUsed)) {
                // only show active charts
                chartKeyLabels.add(new ConcreteKeyValue(element.getChartOfAccountsCode(), element.getChartOfAccountsCode()));
            }
        }
    }
    return chartKeyLabels;
}
Also used : ConcreteKeyValue(org.kuali.rice.core.api.util.ConcreteKeyValue) KeyValue(org.kuali.rice.core.api.util.KeyValue) ConcreteKeyValue(org.kuali.rice.core.api.util.ConcreteKeyValue) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) ArrayList(java.util.ArrayList) KeyValuesService(org.kuali.kfs.krad.service.KeyValuesService) Person(org.kuali.rice.kim.api.identity.Person) Chart(org.kuali.kfs.coa.businessobject.Chart)

Example 12 with ParameterService

use of org.kuali.kfs.coreservice.framework.parameter.ParameterService in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherDocument method templateAlumni.

/**
 * Convenience method to set dv payee detail fields based on a given Alumnus.
 *
 * @param alumni
 */
public void templateAlumni(Person alumni) {
    if (alumni == null) {
        return;
    }
    this.getDvPayeeDetail().setDisbursementVoucherPayeeTypeCode(CuDisbursementVoucherConstants.DV_PAYEE_TYPE_ALUMNI);
    this.getDvPayeeDetail().setDisbVchrPayeeIdNumber(alumni.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(alumni.getNameUnmasked());
    final ParameterService parameterService = this.getParameterService();
    // Use the same parameter as for employees even though this is a alumni as basic intention is the same
    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(alumni.getAddressLine1Unmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(alumni.getAddressLine2Unmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeCityName(alumni.getAddressCityUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeStateCode(alumni.getAddressStateProvinceCodeUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeZipCode(alumni.getAddressPostalCodeUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(alumni.getAddressCountryCodeUnmasked());
    } else {
        final EntityAddress address = getNonDefaultAddress(alumni);
        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(alumni.getAddressPostalCodeUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(address.getCountryCodeUnmasked());
        } else {
            this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr("");
            this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr("");
            this.getDvPayeeDetail().setDisbVchrPayeeCityName("");
            this.getDvPayeeDetail().setDisbVchrPayeeStateCode("");
            this.getDvPayeeDetail().setDisbVchrPayeeZipCode("");
            this.getDvPayeeDetail().setDisbVchrPayeeCountryCode("");
        }
    }
    // I'm assuming that if a tax id type code other than 'TAX' is present, then the alumni must be foreign
    for (String externalIdentifierTypeCode : alumni.getExternalIdentifiers().keySet()) {
        if (KimConstants.PersonExternalIdentifierTypes.TAX.equals(externalIdentifierTypeCode)) {
            this.getDvPayeeDetail().setDisbVchrAlienPaymentCode(false);
        }
    }
    // Determine if alumni 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 13 with ParameterService

use of org.kuali.kfs.coreservice.framework.parameter.ParameterService 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 14 with ParameterService

use of org.kuali.kfs.coreservice.framework.parameter.ParameterService in project cu-kfs by CU-CommunityApps.

the class PurchaseOrderDocument method getAccountsForAwardRouting.

public List<Account> getAccountsForAwardRouting() {
    List<Account> accounts = new ArrayList<Account>();
    ParameterService parameterService = SpringContext.getBean(ParameterService.class);
    for (PurApItem item : (List<PurApItem>) this.getItems()) {
        for (PurApAccountingLine accountingLine : item.getSourceAccountingLines()) {
            if (isObjectCodeAllowedForAwardRouting(accountingLine, parameterService)) {
                if (ObjectUtils.isNull(accountingLine.getAccount())) {
                    accountingLine.refreshReferenceObject("account");
                }
                if (accountingLine.getAccount() != null && !accounts.contains(accountingLine.getAccount())) {
                    accounts.add(accountingLine.getAccount());
                }
            }
        }
    }
    return accounts;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) PurchaseOrderAccount(org.kuali.kfs.module.purap.businessobject.PurchaseOrderAccount) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 15 with ParameterService

use of org.kuali.kfs.coreservice.framework.parameter.ParameterService in project cu-kfs by CU-CommunityApps.

the class CuProcurementCardDocument method allowBackpost.

/**
 * Allow Backpost
 *
 * @param tranDate
 * @return
 */
public boolean allowBackpost(Date tranDate) {
    ParameterService parameterService = SpringContext.getBean(ParameterService.class);
    UniversityDateService universityDateService = SpringContext.getBean(UniversityDateService.class);
    int allowBackpost = Integer.parseInt(parameterService.getParameterValueAsString(ProcurementCardLoadStep.class, PurapRuleConstants.ALLOW_BACKPOST_DAYS));
    Calendar today = Calendar.getInstance();
    Integer currentFY = universityDateService.getCurrentUniversityDate().getUniversityFiscalYear();
    java.util.Date priorClosingDateTemp = universityDateService.getLastDateOfFiscalYear(currentFY - 1);
    Calendar priorClosingDate = Calendar.getInstance();
    priorClosingDate.setTime(priorClosingDateTemp);
    // adding 1 to set the date to midnight the day after backpost is allowed so that preqs allow backpost on the last day
    Calendar allowBackpostDate = Calendar.getInstance();
    allowBackpostDate.setTime(priorClosingDate.getTime());
    allowBackpostDate.add(Calendar.DATE, allowBackpost + 1);
    Calendar tranCal = Calendar.getInstance();
    tranCal.setTime(tranDate);
    // prior year, set the year to prior year
    if ((today.compareTo(priorClosingDate) > 0) && (today.compareTo(allowBackpostDate) <= 0) && (tranCal.compareTo(priorClosingDate) <= 0)) {
        LOG.debug("allowBackpost() within range to allow backpost; posting entry to period 12 of previous FY");
        return true;
    }
    LOG.debug("allowBackpost() not within range to allow backpost; posting entry to current FY");
    return false;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) Calendar(java.util.Calendar) ProcurementCardLoadStep(org.kuali.kfs.fp.batch.ProcurementCardLoadStep) UniversityDateService(org.kuali.kfs.sys.service.UniversityDateService)

Aggregations

ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)29 ArrayList (java.util.ArrayList)9 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)9 List (java.util.List)4 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)4 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)4 ParameterEvaluator (org.kuali.rice.core.api.parameter.ParameterEvaluator)4 ParameterEvaluatorService (org.kuali.rice.core.api.parameter.ParameterEvaluatorService)4 CuDisbursementVoucherPayeeDetailExtension (edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetailExtension)3 HashMap (java.util.HashMap)3 Account (org.kuali.kfs.coa.businessobject.Account)3 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)3 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)3 KfsParameterConstants (org.kuali.kfs.sys.service.impl.KfsParameterConstants)3 EntityAddress (org.kuali.rice.kim.api.identity.address.EntityAddress)3 Date (java.sql.Date)2 ParseException (java.text.ParseException)2 Calendar (java.util.Calendar)2 BenefitsCalculation (org.kuali.kfs.module.ld.businessobject.BenefitsCalculation)2 PreEncumbranceSourceAccountingLine (edu.cornell.kfs.fp.businessobject.PreEncumbranceSourceAccountingLine)1