Search in sources :

Example 6 with ConfigurationService

use of org.kuali.kfs.core.api.config.property.ConfigurationService in project cu-kfs by CU-CommunityApps.

the class PayeeACHAccountExtractServiceImplTest method createMockConfigurationService.

private ConfigurationService createMockConfigurationService() throws Exception {
    ConfigurationService configurationService = mock(ConfigurationService.class);
    when(configurationService.getPropertyValueAsString(KFSConstants.GLOBAL_ERRORS)).thenReturn(GLOBAL_ERROR_FORMAT);
    return configurationService;
}
Also used : ConfigurationService(org.kuali.kfs.core.api.config.property.ConfigurationService)

Example 7 with ConfigurationService

use of org.kuali.kfs.core.api.config.property.ConfigurationService in project cu-kfs by CU-CommunityApps.

the class PaymentWorksNewVendorPayeeAchServiceImplTest method buildMockConfigurationService.

private ConfigurationService buildMockConfigurationService() {
    ConfigurationService configService = Mockito.mock(ConfigurationService.class);
    Mockito.when(configService.getPropertyValueAsString(PaymentWorksKeyConstants.ERROR_PAYMENTWORKS_BANK_NOT_US)).thenReturn(ACH_BANK_NOT_US_ERROR_MESSAGE);
    return configService;
}
Also used : ConfigurationService(org.kuali.kfs.core.api.config.property.ConfigurationService)

Example 8 with ConfigurationService

use of org.kuali.kfs.core.api.config.property.ConfigurationService 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 9 with ConfigurationService

use of org.kuali.kfs.core.api.config.property.ConfigurationService in project cu-kfs by CU-CommunityApps.

the class CuContractsGrantsInvoiceDocumentAction method getContractsGrantsInvoiceDocumentWarningMessage.

protected String getContractsGrantsInvoiceDocumentWarningMessage(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument) {
    if (contractsGrantsInvoiceDocument.isCorrectionDocument()) {
        return StringUtils.EMPTY;
    }
    List<String> warningMessages = new ArrayList<>();
    ConfigurationService configurationService = SpringContext.getBean(ConfigurationService.class);
    if (contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().isFinalBillIndicator()) {
        warningMessages.add(configurationService.getPropertyValueAsString(CUKFSKeyConstants.WARNING_CINV_FINAL_BILL_INDICATOR));
    }
    String billingPeriod = contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getBillingPeriod();
    if (StringUtils.length(billingPeriod) != CuArConstants.CINV_DATE_RANGE_EXPECTED_FORMAT_LENGTH) {
        billingPeriod = StringUtils.defaultString(billingPeriod);
        String warningMessage = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(CUKFSKeyConstants.WARNING_CINV_DATE_RANGE_INVALID_FORMAT_LENGTH);
        warningMessages.add(MessageFormat.format(warningMessage, new String[] { billingPeriod }));
    } else if (shouldValidateBillingPeriodDateRange(contractsGrantsInvoiceDocument)) {
        try {
            validateBillingPeriodDateRange(contractsGrantsInvoiceDocument, warningMessages);
        } catch (ParseException ex) {
            LOG.error("getContractsGrantsInvoiceDocumentWarningMessage: " + ex.getMessage());
            String warningMessage = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(CUKFSKeyConstants.WARNING_CINV_DATE_RANGE_PARSE_EXCEPTION);
            warningMessages.add(MessageFormat.format(warningMessage, new String[] { billingPeriod }));
        }
    }
    return StringUtils.join(warningMessages, CuArConstants.QUESTION_NEWLINE_STRING);
}
Also used : ArrayList(java.util.ArrayList) ConfigurationService(org.kuali.kfs.core.api.config.property.ConfigurationService) ParseException(java.text.ParseException)

Example 10 with ConfigurationService

use of org.kuali.kfs.core.api.config.property.ConfigurationService in project cu-kfs by CU-CommunityApps.

the class CreateDoneKualiBatchFileAdminAction method createDoneFile.

/**
 * Creates a '.done' file with the name of the original file.
 */
protected String createDoneFile(String filename) {
    String status = null;
    String doneFileName = StringUtils.substringBeforeLast(filename, ".") + ".done";
    File doneFile = new File(doneFileName);
    ConfigurationService kualiConfigurationService = SpringContext.getBean(ConfigurationService.class);
    if (!doneFile.exists()) {
        boolean doneFileCreated = false;
        try {
            doneFileCreated = doneFile.createNewFile();
            status = kualiConfigurationService.getPropertyValueAsString(CUKFSKeyConstants.MESSAGE_DONE_FILE_SUCCESSFULLY_CREATED);
        } catch (IOException e) {
            throw new RuntimeException("Errors encountered while saving the file: Unable to create .done file " + doneFileName, e);
        }
        if (!doneFileCreated) {
            throw new RuntimeException("Errors encountered while saving the file: Unable to create .done file " + doneFileName);
        }
    } else {
        status = kualiConfigurationService.getPropertyValueAsString(CUKFSKeyConstants.MESSAGE_DONE_FILE_ALREADY_EXISTS);
    }
    return status;
}
Also used : ConfigurationService(org.kuali.kfs.core.api.config.property.ConfigurationService) IOException(java.io.IOException) CreateDoneBatchFile(edu.cornell.kfs.sys.batch.CreateDoneBatchFile) File(java.io.File) BatchFile(org.kuali.kfs.sys.batch.BatchFile)

Aggregations

ConfigurationService (org.kuali.kfs.core.api.config.property.ConfigurationService)13 DateTimeService (org.kuali.kfs.core.api.datetime.DateTimeService)3 Date (java.sql.Date)2 ParseException (java.text.ParseException)2 CuDisbursementVoucherDefaultDueDateService (edu.cornell.kfs.fp.document.service.CuDisbursementVoucherDefaultDueDateService)1 CreateDoneBatchFile (edu.cornell.kfs.sys.batch.CreateDoneBatchFile)1 File (java.io.File)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Pair (org.apache.commons.lang3.tuple.Pair)1 ActionForward (org.apache.struts.action.ActionForward)1 Before (org.junit.Before)1 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)1 ActionTaken (org.kuali.kfs.kew.actiontaken.ActionTaken)1 UserOptions (org.kuali.kfs.kew.useroptions.UserOptions)1 BatchFile (org.kuali.kfs.sys.batch.BatchFile)1 BatchInputFileServiceImpl (org.kuali.kfs.sys.batch.service.impl.BatchInputFileServiceImpl)1