use of org.kuali.rice.core.api.datetime.DateTimeService in project cu-kfs by CU-CommunityApps.
the class AgencyStep method execute.
public boolean execute(String arg0, java.util.Date arg1) throws InterruptedException {
String dateString = parameterService.getParameterValueAsString(AgencyStep.class, LAST_SUCCESSFUL_RUN);
DateTimeService dtService = SpringContext.getBean(DateTimeService.class);
java.sql.Date lastRun = null;
try {
lastRun = dtService.convertToSqlDate(dateString);
} catch (ParseException e1) {
e1.printStackTrace();
}
boolean result = true;
// try {
result = ezraService.updateSponsorsSince(lastRun);
// }
if (result) {
Parameter parm = parameterService.getParameter(PARAMETER_NAMESPACE_CODE, PARAMETER_NAMESPACE_STEP, LAST_SUCCESSFUL_RUN);
Parameter.Builder newParm = Parameter.Builder.create(parm);
newParm.setValue(dtService.toDateTimeString(dtService.getCurrentSqlDate()));
parameterService.updateParameter(newParm.build());
// //parameterService.
}
return result;
}
use of org.kuali.rice.core.api.datetime.DateTimeService in project cu-kfs by CU-CommunityApps.
the class DisencumbranceEnterpriseFeederFileSetType method getDoneFileName.
/**
* Returns done file name for a specific user and file user identifier
*
* @param user the user who uploaded or will upload the file
* @param fileUserIdentifier the file identifier
* @return String done file name
* @see org.kuali.kfs.sys.batch.BatchInputFileSetType#getDoneFileName(org.kuali.rice.kim.bo.Person, java.lang.String)
*/
public String getDoneFileName(Person user, String fileUserIdentifer, Date creationDate) {
DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
StringBuilder buf = new StringBuilder();
fileUserIdentifer = StringUtils.deleteWhitespace(fileUserIdentifer);
fileUserIdentifer = StringUtils.remove(fileUserIdentifer, FILE_NAME_PART_DELIMITER);
buf.append(FILE_NAME_PREFIX).append(FILE_NAME_PART_DELIMITER).append(user.getPrincipalName()).append(FILE_NAME_PART_DELIMITER).append(fileUserIdentifer).append(FILE_NAME_PART_DELIMITER).append(dateTimeService.toDateTimeStringForFilename(creationDate)).append(getDoneFileExtension());
return buf.toString();
}
use of org.kuali.rice.core.api.datetime.DateTimeService in project cu-kfs by CU-CommunityApps.
the class CuLaborPendingEntryConverterServiceImpl method getOffsetPendingEntries.
/**
* convert the given document and accounting line into the benefit pending entries
*
* @param document the given accounting document
* @param accountingLine the given accounting line
* @param sequenceHelper the given sequence helper
* @param benefitAmount the given benefit amount
* @param fringeBenefitObjectCode the given fringe benefit object code
* @return a set of benefit pending entries
*/
public List<LaborLedgerPendingEntry> getOffsetPendingEntries(LaborLedgerPendingEntry pendingEntry, GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
List<LaborLedgerPendingEntry> offsetEntries = new ArrayList<LaborLedgerPendingEntry>();
String benefitRateCategoryCode = SpringContext.getBean(LaborBenefitsCalculationService.class).getBenefitRateCategoryCode(pendingEntry.getChartOfAccountsCode(), pendingEntry.getAccountNumber(), pendingEntry.getSubAccountNumber());
Collection<PositionObjectBenefit> positionObjectBenefits = SpringContext.getBean(LaborPositionObjectBenefitService.class).getActivePositionObjectBenefits(pendingEntry.getUniversityFiscalYear(), pendingEntry.getChartOfAccountsCode(), pendingEntry.getFinancialObjectCode());
if (positionObjectBenefits == null || positionObjectBenefits.isEmpty()) {
return offsetEntries;
}
for (PositionObjectBenefit positionObjectBenefit : positionObjectBenefits) {
Map<String, Object> fieldValues = new HashMap<String, Object>();
fieldValues.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, pendingEntry.getUniversityFiscalYear());
fieldValues.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, pendingEntry.getChartOfAccountsCode());
fieldValues.put(LaborPropertyConstants.POSITION_BENEFIT_TYPE_CODE, positionObjectBenefit.getFinancialObjectBenefitsTypeCode());
fieldValues.put(LaborPropertyConstants.LABOR_BENEFIT_RATE_CATEGORY_CODE, benefitRateCategoryCode);
BenefitsCalculation benefitsCalculation = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(BenefitsCalculation.class, fieldValues);
if (ObjectUtils.isNull(benefitsCalculation)) {
continue;
}
LaborLedgerPendingEntry offsetEntry = new LaborLedgerPendingEntry();
// Copy values from pending entry
offsetEntry.setReferenceFinancialDocumentNumber(pendingEntry.getReferenceFinancialDocumentNumber());
offsetEntry.setReferenceFinancialDocumentTypeCode(pendingEntry.getReferenceFinancialDocumentTypeCode());
offsetEntry.setFinancialDocumentReversalDate(pendingEntry.getFinancialDocumentReversalDate());
offsetEntry.setFinancialBalanceTypeCode(pendingEntry.getFinancialBalanceTypeCode());
offsetEntry.setFinancialObjectTypeCode(pendingEntry.getFinancialObjectTypeCode());
offsetEntry.setReferenceFinancialSystemOriginationCode(pendingEntry.getReferenceFinancialSystemOriginationCode());
offsetEntry.setOrganizationDocumentNumber(pendingEntry.getOrganizationDocumentNumber());
offsetEntry.setTransactionDate(pendingEntry.getTransactionDate());
offsetEntry.setTransactionDebitCreditCode(pendingEntry.getTransactionDebitCreditCode());
offsetEntry.setTransactionEncumbranceUpdateCode(pendingEntry.getTransactionEncumbranceUpdateCode());
offsetEntry.setPositionNumber(pendingEntry.getPositionNumber());
offsetEntry.setTransactionPostingDate(pendingEntry.getTransactionPostingDate());
offsetEntry.setPayPeriodEndDate(pendingEntry.getPayPeriodEndDate());
offsetEntry.setTransactionTotalHours(pendingEntry.getTransactionTotalHours());
offsetEntry.setPayrollEndDateFiscalYear(pendingEntry.getPayrollEndDateFiscalYear());
offsetEntry.setPayrollEndDateFiscalPeriodCode(pendingEntry.getPayrollEndDateFiscalPeriodCode());
offsetEntry.setEmplid(pendingEntry.getEmplid());
offsetEntry.setEmployeeRecord(pendingEntry.getEmployeeRecord());
offsetEntry.setEarnCode(pendingEntry.getEarnCode());
offsetEntry.setPayGroup(pendingEntry.getPayGroup());
offsetEntry.setSalaryAdministrationPlan(pendingEntry.getSalaryAdministrationPlan());
offsetEntry.setGrade(pendingEntry.getGrade());
offsetEntry.setRunIdentifier(pendingEntry.getRunIdentifier());
offsetEntry.setLaborLedgerOriginalChartOfAccountsCode(pendingEntry.getLaborLedgerOriginalChartOfAccountsCode());
offsetEntry.setLaborLedgerOriginalAccountNumber(pendingEntry.getLaborLedgerOriginalAccountNumber());
offsetEntry.setLaborLedgerOriginalSubAccountNumber(pendingEntry.getLaborLedgerOriginalSubAccountNumber());
offsetEntry.setLaborLedgerOriginalFinancialObjectCode(pendingEntry.getLaborLedgerOriginalFinancialObjectCode());
offsetEntry.setLaborLedgerOriginalFinancialSubObjectCode(pendingEntry.getLaborLedgerOriginalFinancialSubObjectCode());
offsetEntry.setHrmsCompany(pendingEntry.getHrmsCompany());
offsetEntry.setSetid(pendingEntry.getSetid());
offsetEntry.setTransactionEntryOffsetCode(pendingEntry.getTransactionEntryOffsetCode());
offsetEntry.setPayrollEndDateFiscalPeriod(pendingEntry.getPayrollEndDateFiscalPeriod());
// New offset values
offsetEntry.setFinancialObjectCode(benefitsCalculation.getPositionFringeBenefitObjectCode());
offsetEntry.setTransactionLedgerEntrySequenceNumber(getNextSequenceNumber(sequenceHelper));
// calculate the offsetAmount amount (ledger amt * (benfit pct/100) )
KualiDecimal fringeBenefitPercent = benefitsCalculation.getPositionFringeBenefitPercent();
KualiDecimal offsetAmount = fringeBenefitPercent.multiply(pendingEntry.getTransactionLedgerEntryAmount()).divide(KFSConstants.ONE_HUNDRED.kualiDecimalValue());
offsetEntry.setTransactionLedgerEntryAmount(offsetAmount.abs());
offsetEntry.setAccountNumber(benefitsCalculation.getAccountCodeOffset());
offsetEntry.setFinancialObjectCode(benefitsCalculation.getObjectCodeOffset());
// Set all the fields required to process through the scrubber and poster jobs
offsetEntry.setUniversityFiscalPeriodCode(pendingEntry.getUniversityFiscalPeriodCode());
offsetEntry.setChartOfAccountsCode(pendingEntry.getChartOfAccountsCode());
offsetEntry.setUniversityFiscalYear(pendingEntry.getUniversityFiscalYear());
offsetEntry.setSubAccountNumber("-----");
offsetEntry.setFinancialSubObjectCode("---");
offsetEntry.setOrganizationReferenceId("");
offsetEntry.setProjectCode("");
offsetEntry.setTransactionLedgerEntryDescription("GENERATED BENEFIT OFFSET");
ParameterService parameterService = SpringContext.getBean(ParameterService.class);
String originCode = parameterService.getParameterValueAsString(LaborEnterpriseFeedStep.class, LdConstants.LABOR_BENEFIT_OFFSET_ORIGIN_CODE);
offsetEntry.setFinancialSystemOriginationCode(originCode);
DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
offsetEntry.setDocumentNumber(dateTimeService.toString(dateTimeService.getCurrentDate(), "yyyyMMddhhmmssSSS"));
if (pendingEntry.getTransactionDebitCreditCode().equalsIgnoreCase("D")) {
offsetAmount = offsetAmount;
} else {
offsetAmount = offsetAmount.multiply(new KualiDecimal(-1));
}
if (offsetAmount.isGreaterThan(new KualiDecimal(0))) {
offsetEntry.setTransactionDebitCreditCode("C");
} else if (offsetAmount.isLessThan(new KualiDecimal(0))) {
offsetEntry.setTransactionDebitCreditCode("D");
}
String offsetDocTypes = null;
if (StringUtils.isNotEmpty(parameterService.getParameterValueAsString(LaborEnterpriseFeedStep.class, LdConstants.LABOR_BENEFIT_OFFSET_DOCTYPE))) {
offsetDocTypes = "," + parameterService.getParameterValueAsString(LaborEnterpriseFeedStep.class, LdConstants.LABOR_BENEFIT_OFFSET_DOCTYPE).replace(";", ",").replace("|", ",") + ",";
}
String docTypeCode = offsetDocTypes;
if (offsetDocTypes.contains(",")) {
String[] splits = offsetDocTypes.split(",");
for (String split : splits) {
if (!StringUtils.isEmpty(split)) {
docTypeCode = split;
break;
}
}
}
offsetEntry.setFinancialDocumentTypeCode(docTypeCode);
offsetEntries.add(offsetEntry);
}
return offsetEntries;
}
use of org.kuali.rice.core.api.datetime.DateTimeService in project cu-kfs by CU-CommunityApps.
the class FormatAction method prepare.
/**
* This method marks the payments for format
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward prepare(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
FormatForm formatForm = (FormatForm) form;
DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
if (formatForm.getCampus() == null) {
return mapping.findForward(PdpConstants.MAPPING_SELECTION);
}
// Figure out which ones they have selected
List selectedCustomers = new ArrayList();
for (CustomerProfile customer : formatForm.getCustomers()) {
if (customer.isSelectedForFormat()) {
selectedCustomers.add(customer);
}
}
Date paymentDate = dateTimeService.convertToSqlDate(formatForm.getPaymentDate());
Person kualiUser = GlobalVariables.getUserSession().getPerson();
FormatProcessSummary formatProcessSummary = formatService.startFormatProcess(kualiUser, formatForm.getCampus(), selectedCustomers, paymentDate, formatForm.getPaymentTypes());
if (formatProcessSummary.getProcessSummaryList().size() == 0) {
KNSGlobalVariables.getMessageList().add(PdpKeyConstants.Format.ERROR_PDP_NO_MATCHING_PAYMENT_FOR_FORMAT);
return mapping.findForward(PdpConstants.MAPPING_SELECTION);
}
formatForm.setFormatProcessSummary(formatProcessSummary);
return mapping.findForward(PdpConstants.MAPPING_CONTINUE);
}
use of org.kuali.rice.core.api.datetime.DateTimeService in project cu-kfs by CU-CommunityApps.
the class CuFormatAction method start.
@Override
public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
CuFormatForm formatForm = (CuFormatForm) form;
Person kualiUser = GlobalVariables.getUserSession().getPerson();
FormatSelection formatSelection = formatService.getDataForFormat(kualiUser);
DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
formatForm.setCampus(kualiUser.getCampusCode());
// no data for format because another format process is already running
if (formatSelection.getStartDate() != null) {
GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.Format.ERROR_PDP_FORMAT_PROCESS_ALREADY_RUNNING, dateTimeService.toDateTimeString(formatSelection.getStartDate()));
} else {
List<CustomerProfile> customers = formatSelection.getCustomerList();
for (CustomerProfile element : customers) {
if (formatSelection.getCampus().equals(element.getDefaultPhysicalCampusProcessingCode())) {
element.setSelectedForFormat(Boolean.TRUE);
} else {
element.setSelectedForFormat(Boolean.FALSE);
}
}
formatForm.setPaymentDate(dateTimeService.toDateString(dateTimeService.getCurrentTimestamp()));
formatForm.setPaymentTypes(PdpConstants.PaymentTypes.ALL);
formatForm.setPaymentDistribution(CUPdpConstants.PaymentDistributions.PROCESS_ALL);
formatForm.setCustomers(customers);
formatForm.setRanges(formatSelection.getRangeList());
}
return mapping.findForward(PdpConstants.MAPPING_SELECTION);
}
Aggregations