Search in sources :

Example 36 with WorkflowException

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() + ")");
    }
}
Also used : ElectronicInvoiceLoadSummary(org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceLoadSummary) ElectronicInvoiceRejectDocument(org.kuali.kfs.module.purap.document.ElectronicInvoiceRejectDocument) CuElectronicInvoiceRejectDocument(edu.cornell.kfs.module.purap.document.CuElectronicInvoiceRejectDocument) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) ArrayList(java.util.ArrayList) ElectronicInvoiceRejectReason(org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceRejectReason)

Example 37 with WorkflowException

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());
    }
}
Also used : WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) DocumentType(org.kuali.kfs.kew.doctype.bo.DocumentType) DocumentAttributeIndexingQueue(org.kuali.kfs.kew.api.document.attribute.DocumentAttributeIndexingQueue) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) Timestamp(java.sql.Timestamp)

Example 38 with WorkflowException

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;
}
Also used : HashMap(java.util.HashMap) Builder(org.kuali.kfs.kim.api.role.RoleMembership.Builder) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) ArrayList(java.util.ArrayList) RoleMembership(org.kuali.kfs.kim.api.role.RoleMembership) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument) HashMap(java.util.HashMap) Map(java.util.Map)

Example 39 with WorkflowException

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);
}
Also used : CuPurchasingAccountsPayableModuleService(edu.cornell.kfs.integration.purap.CuPurchasingAccountsPayableModuleService) PaymentDetailExtendedAttribute(edu.cornell.kfs.pdp.businessobject.PaymentDetailExtendedAttribute) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) PaymentSource(org.kuali.kfs.sys.document.PaymentSource) Transactional(org.springframework.transaction.annotation.Transactional)

Example 40 with WorkflowException

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;
}
Also used : MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) KfsAchDataWrapper(edu.cornell.kfs.pmw.batch.businessobject.KfsAchDataWrapper) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)52 ArrayList (java.util.ArrayList)12 DocumentService (org.kuali.kfs.krad.service.DocumentService)11 Document (org.kuali.kfs.krad.document.Document)9 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)7 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)7 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)6 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)6 Date (java.sql.Date)5 HashMap (java.util.HashMap)5 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)5 ValidationException (org.kuali.kfs.krad.exception.ValidationException)5 RemoteException (java.rmi.RemoteException)4 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)4 Person (org.kuali.kfs.kim.api.identity.Person)4 AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)4 CuElectronicInvoiceRejectDocument (edu.cornell.kfs.module.purap.document.CuElectronicInvoiceRejectDocument)3 AccountGlobal (org.kuali.kfs.coa.businessobject.AccountGlobal)3 Note (org.kuali.kfs.krad.bo.Note)3 ContractsGrantsInvoiceDocument (org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument)3