Search in sources :

Example 1 with UniversityDateService

use of org.kuali.kfs.sys.service.UniversityDateService in project cu-kfs by CU-CommunityApps.

the class ProcurementCardCreateDocumentServiceImpl method validateTransaction.

@Override
protected String validateTransaction(ProcurementCardTransaction transaction) {
    String errorText = "";
    UniversityDateService uds = SpringContext.getBean(UniversityDateService.class);
    ObjectCodeService ocs = SpringContext.getBean(ObjectCodeService.class);
    ObjectCode objectCode = ocs.getByPrimaryIdWithCaching(uds.getCurrentFiscalYear(), transaction.getChartOfAccountsCode(), transaction.getFinancialObjectCode());
    if (ObjectUtils.isNull(objectCode)) {
        String tempErrorText = "Chart " + transaction.getChartOfAccountsCode() + " Object Code " + transaction.getFinancialObjectCode() + " is invalid; using default error Object Code.";
        if (LOG.isInfoEnabled()) {
            LOG.info(tempErrorText);
        }
        errorText += " " + tempErrorText;
        transaction.setFinancialObjectCode(getErrorObjectCode());
        transaction.refresh();
    }
    errorText += " " + super.validateTransaction(transaction);
    return errorText;
}
Also used : ObjectCodeService(org.kuali.kfs.coa.service.ObjectCodeService) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) UniversityDateService(org.kuali.kfs.sys.service.UniversityDateService)

Example 2 with UniversityDateService

use of org.kuali.kfs.sys.service.UniversityDateService 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

UniversityDateService (org.kuali.kfs.sys.service.UniversityDateService)2 Calendar (java.util.Calendar)1 ObjectCode (org.kuali.kfs.coa.businessobject.ObjectCode)1 ObjectCodeService (org.kuali.kfs.coa.service.ObjectCodeService)1 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)1 ProcurementCardLoadStep (org.kuali.kfs.fp.batch.ProcurementCardLoadStep)1