use of org.kuali.rice.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);
}
}
}
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuElectronicInvoiceHelperServiceImpl method routeEIRTDocuments.
protected boolean routeEIRTDocuments() {
Collection<String> documentIdList = null;
try {
documentIdList = retrieveDocumentsToRoute(KewApiConstants.ROUTE_HEADER_SAVED_CD, ElectronicInvoiceRejectDocument.class);
} catch (WorkflowException e1) {
LOG.error("Error retrieving eirt documents for routing: " + e1.getMessage(), e1);
throw new RuntimeException(e1.getMessage(), e1);
} catch (RemoteException re) {
LOG.error("Error retrieving eirt documents for routing: " + re.getMessage(), re);
throw new RuntimeException(re.getMessage(), re);
}
// Collections.reverse(documentIdList);
LOG.info("EIRTs to Route: " + documentIdList);
DocumentService documentService = SpringContext.getBean(DocumentService.class);
WorkflowDocumentService workflowDocumentService = SpringContext.getBean(WorkflowDocumentService.class);
for (String eirtDocumentId : documentIdList) {
try {
LOG.info("Retrieving EIRT document # " + eirtDocumentId + ".");
ElectronicInvoiceRejectDocument eirtDocument = (ElectronicInvoiceRejectDocument) documentService.getByDocumentHeaderId(eirtDocumentId);
LOG.info("Routing EIRT document # " + eirtDocumentId + ".");
documentService.prepareWorkflowDocument(eirtDocument);
LOG.info("EIRT document # " + eirtDocumentId + " prepared for workflow.");
// calling workflow service to bypass business rule checks
workflowDocumentService.route(eirtDocument.getDocumentHeader().getWorkflowDocument(), "Routed by electronic invoice batch job", null);
LOG.info("EIRT document # " + eirtDocumentId + " routed.");
} catch (WorkflowException e) {
LOG.error("Error routing document # " + eirtDocumentId + " " + e.getMessage());
throw new RuntimeException(e.getMessage(), e);
}
}
return true;
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class SubmitTripWebServiceImpl method buildDisbursementVoucher.
/**
* @param dvDescription
* @param dvExplanation
* @param tripNumber
* @param travelerNetId
* @param initiatorNetId
* @param totalAmount
* @param checkStubText
* @return
* @throws Exception
*/
private String buildDisbursementVoucher(String dvDescription, String dvExplanation, String tripNumber, String travelerNetId, String initiatorNetId, double totalAmount, String checkStubText) throws Exception {
try {
if (!isValidDocumentInitiator(initiatorNetId, DISBURSEMENT_VOUCHER)) {
throw new RuntimeException("Initiator identified does not have permission to create a DV.");
}
} catch (Exception ex) {
throw new RuntimeException("Initiator identified does not have permission to create a DV.", ex);
}
// create and route doc as system user
GlobalVariables.setUserSession(new UserSession(initiatorNetId));
MessageMap documentErrorMap = new MessageMap();
GlobalVariables.setMessageMap(documentErrorMap);
// Create document with description provided
CuDisbursementVoucherDocument dvDoc = null;
try {
dvDoc = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
} catch (WorkflowException e) {
throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
}
if (dvDoc != null) {
dvDoc.getDocumentHeader().setDocumentDescription(dvDescription);
dvDoc.getDocumentHeader().setExplanation(dvExplanation);
dvDoc.getDocumentHeader().setOrganizationDocumentNumber(tripNumber);
dvDoc.initiateDocument();
// Set vendor to traveler using netID provided
Person traveler = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(travelerNetId);
for (EntityAffiliationContract entityAffiliation : ((PersonImpl) traveler).getAffiliations()) {
if (entityAffiliation.isDefaultValue()) {
if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STUDENT)) {
dvDoc.templateStudent(traveler);
} else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.ALUMNI)) {
dvDoc.templateAlumni(traveler);
} else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.FACULTY) || StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STAFF)) {
dvDoc.templateEmployee(traveler);
}
}
}
dvDoc.setPayeeAssigned(true);
dvDoc.getDvPayeeDetail().setDisbVchrPaymentReasonCode("J");
dvDoc.setDisbVchrCheckTotalAmount(new KualiDecimal(totalAmount));
dvDoc.setDisbVchrPaymentMethodCode("P");
dvDoc.setDisbVchrCheckStubText(checkStubText);
dvDoc.setTripId(tripNumber);
dvDoc.setTripAssociationStatusCode(CULegacyTravelServiceImpl.TRIP_ASSOCIATIONS.IS_TRIP_DOC);
// Persist document
SpringContext.getBean(DocumentService.class).saveDocument(dvDoc);
return dvDoc.getDocumentNumber();
} else {
return "";
}
}
use of org.kuali.rice.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.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuProcessPdpCancelPaidServiceImpl method processPdpPaid.
/**
* Default implementation uses most of the "while" loop contents from the ProcessPdpCancelPaidServiceImpl.processPdpPaids method,
* with additional CU-related changes as needed. This implementation also runs within its own transaction.
*/
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public void processPdpPaid(PaymentDetail paymentDetail, Date processDate) {
String documentTypeCode = paymentDetail.getFinancialDocumentTypeCode();
String documentNumber = paymentDetail.getCustPaymentDocNbr();
if (purchasingAccountsPayableModuleService.isPurchasingBatchDocument(documentTypeCode)) {
purchasingAccountsPayableModuleService.handlePurchasingBatchPaids(documentNumber, documentTypeCode, processDate);
} else {
PaymentSourceToExtractService<PaymentSource> extractService = getPaymentSourceToExtractService(paymentDetail);
if (extractService != null) {
try {
PaymentSource dv = (PaymentSource) documentService.getByDocumentHeaderId(documentNumber);
extractService.markAsPaid(dv, processDate);
} catch (WorkflowException we) {
throw new RuntimeException("Could not retrieve document #" + documentNumber, we);
}
} else {
LOG.warn("processPdpPaids() Unknown document type (" + documentTypeCode + ") for document ID: " + documentNumber);
return;
}
}
paymentGroupService.processPaidGroup(paymentDetail.getPaymentGroup(), processDate);
}
Aggregations