Search in sources :

Example 11 with DateTimeService

use of org.kuali.kfs.core.api.datetime.DateTimeService in project cu-kfs by CU-CommunityApps.

the class ConcurStandardAccountingExtractCreateCollectorFileServiceImplTest method buildCollectorFileService.

protected ConcurStandardAccountingExtractCreateCollectorFileService buildCollectorFileService() throws Exception {
    DateTimeService dateTimeService = buildDateTimeService();
    TestConcurStandardAccountingExtractCreateCollectorFileServiceImpl collectorFileServiceImpl = new TestConcurStandardAccountingExtractCreateCollectorFileServiceImpl();
    collectorFileServiceImpl.setDateTimeService(dateTimeService);
    collectorFileServiceImpl.setBatchFileLookupableHelperService(buildBatchFileLookupableHelperService(dateTimeService));
    collectorFileServiceImpl.setCollectorBatchBuilder(buildMockBatchBuilder());
    collectorFileServiceImpl.setStagingDirectoryPath(BASE_TEST_DIRECTORY);
    collectorFileServiceImpl.setCollectorDirectoryPath(COLLECTOR_OUTPUT_DIRECTORY_PATH);
    collectorFileServiceImpl.setCollectorFlatFileSerializerService(buildCollectorFlatFileSerializerService(dateTimeService));
    return collectorFileServiceImpl;
}
Also used : DateTimeService(org.kuali.kfs.core.api.datetime.DateTimeService)

Example 12 with DateTimeService

use of org.kuali.kfs.core.api.datetime.DateTimeService in project cu-kfs by CU-CommunityApps.

the class StaleCheckExtractServiceImplTest method createMockDateTimeService.

private static DateTimeService createMockDateTimeService() {
    DateTimeService dateTimeService = mock(DateTimeServiceImpl.class);
    java.sql.Date currentSqlDate = new java.sql.Date(Calendar.getInstance().getTimeInMillis());
    when(dateTimeService.getCurrentSqlDate()).thenReturn(currentSqlDate);
    return dateTimeService;
}
Also used : DateTimeService(org.kuali.kfs.core.api.datetime.DateTimeService)

Example 13 with DateTimeService

use of org.kuali.kfs.core.api.datetime.DateTimeService in project cu-kfs by CU-CommunityApps.

the class CuContractsGrantsInvoiceDocumentAction method validateBillingPeriodDateRange.

protected void validateBillingPeriodDateRange(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument, List<String> warningMessages) throws ParseException {
    Pair<Date, Date> billingPeriodDates = parseDateRange(contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getBillingPeriod());
    DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
    ConfigurationService configurationService = SpringContext.getBean(ConfigurationService.class);
    Date billingPeriodStartDate = billingPeriodDates.getLeft();
    Date billingPeriodEndDate = billingPeriodDates.getRight();
    if (dateTimeService.dateDiff(billingPeriodEndDate, billingPeriodStartDate, false) >= 1) {
        warningMessages.add(configurationService.getPropertyValueAsString(CUKFSKeyConstants.WARNING_CINV_BILLING_PERIOD_END_DATE_BEFORE_BILLING_PERIOD_START_DATE));
    }
    if (dateTimeService.dateDiff(dateTimeService.getCurrentSqlDate(), billingPeriodEndDate, false) >= 1) {
        warningMessages.add(configurationService.getPropertyValueAsString(CUKFSKeyConstants.WARNING_CINV_BILLING_PERIOD_END_DATE_AFTER_TODAY));
    }
    Date lastBilledDate = contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getLastBilledDate();
    if (dateTimeService.dateDiff(billingPeriodEndDate, lastBilledDate, false) >= 1) {
        warningMessages.add(configurationService.getPropertyValueAsString(CUKFSKeyConstants.WARNING_CINV_BILLING_PERIOD_END_DATE_BEFORE_LAST_BILLED_DATE));
    }
    if (dateTimeService.dateDiff(billingPeriodEndDate, lastBilledDate, false) <= -1) {
        warningMessages.add(configurationService.getPropertyValueAsString(CUKFSKeyConstants.WARNING_CINV_BILLING_PERIOD_END_DATE_AFTER_LAST_BILLED_DATE));
    }
    if (dateTimeService.dateDiff(billingPeriodStartDate, lastBilledDate, false) <= -1) {
        warningMessages.add(configurationService.getPropertyValueAsString(CUKFSKeyConstants.WARNING_CINV_BILLING_PERIOD_START_DATE_AFTER_LAST_BILLED_DATE));
    }
    Pair<Date, Date> awardDateRange = parseDateRange(contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getAwardDateRange());
    if (dateTimeService.dateDiff(billingPeriodStartDate, awardDateRange.getLeft(), false) >= 1) {
        warningMessages.add(configurationService.getPropertyValueAsString(CUKFSKeyConstants.WARNING_CINV_BILLING_PERIOD_START_DATE_BEFORE_AWARD_START_DATE));
    }
}
Also used : ConfigurationService(org.kuali.kfs.core.api.config.property.ConfigurationService) DateTimeService(org.kuali.kfs.core.api.datetime.DateTimeService) Date(java.sql.Date)

Example 14 with DateTimeService

use of org.kuali.kfs.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.kfs.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();
}
Also used : DateTimeService(org.kuali.kfs.core.api.datetime.DateTimeService)

Example 15 with DateTimeService

use of org.kuali.kfs.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;
}
Also used : BenefitsCalculation(org.kuali.kfs.module.ld.businessobject.BenefitsCalculation) LaborBenefitsCalculationService(org.kuali.kfs.module.ld.service.LaborBenefitsCalculationService) HashMap(java.util.HashMap) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) LaborEnterpriseFeedStep(org.kuali.kfs.module.ld.batch.LaborEnterpriseFeedStep) ArrayList(java.util.ArrayList) PositionObjectBenefit(org.kuali.kfs.module.ld.businessobject.PositionObjectBenefit) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) LaborLedgerPendingEntry(org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry) LaborPositionObjectBenefitService(org.kuali.kfs.module.ld.service.LaborPositionObjectBenefitService) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) DateTimeService(org.kuali.kfs.core.api.datetime.DateTimeService)

Aggregations

DateTimeService (org.kuali.kfs.core.api.datetime.DateTimeService)22 Date (java.util.Date)7 Date (java.sql.Date)4 ConfigurationService (org.kuali.kfs.core.api.config.property.ConfigurationService)4 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)4 Person (org.kuali.kfs.kim.api.identity.Person)4 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)4 ArrayList (java.util.ArrayList)3 ParseException (java.text.ParseException)2 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)2 FormatProcessSummary (org.kuali.kfs.pdp.businessobject.FormatProcessSummary)2 FormatSelection (org.kuali.kfs.pdp.businessobject.FormatSelection)2 CuDisbursementVoucherDefaultDueDateService (edu.cornell.kfs.fp.document.service.CuDisbursementVoucherDefaultDueDateService)1 CuFormatService (edu.cornell.kfs.pdp.service.CuFormatService)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 StringBufferInputStream (java.io.StringBufferInputStream)1 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ServletOutputStream (javax.servlet.ServletOutputStream)1