use of org.kuali.kfs.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class RecurringDisbursementVoucherDocumentServiceImpl method addNoteToAutoApproveDv.
private void addNoteToAutoApproveDv(CuDisbursementVoucherDocument dv, String noteText) throws WorkflowException {
Note note = buildNoteBase();
note.setNoteText(noteText);
dv.addNote(note);
try {
getDocumentService().saveDocument(dv);
} catch (WorkflowException e) {
LOG.error("addNoteToAutoApproveDv: Unable to save note for DV Document ID::" + dv.getDocumentNumber() + "the exception was: ", e);
throw e;
}
}
use of org.kuali.kfs.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;
}
use of org.kuali.kfs.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.kfs.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuPurapServiceImpl method saveRoutingDataForRelatedDocuments.
// ==== CU Customization (KFSPTS-1656): Save IWantDocument routing data. ====
@Override
public void saveRoutingDataForRelatedDocuments(Integer accountsPayablePurchasingDocumentLinkIdentifier) {
super.saveRoutingDataForRelatedDocuments(accountsPayablePurchasingDocumentLinkIdentifier);
try {
// Save IWNT routing data.
@SuppressWarnings("unchecked") List<IWantView> iWantViews = getRelatedViews(IWantView.class, accountsPayablePurchasingDocumentLinkIdentifier);
for (Iterator<IWantView> iterator = iWantViews.iterator(); iterator.hasNext(); ) {
IWantView view = (IWantView) iterator.next();
Document doc = documentService.getByDocumentHeaderId(view.getDocumentNumber());
doc.getDocumentHeader().getWorkflowDocument().saveDocumentData();
}
} catch (WorkflowException e) {
throw new InfrastructureException("unable to save routing data for related docs", e);
}
}
use of org.kuali.kfs.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuReceivingServiceImpl method spawnPoAmendmentForUnorderedItems.
protected void spawnPoAmendmentForUnorderedItems(ReceivingDocument receivingDocument, PurchaseOrderDocument po) {
// if receiving line document
if (receivingDocument instanceof LineItemReceivingDocument) {
LineItemReceivingDocument rlDoc = (LineItemReceivingDocument) receivingDocument;
// if a new item has been added spawn a purchase order amendment
if (hasNewUnorderedItem((LineItemReceivingDocument) receivingDocument)) {
String newSessionUserId = KFSConstants.SYSTEM_USER;
try {
LogicContainer logicToRun = new LogicContainer() {
@Override
public Object runLogic(Object[] objects) throws Exception {
LineItemReceivingDocument rlDoc = (LineItemReceivingDocument) objects[0];
String poDocNumber = (String) objects[1];
// create a PO amendment
PurchaseOrderAmendmentDocument amendmentPo = (PurchaseOrderAmendmentDocument) purchaseOrderService.createAndSavePotentialChangeDocument(poDocNumber, PurchaseOrderDocTypes.PURCHASE_ORDER_AMENDMENT_DOCUMENT, PurchaseOrderStatuses.APPDOC_AMENDMENT);
// KFSPTS-1769, KFSUPGRADE-339
((CuPurchaseOrderAmendmentDocument) amendmentPo).setSpawnPoa(true);
// add new lines to amendement
addUnorderedItemsToAmendment(amendmentPo, rlDoc);
// route amendment
documentService.routeDocument(amendmentPo, null, null);
// add note to amendment po document
String note = "Purchase Order Amendment " + amendmentPo.getPurapDocumentIdentifier() + " (document id " + amendmentPo.getDocumentNumber() + ") created for new unordered line items due to Receiving (document id " + rlDoc.getDocumentNumber() + ")";
Note noteObj = documentService.createNoteFromDocument(amendmentPo, note);
amendmentPo.addNote(noteObj);
noteService.save(noteObj);
return null;
}
};
purapService.performLogicWithFakedUserSession(newSessionUserId, logicToRun, new Object[] { rlDoc, po.getDocumentNumber() });
} catch (WorkflowException e) {
String errorMsg = "Workflow Exception caught: " + e.getLocalizedMessage();
throw new RuntimeException(errorMsg, e);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}
Aggregations