use of org.kuali.kfs.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuElectronicInvoiceHelperServiceImpl method rejectElectronicInvoiceFile.
@Override
protected void rejectElectronicInvoiceFile(ElectronicInvoiceLoad eInvoiceLoad, String fileDunsNumber, File invoiceFile, String extraDescription, String rejectReasonTypeCode) {
clearErrorMessagesToPreventSaveAndRouteErrors();
if (LOG.isInfoEnabled()) {
LOG.info("Rejecting the entire invoice file - " + invoiceFile.getName());
}
ElectronicInvoiceLoadSummary eInvoiceLoadSummary = getOrCreateLoadSummary(eInvoiceLoad, fileDunsNumber);
eInvoiceLoadSummary.addFailedInvoiceOrder();
eInvoiceLoad.insertInvoiceLoadSummary(eInvoiceLoadSummary);
ElectronicInvoiceRejectDocument eInvoiceRejectDocument = null;
try {
eInvoiceRejectDocument = (ElectronicInvoiceRejectDocument) documentService.getNewDocument("EIRT");
eInvoiceRejectDocument.setInvoiceProcessTimestamp(dateTimeService.getCurrentTimestamp());
eInvoiceRejectDocument.setVendorDunsNumber(fileDunsNumber);
eInvoiceRejectDocument.setDocumentCreationInProgress(true);
if (invoiceFile != null) {
eInvoiceRejectDocument.setInvoiceFileName(invoiceFile.getName());
}
List<ElectronicInvoiceRejectReason> list = new ArrayList<ElectronicInvoiceRejectReason>(1);
String message = "Complete failure document has been created for the Invoice with Filename '" + invoiceFile.getName() + "' due to the following error:\n";
emailTextErrorList.append(message);
ElectronicInvoiceRejectReason rejectReason = matchingService.createRejectReason(rejectReasonTypeCode, extraDescription, invoiceFile.getName());
list.add(rejectReason);
emailTextErrorList.append(" - " + rejectReason.getInvoiceRejectReasonDescription());
emailTextErrorList.append("\n\n");
eInvoiceRejectDocument.setInvoiceRejectReasons(list);
eInvoiceRejectDocument.getDocumentHeader().setDocumentDescription("Complete failure");
// KFSCNTRB-1369: Need to Save document
documentService.saveDocument(eInvoiceRejectDocument);
String noteText = "Invoice file";
// if (invoiceFile.length() > 0) {
// empty file will casuse attachment creation exception. Hence, job will be stopped
attachInvoiceXMLWithRejectDoc(eInvoiceRejectDocument, invoiceFile, noteText);
// }
eInvoiceLoad.addInvoiceReject(eInvoiceRejectDocument);
} catch (WorkflowException e) {
throw new RuntimeException(e);
}
if (LOG.isInfoEnabled()) {
LOG.info("Complete failure document has been created (DocNo:" + eInvoiceRejectDocument.getDocumentNumber() + ")");
}
}
use of org.kuali.kfs.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()));
getPurapService().saveDocumentNoValidation(doc);
DocumentType documentType = documentTypeService.getDocumentTypeByName(doc.getFinancialDocumentTypeCode());
DocumentAttributeIndexingQueue queue = KewApiServiceLocator.getDocumentAttributeIndexingQueue();
queue.indexDocument(doc.getDocumentNumber());
} catch (WorkflowException e) {
throw new IllegalArgumentException("Unable to retrieve payment request: " + paymentRequestDocument.getDocumentNumber());
}
}
use of org.kuali.kfs.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuRelatedDocumentDerivedRoleTypeServiceImpl method getRoleMembersFromDerivedRole.
@Override
public List<RoleMembership> getRoleMembersFromDerivedRole(String namespaceCode, String roleName, Map<String, String> qualification) {
List<RoleMembership> members = new ArrayList<RoleMembership>();
if (qualification != null && !qualification.isEmpty()) {
if (SOURCE_DOCUMENT_ROUTER_ROLE_NAME.equals(roleName)) {
try {
PurchasingAccountsPayableDocument document = (PurchasingAccountsPayableDocument) getDocumentService().getByDocumentHeaderId(qualification.get(KFSPropertyConstants.DOCUMENT_NUMBER));
if (document != null) {
PurchasingAccountsPayableDocument sourceDocument = document.getPurApSourceDocumentIfPossible();
if (sourceDocument != null && StringUtils.isNotBlank(sourceDocument.getDocumentHeader().getWorkflowDocument().getRoutedByPrincipalId())) {
Map<String, String> roleQualifier = new HashMap<String, String>(1);
roleQualifier.put(KimConstants.AttributeConstants.DOCUMENT_NUMBER, sourceDocument.getDocumentNumber());
Builder roleMember = RoleMembership.Builder.create(null, null, sourceDocument.getDocumentHeader().getWorkflowDocument().getRoutedByPrincipalId(), KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, roleQualifier);
members.add(roleMember.build());
}
}
} catch (WorkflowException e) {
throw new RuntimeException("Unable to load document in getPrincipalIdsFromApplicationRole", e);
}
} else if (SENSITIVE_RELATED_DOCUMENT_INITATOR_OR_REVIEWER_ROLE_NAME.equals(roleName)) {
// KFSUPGRADE-346
if (!qualification.containsKey(PurapKimAttributes.ACCOUNTS_PAYABLE_PURCHASING_DOCUMENT_LINK_IDENTIFIER)) {
Map<String, String> tempQualification = new HashMap<String, String>(1);
tempQualification.put(KFSPropertyConstants.DOCUMENT_NUMBER, qualification.get("documentNumber"));
for (String principalId : getRoleService().getRoleMemberPrincipalIds(KFSConstants.CoreModuleNamespaces.WORKFLOW, RouteLogDerivedRoleTypeServiceImpl.INITIATOR_OR_REVIEWER_ROLE_NAME, tempQualification)) {
Builder roleMember = RoleMembership.Builder.create(null, null, principalId, KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, tempQualification);
members.add(roleMember.build());
}
} else {
for (String documentId : getPurapService().getRelatedDocumentIds(new Integer(qualification.get(PurapKimAttributes.ACCOUNTS_PAYABLE_PURCHASING_DOCUMENT_LINK_IDENTIFIER)))) {
Map<String, String> tempQualification = new HashMap<String, String>(1);
tempQualification.put(KFSPropertyConstants.DOCUMENT_NUMBER, documentId);
for (String principalId : getRoleService().getRoleMemberPrincipalIds(KFSConstants.CoreModuleNamespaces.WORKFLOW, RouteLogDerivedRoleTypeServiceImpl.INITIATOR_OR_REVIEWER_ROLE_NAME, tempQualification)) {
Builder roleMember = RoleMembership.Builder.create(null, null, principalId, KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, tempQualification);
members.add(roleMember.build());
}
}
}
}
}
return members;
}
use of org.kuali.kfs.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuProcessIndividualPdpCancelPaidServiceImpl method processPdpCancel.
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void processPdpCancel(Date processDate, PaymentDetail paymentDetail) {
String documentTypeCode = paymentDetail.getFinancialDocumentTypeCode();
String documentNumber = paymentDetail.getCustPaymentDocNbr();
boolean primaryCancel = paymentDetail.getPrimaryCancelledPayment();
boolean disbursedPayment = PdpConstants.PaymentStatusCodes.CANCEL_PAYMENT.equals(paymentDetail.getPaymentGroup().getPaymentStatusCode());
// KFSPTS-2719
boolean crCancel = false;
PaymentDetailExtendedAttribute paymentDetailExtendedAttribute = (PaymentDetailExtendedAttribute) paymentDetail.getExtension();
if (ObjectUtils.isNotNull(paymentDetailExtendedAttribute)) {
crCancel = paymentDetailExtendedAttribute.getCrCancelledPayment();
}
if (purchasingAccountsPayableModuleService.isPurchasingBatchDocument(documentTypeCode)) {
((CuPurchasingAccountsPayableModuleService) purchasingAccountsPayableModuleService).handlePurchasingBatchCancels(documentNumber, documentTypeCode, primaryCancel, disbursedPayment, crCancel);
} else {
PaymentSourceToExtractService<PaymentSource> extractService = getPaymentSourceToExtractService(paymentDetail);
if (extractService != null) {
try {
PaymentSource dv = (PaymentSource) documentService.getByDocumentHeaderId(documentNumber);
if (dv != null) {
if (disbursedPayment || primaryCancel || crCancel) {
if (!crCancel) {
extractService.cancelPayment(dv, processDate);
}
} else {
extractService.resetFromExtraction(dv);
}
}
} catch (WorkflowException we) {
throw new RuntimeException("Could not retrieve document #" + documentNumber, we);
}
} else {
LOG.warn("processPdpCancel() Unknown document type (" + documentTypeCode + ") for document ID: " + documentNumber);
return;
}
}
paymentGroupService.processCancelledGroup(paymentDetail.getPaymentGroup(), processDate);
}
use of org.kuali.kfs.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class PaymentWorksVendorAchDataProcessingIntoKfsServiceImpl method createKfsPayeeAchMaintenaceDocument.
private MaintenanceDocument createKfsPayeeAchMaintenaceDocument(PaymentWorksVendor pmwVendor, PaymentWorksNewVendorPayeeAchBatchReportData reportData) {
MaintenanceDocument paatMaintenceDoc = null;
try {
KfsAchDataWrapper kfsAchDataWrapper = getPaymentWorksVendorToKfsPayeeAchAccountConversionService().createKfsPayeeAchFromPmwVendor(pmwVendor);
if (kfsAchDataWrapper.noProcessingErrorsGenerated()) {
paatMaintenceDoc = buildPayeeAchMaintenanceDocument(kfsAchDataWrapper);
LOG.info("createKfsPayeeAchMaintenaceDocument: paatMaintenceDoc created for pmwVendorId = " + pmwVendor.getPmwVendorRequestId() + " KFS vendor id = " + pmwVendor.getKfsVendorHeaderGeneratedIdentifier() + "-" + pmwVendor.getKfsVendorDetailAssignedIdentifier());
} else {
reportData.getRecordsThatCouldNotBeProcessedSummary().incrementRecordCount();
reportData.addPmwVendorAchThatCouldNotBeProcessed(getPaymentWorksNewVendorPayeeAchReportService().createBatchReportVendorItem(pmwVendor, kfsAchDataWrapper.getErrorMessages()));
LOG.info("createKfsPayeeAchMaintenaceDocument: paatMaintenceDoc not created due to pmw-to-kfs data conversion error(s): " + kfsAchDataWrapper.getErrorMessages().toString());
}
} catch (WorkflowException we) {
List<String> edocCreateErrors = getPaymentWorksBatchUtilityService().convertReportDataValidationErrors(GlobalVariables.getMessageMap().getErrorMessages());
captureKfsPayeeAchProcessingErrorsForVendor(pmwVendor, reportData, edocCreateErrors);
LOG.error("createKfsPayeeAchMaintenaceDocument: eDoc creation error(s): " + edocCreateErrors.toString());
LOG.error("createKfsPayeeAchMaintenaceDocument: eDoc creation exception caught: " + we.getMessage());
paatMaintenceDoc = null;
} finally {
GlobalVariables.getMessageMap().clearErrorMessages();
}
return paatMaintenceDoc;
}
Aggregations