use of org.kuali.kfs.coreservice.framework.parameter.ParameterService in project cu-kfs by CU-CommunityApps.
the class TaxProcessingServiceImpl method doTaxProcessing.
@Override
@Transactional
public void doTaxProcessing(String taxType, java.util.Date processingStartDate) {
if (processingStartDate == null) {
throw new IllegalArgumentException("processingStartDate cannot be null");
}
ParameterService parameterService = CoreFrameworkServiceLocator.getParameterService();
String taxDetailType;
int reportYear;
java.sql.Date startDate;
java.sql.Date endDate;
boolean vendorForeign;
/*
* Perform basic tax-type-specific setup.
*/
if (CUTaxConstants.TAX_TYPE_1099.equals(taxType)) {
// Do 1099 tax processing.
taxDetailType = CUTaxConstants.TAX_1099_PARM_DETAIL;
vendorForeign = false;
} else if (CUTaxConstants.TAX_TYPE_1042S.equals(taxType)) {
// Do 1042S tax processing.
taxDetailType = CUTaxConstants.TAX_1042S_PARM_DETAIL;
vendorForeign = true;
} else {
throw new IllegalArgumentException("Invalid tax reporting type");
}
/*
* Determine report year, start date, and end date.
*/
Collection<String> datesToProcess = parameterService.getParameterValuesAsString(CUTaxConstants.TAX_NAMESPACE, taxDetailType, taxType + TaxCommonParameterNames.DATES_TO_PROCESS_PARAMETER_SUFFIX);
Calendar tempCalendar = CoreApiServiceLocator.getDateTimeService().getCurrentCalendar();
if (datesToProcess.isEmpty()) {
throw new IllegalStateException("Dates-to-process parameter cannot be empty or absent");
} else if (datesToProcess.size() == 1) {
// If single value, then it should equal a specific year (or a shortcut value representing a recent year).
String yearValue = datesToProcess.iterator().next();
if (CUTaxConstants.YEAR_TO_DATE.equals(yearValue)) {
// Current tax year; set report year to current year and end date to current date.
reportYear = tempCalendar.get(Calendar.YEAR);
endDate = new java.sql.Date(tempCalendar.getTime().getTime());
} else if (CUTaxConstants.PREVIOUS_YEAR_TO_DATE.equals(yearValue)) {
// Previous tax year; set report year to previous year and end date to December 31 of previous year.
tempCalendar.set(tempCalendar.get(Calendar.YEAR) - 1, Calendar.DECEMBER, DAY_31);
reportYear = tempCalendar.get(Calendar.YEAR);
endDate = new java.sql.Date(tempCalendar.getTime().getTime());
} else {
// Specific year; set report year to given year and end date to current date or December 31 of given year, depending on current year.
try {
reportYear = Integer.parseInt(yearValue);
} catch (NumberFormatException e) {
throw new IllegalStateException("Dates-to-process parameter's literal year value was not an integer");
}
if (reportYear != tempCalendar.get(Calendar.YEAR)) {
tempCalendar.set(reportYear, Calendar.DECEMBER, DAY_31);
}
endDate = new java.sql.Date(tempCalendar.getTime().getTime());
}
// In all year-only cases, set start date to January 1 of given year.
tempCalendar.set(reportYear, Calendar.JANUARY, 1);
startDate = new java.sql.Date(tempCalendar.getTime().getTime());
} else if (datesToProcess.size() == 2) {
// If two values, then they should be start dates and end dates in the same year.
String[] dateValues = datesToProcess.toArray(new String[2]);
try {
startDate = CoreApiServiceLocator.getDateTimeService().convertToSqlDate(dateValues[0]);
endDate = CoreApiServiceLocator.getDateTimeService().convertToSqlDate(dateValues[1]);
} catch (ParseException e) {
throw new IllegalStateException("Dates-to-process parameter contains one or more invalid date values");
}
// Set report year to the year of the starting date.
tempCalendar.setTimeInMillis(startDate.getTime());
reportYear = tempCalendar.get(Calendar.YEAR);
// Make sure the dates are in the same year, and start date is earlier than or equal to end date.
tempCalendar.setTimeInMillis(endDate.getTime());
if (reportYear != tempCalendar.get(Calendar.YEAR)) {
throw new IllegalStateException("Dates-to-process parameter's start and end dates are not in the same year");
} else if (startDate.compareTo(endDate) > 0) {
throw new IllegalStateException("Dates-to-process parameter's start date cannot be later than its end date");
}
} else {
throw new IllegalStateException("Dates-to-process parameter cannot have more than two values");
}
/*
* Perform the main processing.
*/
LOG.info("==== Start of tax processing ====");
LOG.info("Performing " + taxType + " tax processing for the given time period:");
LOG.info("Report Year: " + Integer.toString(reportYear) + ", Start Date: " + startDate.toString() + ", End Date: " + endDate.toString());
taxProcessingDao.doTaxProcessing(taxType, reportYear, startDate, endDate, vendorForeign, processingStartDate);
LOG.info("==== End of tax processing ====");
}
use of org.kuali.kfs.coreservice.framework.parameter.ParameterService in project cu-kfs by CU-CommunityApps.
the class CuPaymentRequestServiceImplTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
paymentRequestService = SpringContext.getBean(PaymentRequestService.class);
// Override auto-approval-limit parameter for the duration of the test. The old value will be restored by the post-test rollback.
// NOTE: If this test class ever gets configured to not roll back, then this override should change accordingly to restore the old param value.
ParameterService parameterService = SpringContext.getBean(ParameterService.class);
Parameter oldAmountLimit = parameterService.getParameter(PaymentRequestDocument.class, CUPurapParameterConstants.DEFAULT_PURCHASE_ORDER_POS_APRVL_LMT_FOR_PREQ);
Parameter.Builder newAmountLimit = Parameter.Builder.create(oldAmountLimit);
newAmountLimit.setValue(RequisitionItemFixture.REQ_QTY_ITEM_AMOUNT_AT_5K.extendedPrice.toString());
parameterService.updateParameter(newAmountLimit.build());
}
use of org.kuali.kfs.coreservice.framework.parameter.ParameterService in project cu-kfs by CU-CommunityApps.
the class CreateAccountingDocumentServiceImplTest method buildParameterService.
private ParameterService buildParameterService() {
ParameterService parameterService = EasyMock.createMock(ParameterService.class);
EasyMock.expect(parameterService.getParameterValueAsString(KFSConstants.ParameterNamespaces.FINANCIAL, CuFPParameterConstants.CreateAccountingDocumentService.CREATE_ACCOUNTING_DOCUMENT_SERVICE_COMPONENT_NAME, CuFPParameterConstants.CreateAccountingDocumentService.CREATE_ACCT_DOC_REPORT_EMAIL_ADDRESS)).andStubAnswer(() -> "kfs-gl_fp@cornell.edu");
EasyMock.replay(parameterService);
return parameterService;
}
use of org.kuali.kfs.coreservice.framework.parameter.ParameterService in project cu-kfs by CU-CommunityApps.
the class AwsAccountingXmlDocumentAccountingLineServiceImplTest method buildMockParameterService.
private ParameterService buildMockParameterService() {
ParameterService parameterService = mock(ParameterService.class);
when(parameterService.getParameterValueAsString(KFSConstants.CoreModuleNamespaces.FINANCIAL, CuFPConstants.AmazonWebServiceBillingConstants.AWS_COMPENT_NAME, CuFPConstants.AmazonWebServiceBillingConstants.AWS_CHART_CODE_PROPERTY_NAME)).thenReturn(CuFPTestConstants.TEST_AWS_BILLING_DEFAULT_CHART_CODE);
when(parameterService.getParameterValueAsString(KFSConstants.CoreModuleNamespaces.FINANCIAL, CuFPConstants.AmazonWebServiceBillingConstants.AWS_COMPENT_NAME, CuFPConstants.AmazonWebServiceBillingConstants.AWS_OBJECT_CODE_PROPERTY_NAME)).thenReturn(CuFPTestConstants.TEST_AWS_DEFAULT_OBJ_CODE);
return parameterService;
}
use of org.kuali.kfs.coreservice.framework.parameter.ParameterService in project cu-kfs by CU-CommunityApps.
the class CuAssetServiceImplTest method createMockParameterServiceAllowRetiredAssets.
protected ParameterService createMockParameterServiceAllowRetiredAssets(boolean result) {
ParameterService parameterService = mock(ParameterServiceImpl.class);
when(parameterService.getParameterValueAsBoolean(CamsConstants.CAM_MODULE_CODE, "Asset", CuCamsConstants.Parameters.RE_USE_RETIRED_ASSET_TAG_NUMBER, Boolean.FALSE)).thenReturn(result);
List<String> statusCodes = new ArrayList<String>();
statusCodes.add(RETIRED_STATUS_CD);
when(parameterService.getParameterValuesAsString(Asset.class, CamsConstants.Parameters.RETIRED_STATUS_CODES)).thenReturn(statusCodes);
return parameterService;
}
Aggregations