use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuElectronicInvoiceHelperServiceImpl method createRejectDocument.
public ElectronicInvoiceRejectDocument createRejectDocument(ElectronicInvoice eInvoice, ElectronicInvoiceOrder electronicInvoiceOrder, ElectronicInvoiceLoad eInvoiceLoad) {
LOG.info("Creating reject document [DUNS=" + eInvoice.getDunsNumber() + ",POID=" + electronicInvoiceOrder.getInvoicePurchaseOrderID() + "]");
ElectronicInvoiceRejectDocument eInvoiceRejectDocument;
try {
eInvoiceRejectDocument = (ElectronicInvoiceRejectDocument) SpringContext.getBean(DocumentService.class).getNewDocument("EIRT");
eInvoiceRejectDocument.setInvoiceProcessTimestamp(SpringContext.getBean(DateTimeService.class).getCurrentTimestamp());
String rejectdocDesc = generateRejectDocumentDescription(eInvoice, electronicInvoiceOrder);
eInvoiceRejectDocument.getDocumentHeader().setDocumentDescription(rejectdocDesc);
eInvoiceRejectDocument.setDocumentCreationInProgress(true);
eInvoiceRejectDocument.setFileLevelData(eInvoice);
eInvoiceRejectDocument.setInvoiceOrderLevelData(eInvoice, electronicInvoiceOrder);
SpringContext.getBean(DocumentService.class).saveDocument(eInvoiceRejectDocument);
String noteText = "Invoice file";
attachInvoiceXMLWithRejectDoc(eInvoiceRejectDocument, getInvoiceFile(eInvoice.getFileName()), noteText);
eInvoiceLoad.addInvoiceReject(eInvoiceRejectDocument);
} catch (WorkflowException e) {
throw new RuntimeException(e);
}
LOG.info("Reject document has been created (DocNo=" + eInvoiceRejectDocument.getDocumentNumber() + ")");
emailTextErrorList.append("DUNS Number - " + eInvoice.getDunsNumber() + " " + eInvoice.getVendorName() + ":\n");
emailTextErrorList.append("An e-invoice from file '" + eInvoice.getFileName() + "' has been rejected due to the following error(s):\n");
// get note text max length from DD
int noteTextMaxLength = NOTE_TEXT_DEFAULT_MAX_LENGTH;
Integer noteTextLength = SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(Note.class, KRADConstants.NOTE_TEXT_PROPERTY_NAME);
if (noteTextLength != null) {
noteTextMaxLength = noteTextLength.intValue();
}
// KFSUPGRADE-489/KITI-2643 - Modified to fix bug reported in KFSPTS-292
// Ensure that we don't overflow the maximum size of the note by creating
// separate notes if necessary.
ArrayList<StringBuffer> rejectReasonNotes = new ArrayList<StringBuffer>();
StringBuffer rejectReasonNote = new StringBuffer();
String rejectReason = "";
rejectReasonNote.append("This reject document has been created because of the following reason(s):\n");
int index = 1;
for (ElectronicInvoiceRejectReason reason : eInvoiceRejectDocument.getInvoiceRejectReasons()) {
emailTextErrorList.append(" - " + reason.getInvoiceRejectReasonDescription() + "\n");
emailTextErrorList.append(" - PO " + eInvoiceRejectDocument.getPurchaseOrderIdentifier() + "\n");
emailTextErrorList.append(" - EIRT " + eInvoiceRejectDocument.getDocumentNumber() + "\n");
// addRejectReasonsToNote("Reject Reason " + index + ". " + reason.getInvoiceRejectReasonDescription(), eInvoiceRejectDocument);
rejectReason = " " + index + ". " + reason.getInvoiceRejectReasonDescription() + "\n";
if (rejectReasonNote.length() + rejectReason.length() > noteTextMaxLength) {
rejectReasonNotes.add(rejectReasonNote);
rejectReasonNote = new StringBuffer();
rejectReasonNote.append("Reject document creation reasons continued:\n");
}
rejectReasonNote.append(rejectReason);
index++;
}
rejectReasonNotes.add(rejectReasonNote);
emailTextErrorList.append("\n");
for (StringBuffer noteText : rejectReasonNotes) {
addRejectReasonsToNote(noteText.toString(), eInvoiceRejectDocument);
}
return eInvoiceRejectDocument;
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuElectronicInvoiceHelperServiceImpl method routePREQDocuments.
/**
* @return
*/
protected boolean routePREQDocuments() {
Collection<String> documentIdList = null;
try {
documentIdList = retrieveDocumentsToRoute(KewApiConstants.ROUTE_HEADER_SAVED_CD, PaymentRequestDocument.class);
} catch (WorkflowException e1) {
LOG.error("Error retrieving preq documents for routing: " + e1.getMessage(), e1);
throw new RuntimeException(e1.getMessage(), e1);
} catch (RemoteException re) {
LOG.error("Error retrieving preq documents for routing: " + re.getMessage(), re);
throw new RuntimeException(re.getMessage(), re);
}
// Collections.reverse(documentIdList);
LOG.info("PREQs to Route: " + documentIdList);
DocumentService documentService = SpringContext.getBean(DocumentService.class);
WorkflowDocumentService workflowDocumentService = SpringContext.getBean(WorkflowDocumentService.class);
for (String preqDocumentId : documentIdList) {
try {
LOG.info("Retrieving PREQ document # " + preqDocumentId + ".");
PaymentRequestDocument preqDocument = (PaymentRequestDocument) documentService.getByDocumentHeaderId(preqDocumentId);
LOG.info("Routing PREQ document # " + preqDocumentId + ".");
if (preqDocument.getPaymentRequestElectronicInvoiceIndicator()) {
documentService.prepareWorkflowDocument(preqDocument);
LOG.info("PREQ document # " + preqDocumentId + " prepared for workflow.");
// calling workflow service to bypass business rule checks
workflowDocumentService.route(preqDocument.getDocumentHeader().getWorkflowDocument(), "Routed by electronic invoice batch job", null);
LOG.info("PREQ document # " + preqDocumentId + " routed.");
}
} catch (WorkflowException e) {
LOG.error("Error routing document # " + preqDocumentId + " " + 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 CuPdpExtractServiceImpl method updatePaymentRequest.
@Override
protected void updatePaymentRequest(PaymentRequestDocument paymentRequestDocument, Person puser, Date processRunDate) {
try {
PaymentRequestDocument doc = (PaymentRequestDocument) documentService.getByDocumentHeaderId(paymentRequestDocument.getDocumentNumber());
doc.setExtractedTimestamp(new Timestamp(processRunDate.getTime()));
SpringContext.getBean(PurapService.class).saveDocumentNoValidation(doc);
// RICE20 replaced searchableAttributeProcessingService.indexDocument with DocumentAttributeIndexingQueue.indexDocument
DocumentTypeService documentTypeService = SpringContext.getBean(DocumentTypeService.class);
DocumentType documentType = documentTypeService.getDocumentTypeByName(doc.getFinancialDocumentTypeCode());
DocumentAttributeIndexingQueue queue = KewApiServiceLocator.getDocumentAttributeIndexingQueue(documentType.getApplicationId());
queue.indexDocument(doc.getDocumentNumber());
} catch (WorkflowException e) {
throw new IllegalArgumentException("Unable to retrieve payment request: " + paymentRequestDocument.getDocumentNumber());
}
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class AutoCancelBatchDaoJdbc method cancelDocuments.
/**
* @see AutoCancelBatchDao#cancelDocuments()
*/
@Override
public void cancelDocuments() throws Exception {
final String daysToAutoCancel = parameterService.getParameterValueAsString(AutoCancelBatchStep.class, CUKFSParameterKeyConstants.DAYS_TO_AUTO_CANCEL_PARAMETER);
if (StringUtils.isNotBlank(daysToAutoCancel)) {
Map<String, String> cancelIds = findSavedDocumentIds(Integer.parseInt(daysToAutoCancel));
Set<String> cancelDocumentIds = cancelIds.keySet();
int canceledDocumentCount = 0;
for (String docId : cancelDocumentIds) {
String docTypeId = cancelIds.get(docId);
if (canAutoCancelDocType(docTypeId)) {
LOG.info("Retrieving document : " + docId.trim());
Document document = documentService.getByDocumentHeaderId(docId.trim());
try {
if (!ObjectUtils.isNull(document)) {
LOG.info("Document Number to cancel : " + document.getDocumentNumber());
canceledDocumentCount++;
documentService.prepareWorkflowDocument(document);
workflowDocumentService.superUserCancel(document.getDocumentHeader().getWorkflowDocument(), "AutoCancelBatchStep: Older Than " + daysToAutoCancel + " Days");
sessionDocumentService.addDocumentToUserSession(GlobalVariables.getUserSession(), document.getDocumentHeader().getWorkflowDocument());
}
} catch (WorkflowException e) {
LOG.error("AutoCancelBatchStep Encountered WorkflowException " + document.getDocumentNumber(), e);
}
}
}
LOG.info("Total number of docs canceled : " + canceledDocumentCount);
} else {
LOG.info("ERROR: DAYS_TO_CANCEL parameter is empty or missing");
}
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherExtractionHelperServiceImplTest method test.
public void test() {
CuDisbursementVoucherDocument dv = null;
try {
dv = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
} catch (WorkflowException e) {
throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
}
if (dv != null) {
dv.getDocumentHeader().setDocumentDescription("Test Document Description");
dv.getDocumentHeader().setExplanation("Stuff");
dv.initiateDocument();
VendorDetail vendor = SpringContext.getBean(VendorService.class).getVendorDetail("13366-0");
VendorAddress vendoraddress = SpringContext.getBean(VendorService.class).getVendorDefaultAddress(vendor.getVendorHeaderGeneratedIdentifier(), vendor.getVendorDetailAssignedIdentifier(), "RM", "");
System.out.println(vendoraddress.getVendorCityName() + "\n");
dv.templateVendor(vendor, vendoraddress);
dv.setPayeeAssigned(true);
dv.getDvPayeeDetail().setDisbVchrPaymentReasonCode("S");
dv.setDisbVchrCheckTotalAmount(new KualiDecimal(86.00));
dv.setDisbVchrPaymentMethodCode("P");
dv.setDisbVchrCheckStubText("check text");
dv.setCampusCode("IT");
SourceAccountingLine accountingLine = new SourceAccountingLine();
accountingLine.setChartOfAccountsCode("IT");
accountingLine.setAccountNumber("G081040");
accountingLine.setFinancialObjectCode("2045");
accountingLine.setAmount((new KualiDecimal(86.00)));
accountingLine.setPostingYear(dv.getPostingYear());
accountingLine.setDocumentNumber(dv.getDocumentNumber());
dv.addSourceAccountingLine(accountingLine);
try {
documentService.saveDocument(dv);
} catch (WorkflowException e) {
throw new RuntimeException("Error saving new disbursement voucher document: " + e.getMessage(), e);
}
}
Date transactionTimestamp = new Date(SpringContext.getBean(DateTimeService.class).getCurrentDate().getTime());
Date processRunDate = new java.sql.Date(transactionTimestamp.getTime());
PaymentGroup pg = cuDisbursementVoucherExtractionHelperService.createPaymentGroup(dv, processRunDate);
assertTrue(pg.getPaymentDetails().get(0).getCustPaymentDocNbr().equalsIgnoreCase(dv.getDocumentNumber()));
}
Aggregations