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;
}
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;
}
Aggregations