use of org.kuali.kfs.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);
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.kfs.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuPendingTransactionServiceImpl method reverseSourceDocumentsEntries.
/**
* Reverses the entries of the source documents
*
* @param paymentDetail
* @param sequenceHelper
*/
protected void reverseSourceDocumentsEntries(PaymentDetail paymentDetail, GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
// Need to reverse the payment document's GL entries if the check is stopped or cancelled
if (PurapConstants.PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT.equalsIgnoreCase(paymentDetail.getFinancialDocumentTypeCode()) || CUPdpConstants.PdpDocumentTypes.DISBURSEMENT_VOUCHER.equalsIgnoreCase(paymentDetail.getFinancialDocumentTypeCode()) || CUPdpConstants.PdpDocumentTypes.CREDIT_MEMO.equalsIgnoreCase(paymentDetail.getFinancialDocumentTypeCode())) {
try {
String sourceDocumentNumber = paymentDetail.getCustPaymentDocNbr();
try {
Long.valueOf(sourceDocumentNumber);
} catch (NumberFormatException nfe) {
sourceDocumentNumber = null;
}
if (sourceDocumentNumber != null && StringUtils.isNotBlank(sourceDocumentNumber)) {
Document doc = (AccountingDocumentBase) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(paymentDetail.getCustPaymentDocNbr());
if (ObjectUtils.isNotNull(doc)) {
if (doc instanceof DisbursementVoucherDocument) {
// KFSUPGRADE-775
DisbursementVoucherDocument dv = (DisbursementVoucherDocument) doc;
generateDisbursementVoucherReversalEntries(dv, sequenceHelper);
// end KFSUPGRADE-775
} else if (doc instanceof VendorCreditMemoDocument) {
// KFSPTS-2719
String crCmCancelNote = parameterService.getParameterValueAsString(VendorCreditMemoDocument.class, CUPurapParameterConstants.PURAP_CR_CM_CANCEL_NOTE);
VendorCreditMemoDocument cmDocument = (VendorCreditMemoDocument) doc;
String crCancelMaintDocNbr = getCrCancelMaintenancedocumentNumber(paymentDetail);
crCmCancelNote = crCmCancelNote + crCancelMaintDocNbr;
try {
Note noteObj = documentService.createNoteFromDocument(cmDocument, crCmCancelNote);
cmDocument.addNote(noteObj);
noteService.save(noteObj);
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
// KFSUPGRADE-775
VendorCreditMemoDocument cm = (VendorCreditMemoDocument) doc;
AccountsPayableDocumentSpecificService accountsPayableDocumentSpecificService = cm.getDocumentSpecificService();
accountsPayableDocumentSpecificService.updateStatusByNode("", cm);
// end KFSUPGRADE-775
generateCreditMemoReversalEntries((VendorCreditMemoDocument) doc);
} else if (doc instanceof PaymentRequestDocument) {
// KFSPTS-2719
String crPreqCancelNote = parameterService.getParameterValueAsString(PaymentRequestDocument.class, CUPurapParameterConstants.PURAP_CR_PREQ_CANCEL_NOTE);
PaymentRequestDocument paymentRequest = (PaymentRequestDocument) doc;
String crCancelMaintDocNbr = getCrCancelMaintenancedocumentNumber(paymentDetail);
crPreqCancelNote = crPreqCancelNote + crCancelMaintDocNbr;
try {
Note cancelNote = documentService.createNoteFromDocument(paymentRequest, crPreqCancelNote);
paymentRequest.addNote(cancelNote);
noteService.save(cancelNote);
} catch (Exception e) {
throw new RuntimeException(PurapConstants.REQ_UNABLE_TO_CREATE_NOTE + " " + e);
}
// cancel extracted should not reopen PO
paymentRequest.setReopenPurchaseOrderIndicator(false);
// KFSUPGRADE-775
AccountsPayableDocumentSpecificService accountsPayableDocumentSpecificService = paymentRequest.getDocumentSpecificService();
accountsPayableDocumentSpecificService.updateStatusByNode("", paymentRequest);
// end KFSUPGRADE-775
generatePaymentRequestReversalEntries(paymentRequest);
}
}
}
} catch (WorkflowException we) {
System.out.println("Exception retrieving document " + paymentDetail.getCustPaymentDocNbr());
}
}
}
use of org.kuali.kfs.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class PaymentWorksVendorDataProcessingIntoKfsServiceImpl method createKfsVendorMaintenaceDocument.
private MaintenanceDocument createKfsVendorMaintenaceDocument(PaymentWorksVendor pmwVendor, Map<String, List<PaymentWorksIsoFipsCountryItem>> paymentWorksIsoToFipsCountryMap, Map<String, SupplierDiversity> paymentWorksToKfsDiversityMap, PaymentWorksNewVendorRequestsBatchReportData reportData) {
MaintenanceDocument vendorMaintenceDoc = null;
try {
KfsVendorDataWrapper kfsVendorDataWrapper = getPaymentWorksVendorToKfsVendorDetailConversionService().createKfsVendorDetailFromPmwVendor(pmwVendor, paymentWorksIsoToFipsCountryMap, paymentWorksToKfsDiversityMap);
if (kfsVendorDataWrapper.noProcessingErrorsGenerated()) {
vendorMaintenceDoc = buildVendorMaintenanceDocument(pmwVendor, kfsVendorDataWrapper);
LOG.info("createKfsVendorMaintenaceDocument: vendorMaintenceDoc created for pmwVendorId = " + pmwVendor.getPmwVendorRequestId());
} else {
reportData.getRecordsThatCouldNotBeProcessedSummary().incrementRecordCount();
reportData.addPmwVendorThatCouldNotBeProcessed(new PaymentWorksBatchReportRawDataItem(pmwVendor.toString(), kfsVendorDataWrapper.getErrorMessages()));
LOG.info("createKfsVendorMaintenaceDocument: vendorMaintenceDoc not created due to pmw-to-kfs data conversion error(s): " + kfsVendorDataWrapper.getErrorMessages().toString());
}
} catch (WorkflowException we) {
List<String> edocCreateErrors = getPaymentWorksBatchUtilityService().convertReportDataValidationErrors(GlobalVariables.getMessageMap().getErrorMessages());
captureKfsProcessingErrorsForVendor(pmwVendor, reportData, edocCreateErrors);
LOG.error("createKfsVendorMaintenaceDocument: eDoc creation error(s): " + edocCreateErrors.toString());
LOG.error("createKfsVendorMaintenaceDocument: eDoc creation exception caught: " + we.getMessage());
vendorMaintenceDoc = null;
} finally {
GlobalVariables.getMessageMap().clearErrorMessages();
}
return vendorMaintenceDoc;
}
use of org.kuali.kfs.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CUFinancialSystemDocumentServiceImpl method checkAccountingLinesForChanges.
/**
* new == null, old == null : no change; line deleted previously.
* new == blah, old == blah : no change
* new == blah, old == meh : changed
* new == null, old == blah : deleted
* new == blah, old == null : added
* @throws WorkflowException
*
* @see org.kuali.kfs.sys.document.service.FinancialSystemDocumentService#checkAccountingLinesForChanges(org.kuali.kfs.sys.document.AccountingDocument)
*/
public void checkAccountingLinesForChanges(AccountingDocument accountingDocument) {
DocumentService docService = SpringContext.getBean(DocumentService.class);
AccountingDocument savedDoc = null;
try {
savedDoc = (AccountingDocument) docService.getByDocumentHeaderId(accountingDocument.getDocumentNumber());
} catch (WorkflowException we) {
LOG.error("Unable to retrieve document number " + accountingDocument.getDocumentNumber() + " to evaluate accounting line changes");
}
if (savedDoc == null) {
return;
}
if (!accountingDocument.getSourceAccountingLines().isEmpty()) {
Map<Integer, AccountingLine> newSourceLines = buildAccountingLineMap(accountingDocument.getSourceAccountingLines());
Map<Integer, AccountingLine> savedSourceLines = buildAccountingLineMap(savedDoc.getSourceAccountingLines());
if (newSourceLines.isEmpty())
return;
int maxSourceKey = findMinOrMaxKeyValue(newSourceLines, savedSourceLines, false);
int minSourceKey = findMinOrMaxKeyValue(newSourceLines, savedSourceLines, true);
for (int i = minSourceKey; i < maxSourceKey + 1; i++) {
AccountingLine newLine = newSourceLines.get(i);
AccountingLine oldLine = savedSourceLines.get(i);
if (!compareTo(newLine, oldLine)) {
String diff = buildLineChangedNoteText(newLine, oldLine);
if (StringUtils.isNotBlank(diff)) {
writeNote(accountingDocument, diff);
}
}
}
}
if (!accountingDocument.getTargetAccountingLines().isEmpty()) {
Map<Integer, AccountingLine> newTargetLines = buildAccountingLineMap(accountingDocument.getTargetAccountingLines());
Map<Integer, AccountingLine> savedTargetLines = buildAccountingLineMap(savedDoc.getTargetAccountingLines());
if (newTargetLines.isEmpty())
return;
int maxTargetKey = findMinOrMaxKeyValue(newTargetLines, savedTargetLines, false);
int minTargetKey = findMinOrMaxKeyValue(newTargetLines, savedTargetLines, true);
for (int i = minTargetKey; i < maxTargetKey + 1; i++) {
AccountingLine newLine = newTargetLines.get(i);
AccountingLine oldLine = savedTargetLines.get(i);
if (!compareTo(newLine, oldLine)) {
String diff = buildLineChangedNoteText(newLine, oldLine);
if (StringUtils.isNotBlank(diff)) {
writeNote(accountingDocument, diff);
}
}
}
}
}
use of org.kuali.kfs.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class PaymentApplicationForm method populate.
@Override
public void populate(HttpServletRequest request) {
super.populate(request);
// Set the next non-invoiced line number
PaymentApplicationDocument paymentApplicationDocument = getPaymentApplicationDocument();
if (ObjectUtils.isNotNull(paymentApplicationDocument.getNonInvoicedDistributions())) {
for (NonInvoicedDistribution u : paymentApplicationDocument.getNonInvoicedDistributions()) {
if (null == getNextNonInvoicedLineNumber()) {
setNextNonInvoicedLineNumber(u.getFinancialDocumentLineNumber());
} else if (u.getFinancialDocumentLineNumber() > getNextNonInvoicedLineNumber()) {
setNextNonInvoicedLineNumber(u.getFinancialDocumentLineNumber());
}
}
}
if (null == getNextNonInvoicedLineNumber()) {
setNextNonInvoicedLineNumber(1);
}
// This step doesn't affect anything persisted to the database. It allows proper calculation
// of amounts for the display.
String customerNumber = null;
String docId = getDocument().getDocumentNumber();
if (ObjectUtils.isNotNull(request.getParameter(KFSConstants.PARAMETER_DOC_ID)) && ObjectUtils.isNull(getDocument().getDocumentNumber())) {
// The document hasn't yet been set on the form. Let's look it up manually so that we can get the
// customer number.
docId = request.getParameter(KFSConstants.PARAMETER_DOC_ID).trim();
DocumentService documentService = SpringContext.getBean(DocumentService.class);
Document d;
try {
d = documentService.getByDocumentHeaderId(docId);
} catch (WorkflowException e) {
throw new RuntimeException("WorkflowException thrown when trying to load docId [" + docId + "]", e);
}
PaymentApplicationDocument pDocument = (PaymentApplicationDocument) d;
AccountsReceivableDocumentHeader arHeader = pDocument.getAccountsReceivableDocumentHeader();
if (ObjectUtils.isNotNull(arHeader)) {
customerNumber = arHeader.getCustomerNumber();
}
}
if (ObjectUtils.isNull(getSelectedInvoiceApplication())) {
if (ObjectUtils.isNull(invoices) || invoices.isEmpty()) {
if (ObjectUtils.isNotNull(customerNumber)) {
// get open invoices for the current customer
CustomerInvoiceDocumentService customerInvoiceDocumentService = SpringContext.getBean(CustomerInvoiceDocumentService.class);
Collection<CustomerInvoiceDocument> openInvoicesForCustomer = customerInvoiceDocumentService.getOpenInvoiceDocumentsByCustomerNumber(customerNumber);
setInvoices(new ArrayList<>(openInvoicesForCustomer));
if (invoices != null && !invoices.isEmpty()) {
setSelectedInvoiceDocumentNumber(invoices.get(0).getDocumentNumber());
}
setupInvoiceWrappers(docId);
}
}
}
}
Aggregations