use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class AdvanceDepositServiceImpl method createAdvanceDepositDocument.
/**
* Creates a AdvanceDepositDocument from the List of transactions given.
*
* @param transaction List of CashReceiptDocument objects to be used for creating the document.
* @return A AdvanceDepositDocument populated with the transactions provided.
*/
protected AdvanceDepositDocument createAdvanceDepositDocument(AchIncomeTransaction transaction) {
AdvanceDepositDocument advanceDepositDocument;
try {
String detailReferenceNumber = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.DETAIL_REFERENCE_NUMBER);
String detailDescription = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.DETAIL_DESCRIPTION);
String bankCode = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.BANK_CODE);
String documentDescription = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.DOCUMENT_DESCRIPTION);
advanceDepositDocument = (AdvanceDepositDocument) documentService.getNewDocument(KFSConstants.FinancialDocumentTypeCodes.ADVANCE_DEPOSIT);
advanceDepositDocument.getDocumentHeader().setDocumentDescription(documentDescription);
advanceDepositDocument.setCampusLocationCode(CuFPConstants.ADVANCE_DEPOSIT_DEFAULT_CAMPUS_CODE);
advanceDepositDocument.setDepositDate(dateTimeService.convertToSqlDate(transaction.getBankTimestamp()));
createSourceAccountingLine(transaction, advanceDepositDocument);
AdvanceDepositDetail advanceDepositDetail = new AdvanceDepositDetail();
advanceDepositDetail.setDocumentNumber(advanceDepositDocument.getDocumentNumber());
advanceDepositDetail.setFinancialDocumentAdvanceDepositDate(dateTimeService.convertToSqlDate(transaction.getLoadTimestamp()));
advanceDepositDetail.setFinancialDocumentAdvanceDepositAmount(transaction.getTransactionAmount());
advanceDepositDetail.setFinancialDocumentAdvanceDepositReferenceNumber(detailReferenceNumber);
advanceDepositDetail.setFinancialDocumentAdvanceDepositDescription(detailDescription);
advanceDepositDetail.setFinancialDocumentBankCode(bankCode);
Bank bank = bankService.getByPrimaryId(bankCode);
advanceDepositDetail.setBank(bank);
advanceDepositDocument.addAdvanceDeposit(advanceDepositDetail);
} catch (WorkflowException | ParseException e) {
LOG.error("Error creating advance deposit documents: " + e.getMessage(), e);
throw new RuntimeException("Error creating advance deposit documents: " + e.getMessage(), e);
}
return advanceDepositDocument;
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CorporateBilledCorporatePaidCreateDocumentServiceImpl method routeProcurementCardDocuments.
@Override
public boolean routeProcurementCardDocuments() {
LOG.debug("routeProcurementCardDocuments() started");
Collection<CorporateBilledCorporatePaidDocument> cbcpDocumentList = retrieveCorporateBilledCorporatePaidDocuments(KewApiConstants.ROUTE_HEADER_SAVED_CD);
LOG.info("routeProcurementCardDocuments() Number of CBCP documents to Route: " + cbcpDocumentList.size());
Map<String, String> documentErrors = new HashMap<String, String>();
List<String> successfulDocuments = new ArrayList<String>();
for (CorporateBilledCorporatePaidDocument cbcpDocument : cbcpDocumentList) {
try {
LOG.info("routeProcurementCardDocuments() Routing CBCP document # " + cbcpDocument.getDocumentNumber() + ".");
documentService.prepareWorkflowDocument(cbcpDocument);
documentService.routeDocument(cbcpDocument, "CBCP document automatically routed", new ArrayList<AdHocRouteRecipient>());
successfulDocuments.add(cbcpDocument.getDocumentNumber());
} catch (WorkflowException we) {
documentErrors.put(cbcpDocument.getDocumentNumber(), "Workflow error: " + we.getMessage());
GlobalVariables.getMessageMap().clearErrorMessages();
LOG.error("routeProcurementCardDocuments, workflow error routing document # " + cbcpDocument.getDocumentNumber() + " " + we.getMessage(), we);
} catch (ValidationException ve) {
documentErrors.put(cbcpDocument.getDocumentNumber(), corporateBilledCorporatePaidRouteStepReportService.buildValidationErrorMessage(ve));
GlobalVariables.getMessageMap().clearErrorMessages();
LOG.error("routeProcurementCardDocuments, Error routing document # " + cbcpDocument.getDocumentNumber() + " " + ve.getMessage(), ve);
}
}
createAndEmailReport(cbcpDocumentList, documentErrors, successfulDocuments);
return true;
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class AdvanceDepositServiceImpl method routeAdvanceDepositDocuments.
/**
* @see AdvanceDepositService#routeAdvanceDepositDocuments()
*/
public boolean routeAdvanceDepositDocuments() {
List<String> documentIdList;
try {
documentIdList = retrieveAdvanceDepositDocumentsToRoute(KewApiConstants.ROUTE_HEADER_SAVED_CD);
} catch (WorkflowException | RemoteException e) {
LOG.error("Error retrieving advance deposit documents for routing: " + e.getMessage(), e);
throw new RuntimeException(e.getMessage(), e);
}
if (LOG.isInfoEnabled()) {
LOG.info("Advance deposit to Route: " + documentIdList);
}
for (String documentId : documentIdList) {
try {
AdvanceDepositDocument advanceDocument = (AdvanceDepositDocument) documentService.getByDocumentHeaderId(documentId);
if (LOG.isInfoEnabled()) {
LOG.info("Routing advance deposit document # " + documentId + ".");
}
documentService.routeDocument(advanceDocument, "document routed by achIncome batch job", null);
} catch (Exception e) {
LOG.error("Error routing document # " + documentId + " due to exception: " + e.getMessage());
logException(e);
}
}
return true;
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuPurchaseOrderAmendmentDocument method isSeparationOfDutiesReviewRequired.
protected boolean isSeparationOfDutiesReviewRequired() {
try {
Set<Person> priorApprovers = getAllPriorApprovers();
// then no need for separation of duties
if (priorApprovers.size() > 0) {
return false;
}
} catch (WorkflowException we) {
LOG.error("Exception while attempting to retrieve all prior approvers from workflow: " + we);
}
ParameterService parameterService = SpringContext.getBean(ParameterService.class);
KualiDecimal maxAllowedAmount = new KualiDecimal(parameterService.getParameterValueAsString(RequisitionDocument.class, PurapParameterConstants.SEPARATION_OF_DUTIES_DOLLAR_AMOUNT));
// if app param amount is greater than or equal to documentTotalAmount... no need for separation of duties
KualiDecimal totalAmount = getFinancialSystemDocumentHeader().getFinancialDocumentTotalAmount();
if (ObjectUtils.isNotNull(maxAllowedAmount) && ObjectUtils.isNotNull(totalAmount) && (maxAllowedAmount.compareTo(totalAmount) >= 0)) {
return false;
} else {
return true;
}
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuContractsAndGrantsResponsibilityPlusPayPeriodRoleTypeServiceImpl method documentIsWithinPayPeriodLimit.
/*
* Helper method for determining if the difference between the document's create date period and
* the earliest account pay period is within the given limit. Assumed to be within limit unless
* proven otherwise.
*/
private boolean documentIsWithinPayPeriodLimit(String documentNumber, int limit) {
boolean withinLimit = true;
AccountingDocument document;
// Get the document, which is expected to be an accounting one.
try {
document = (AccountingDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(documentNumber);
} catch (WorkflowException e) {
document = null;
} catch (ClassCastException e) {
document = null;
}
// Skip non-existent or non-retrievable documents, and have them default to within-limit routing.
if (document == null) {
return true;
}
// Make sure source/target lines containing the extra labor-ledger-related data actually exist on the document.
boolean hasLLSourceLine = document.getSourceAccountingLineClass() != null && CollectionUtils.isNotEmpty(document.getSourceAccountingLines()) && LaborLedgerExpenseTransferAccountingLine.class.isAssignableFrom(document.getSourceAccountingLineClass());
boolean hasLLTargetLine = document.getTargetAccountingLineClass() != null && CollectionUtils.isNotEmpty(document.getTargetAccountingLines()) && LaborLedgerExpenseTransferAccountingLine.class.isAssignableFrom(document.getTargetAccountingLineClass());
if (hasLLSourceLine || hasLLTargetLine) {
// Locate the earliest source/target line.
LaborLedgerExpenseTransferAccountingLine earliestLine = null;
if (hasLLSourceLine) {
earliestLine = findEarliestPayPeriodAccountingLine(document.getSourceAccountingLines());
}
if (hasLLTargetLine) {
if (earliestLine != null) {
LaborLedgerExpenseTransferAccountingLine earliestTargetLine = findEarliestPayPeriodAccountingLine(document.getTargetAccountingLines());
earliestLine = (earliestTargetLine == null) ? earliestLine : findEarliestPayPeriodAccountingLine(Arrays.asList(earliestLine, earliestTargetLine));
} else {
earliestLine = findEarliestPayPeriodAccountingLine(document.getTargetAccountingLines());
}
}
// If an earliest line was found, then proceed with the within-limit determination.
if (earliestLine != null) {
// Prepare helper constants.
final int NUM_MONTHS = 12;
final int FY_OFFSET = 6;
// Get the creation date, and calculate its corresponding fiscal year and pay period.
DateTime dateCreated = document.getDocumentHeader().getWorkflowDocument().getDateCreated();
int dateCreatedFiscalYear;
int dateCreatedPayPeriod = dateCreated.getMonthOfYear() + FY_OFFSET;
if (dateCreatedPayPeriod > NUM_MONTHS) {
dateCreatedPayPeriod -= NUM_MONTHS;
}
dateCreatedFiscalYear = dateCreated.getYear() + ((dateCreatedPayPeriod <= FY_OFFSET) ? 1 : 0);
// Determine difference between the pay period the doc was created in and the earliest impacted source/target account's pay period.
int payPeriodDifference = ((dateCreatedFiscalYear - earliestLine.getPayrollEndDateFiscalYear().intValue()) * NUM_MONTHS) + dateCreatedPayPeriod - Integer.parseInt(earliestLine.getPayrollEndDateFiscalPeriodCode());
// Set flag based on whether the difference is within the limit for standard Award node routing.
withinLimit = payPeriodDifference <= limit;
}
}
return withinLimit;
}
Aggregations