Search in sources :

Example 21 with WorkflowException

use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.

the class SubmitTripWebServiceImpl method buildDistributionIncomeExpenseDocument.

/**
 * @param diDescription
 * @param diExplanation
 * @param tripNumber
 * @param initiatorNetId
 * @return
 * @throws Exception
 */
private String buildDistributionIncomeExpenseDocument(String diDescription, String diExplanation, String tripNumber, String initiatorNetId) throws Exception {
    try {
        if (!isValidDocumentInitiator(initiatorNetId, DISTRIBUTION_INCOME_EXPENSE)) {
            throw new RuntimeException("Initiator identified does not have permission to create a DI.");
        }
    } catch (Exception ex) {
        throw new RuntimeException("Initiator identified does not have permission to create a DI.", 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
    CuDistributionOfIncomeAndExpenseDocument diDoc = null;
    try {
        diDoc = (CuDistributionOfIncomeAndExpenseDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DistributionOfIncomeAndExpenseDocument.class);
    } catch (WorkflowException e) {
        throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
    }
    if (diDoc != null) {
        diDoc.getDocumentHeader().setDocumentDescription(diDescription);
        diDoc.getDocumentHeader().setExplanation(diExplanation);
        diDoc.getDocumentHeader().setOrganizationDocumentNumber(tripNumber);
        diDoc.setTripAssociationStatusCode(CULegacyTravelServiceImpl.TRIP_ASSOCIATIONS.IS_TRIP_DOC);
        diDoc.setTripId(tripNumber);
        // Persist document
        SpringContext.getBean(DocumentService.class).saveDocument(diDoc);
        return diDoc.getDocumentNumber();
    } else {
        return "";
    }
}
Also used : UserSession(org.kuali.kfs.krad.UserSession) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) MessageMap(org.kuali.kfs.krad.util.MessageMap) DocumentService(org.kuali.kfs.krad.service.DocumentService) CuDistributionOfIncomeAndExpenseDocument(edu.cornell.kfs.fp.document.CuDistributionOfIncomeAndExpenseDocument)

Example 22 with WorkflowException

use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherDocumentServiceImpl method findPdpStatuses.

@Override
public List<RecurringDisbursementVoucherPDPStatus> findPdpStatuses(RecurringDisbursementVoucherDocument recurringDV) {
    List<RecurringDisbursementVoucherPDPStatus> pdpStatuses = new ArrayList<RecurringDisbursementVoucherPDPStatus>();
    for (RecurringDisbursementVoucherDetail detail : recurringDV.getRecurringDisbursementVoucherDetails()) {
        if (StringUtils.isNotEmpty(detail.getDvDocumentNumber())) {
            DisbursementVoucherDocument disbursementVoucherDocument;
            try {
                disbursementVoucherDocument = (DisbursementVoucherDocument) getDocumentService().getByDocumentHeaderId(detail.getDvDocumentNumber());
            } catch (WorkflowException e) {
                LOG.error("findPdpStatuses: There was a problem getting DV from the recurring DV detail: " + e);
                throw new RuntimeException(e);
            }
            pdpStatuses.add(buildRecurringDisbursementVoucherPDPStatus(disbursementVoucherDocument));
        }
    }
    Collections.sort(pdpStatuses);
    return pdpStatuses;
}
Also used : RecurringDisbursementVoucherPDPStatus(edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherPDPStatus) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) ArrayList(java.util.ArrayList) RecurringDisbursementVoucherDetail(edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)

Example 23 with WorkflowException

use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherDocumentServiceImpl method saveDisbursementVouchers.

private void saveDisbursementVouchers(List<DisbursementVoucherDocument> dvs, RecurringDisbursementVoucherDocument recurringDV) {
    for (DisbursementVoucherDocument dv : dvs) {
        try {
            dv.getDocumentHeader().setDocumentDescription(recurringDV.getDocumentHeader().getDocumentDescription());
            dv.getDocumentHeader().setExplanation(buildDVExplanation(recurringDV));
            getDocumentService().saveDocument(dv);
            getBusinessObjectService().save(recurringDV.getRecurringDisbursementVoucherDetails());
            updateGLPEDatesAndAddRecurringDocumentLinks(dv, recurringDV.getDocumentNumber());
        } catch (WorkflowException e) {
            ;
            LOG.error("saveDisbursementVouchers: There was an error trying to save our route the created Disbursement Voucher documents: ", e);
            throw new RuntimeException(e);
        }
    }
}
Also used : WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)

Example 24 with WorkflowException

use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherDocumentServiceImpl method noteChangeOnRecurringDV.

private void noteChangeOnRecurringDV(RecurringDisbursementVoucherDocument recurringDV, String noteText, Set<String> setOfStrings) {
    if (!setOfStrings.isEmpty()) {
        Note note = buildNoteBase();
        note.setNoteText(noteText + StringUtils.join(setOfStrings, ", "));
        ;
        recurringDV.addNote(note);
        try {
            getDocumentService().saveDocument(recurringDV);
        } catch (WorkflowException e) {
            throw new RuntimeException("noteChangeOnRecurringDV() Unable to save note.", e);
        }
    }
}
Also used : Note(org.kuali.kfs.krad.bo.Note) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException)

Example 25 with WorkflowException

use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherDocumentServiceImpl method cancelDisbursementVouchersFinalizedNotExtracted.

@Override
public Set<String> cancelDisbursementVouchersFinalizedNotExtracted(RecurringDisbursementVoucherDocument recurringDisbursementVoucherDocument, String cancelMessage) {
    Set<String> canceledDVs = new HashSet<String>();
    for (RecurringDisbursementVoucherDetail detail : recurringDisbursementVoucherDocument.getRecurringDisbursementVoucherDetails()) {
        String dvDocumentNumber = detail.getDvDocumentNumber();
        if (!isDVCancelable(dvDocumentNumber)) {
            CuDisbursementVoucherDocument dv;
            try {
                dv = (CuDisbursementVoucherDocument) getDocumentService().getByDocumentHeaderId(detail.getDvDocumentNumber());
                if (isDvCancelableFromApprovedNotExtracted(dv)) {
                    Date cancelDate = new Date(Calendar.getInstance().getTimeInMillis());
                    dv.setCancelDate(cancelDate);
                    CuDisbursementVoucherDocument cancledDV = (CuDisbursementVoucherDocument) getDocumentService().saveDocument(dv);
                    getCuDisbursementVoucherExtractionHelperService().getPaymentSourceHelperService().handleEntryCancellation(cancledDV, getCuDisbursementVoucherExtractionHelperService());
                    canceledDVs.add(cancledDV.getDocumentNumber());
                }
            } catch (WorkflowException e) {
                throw new RuntimeException(e);
            }
        }
    }
    noteChangeOnRecurringDV(recurringDisbursementVoucherDocument, "The following disbursement vouchers were canceled after it was approved but before payments were created: ", canceledDVs);
    return canceledDVs;
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) RecurringDisbursementVoucherDetail(edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail) Date(java.sql.Date) HashSet(java.util.HashSet)

Aggregations

WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)44 DocumentService (org.kuali.kfs.krad.service.DocumentService)14 ArrayList (java.util.ArrayList)8 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)7 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)7 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)7 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)6 UserSession (org.kuali.kfs.krad.UserSession)6 FinancialSystemDocumentService (org.kuali.kfs.sys.document.service.FinancialSystemDocumentService)6 Date (java.sql.Date)5 RemoteException (java.rmi.RemoteException)4 ValidationException (org.kuali.kfs.krad.exception.ValidationException)4 WorkflowDocumentService (org.kuali.kfs.krad.workflow.service.WorkflowDocumentService)4 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)4 CuElectronicInvoiceRejectDocument (edu.cornell.kfs.module.purap.document.CuElectronicInvoiceRejectDocument)3 HashMap (java.util.HashMap)3 AccountGlobal (org.kuali.kfs.coa.businessobject.AccountGlobal)3 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)3 Note (org.kuali.kfs.krad.bo.Note)3 Document (org.kuali.kfs.krad.document.Document)3