Search in sources :

Example 6 with WorkflowException

use of org.kuali.rice.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);
                }
            }
        }
    }
}
Also used : AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) DocumentService(org.kuali.kfs.krad.service.DocumentService) CUFinancialSystemDocumentService(edu.cornell.kfs.sys.document.service.CUFinancialSystemDocumentService)

Example 7 with WorkflowException

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

the class PaymentSourceExtractionServiceImpl method getListByDocumentStatusCodeCampus.

/**
 * This method retrieves a list of disbursement voucher documents that are in the status provided for the campus code given.
 *
 * @param statusCode The status of the disbursement vouchers to be retrieved.
 * @param campusCode The campus code that the disbursement vouchers will be associated with.
 * @param immediatesOnly only retrieve Disbursement Vouchers marked for immediate payment
 * @return A collection of disbursement voucher objects that meet the search criteria given.
 */
protected Collection<DisbursementVoucherDocument> getListByDocumentStatusCodeCampus(String statusCode, String campusCode, boolean immediatesOnly) {
    LOG.info("getListByDocumentStatusCodeCampus(statusCode=" + statusCode + ", campusCode=" + campusCode + ", immediatesOnly=" + immediatesOnly + ") started");
    Collection<DisbursementVoucherDocument> list = new ArrayList<DisbursementVoucherDocument>();
    try {
        Collection<DisbursementVoucherDocument> docs = SpringContext.getBean(FinancialSystemDocumentService.class).findByDocumentHeaderStatusCode(DisbursementVoucherDocument.class, statusCode);
        for (DisbursementVoucherDocument element : docs) {
            String dvdCampusCode = element.getCampusCode();
            if (dvdCampusCode.equals(campusCode) && KFSConstants.PaymentSourceConstants.PAYMENT_METHOD_CHECK.equals(element.getDisbVchrPaymentMethodCode())) {
                if ((immediatesOnly && element.isImmediatePaymentIndicator()) || !immediatesOnly) {
                    list.add(element);
                }
            }
        }
    } catch (WorkflowException we) {
        LOG.error("Could not load Disbursement Voucher Documents with status code = " + statusCode + ": " + we);
        throw new RuntimeException(we);
    }
    return list;
}
Also used : WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) ArrayList(java.util.ArrayList) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) FinancialSystemDocumentService(org.kuali.kfs.sys.document.service.FinancialSystemDocumentService)

Example 8 with WorkflowException

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

the class FinancialSystemSearchableAttribute method extractDocumentAttributes.

@Override
public List<DocumentAttribute> extractDocumentAttributes(ExtensionDefinition extensionDefinition, DocumentWithContent documentWithContent) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("extractDocumentAttributes( " + extensionDefinition + ", " + documentWithContent + " )");
    }
    List<DocumentAttribute> searchAttrValues = super.extractDocumentAttributes(extensionDefinition, documentWithContent);
    String docId = documentWithContent.getDocument().getDocumentId();
    DocumentService docService = SpringContext.getBean(DocumentService.class);
    Document doc = null;
    try {
        doc = docService.getByDocumentHeaderIdSessionless(docId);
    } catch (WorkflowException we) {
    }
    if (doc != null) {
        if (doc instanceof AmountTotaling && ((AmountTotaling) doc).getTotalDollarAmount() != null) {
            DocumentAttributeDecimal.Builder searchableAttributeValue = DocumentAttributeDecimal.Builder.create(KFSPropertyConstants.FINANCIAL_DOCUMENT_TOTAL_AMOUNT);
            searchableAttributeValue.setValue(((AmountTotaling) doc).getTotalDollarAmount().bigDecimalValue());
            searchAttrValues.add(searchableAttributeValue.build());
        }
        if (doc instanceof AccountingDocument) {
            AccountingDocument accountingDoc = (AccountingDocument) doc;
            searchAttrValues.addAll(harvestAccountingDocumentSearchableAttributes(accountingDoc));
        }
        boolean indexedLedgerDoc = false;
        if (doc instanceof LaborLedgerPostingDocumentForSearching) {
            LaborLedgerPostingDocumentForSearching LLPostingDoc = (LaborLedgerPostingDocumentForSearching) doc;
            searchAttrValues.addAll(harvestLLPDocumentSearchableAttributes(LLPostingDoc));
            indexedLedgerDoc = true;
        }
        if (doc instanceof GeneralLedgerPostingDocument && !indexedLedgerDoc) {
            GeneralLedgerPostingDocument GLPostingDoc = (GeneralLedgerPostingDocument) doc;
            searchAttrValues.addAll(harvestGLPDocumentSearchableAttributes(GLPostingDoc));
        }
        DocumentHeader docHeader = doc.getDocumentHeader();
        if (ObjectUtils.isNotNull(docHeader) && ObjectUtils.isNotNull(docHeader.getWorkflowDocument()) && CUKFSConstants.GACC_DOCUMENT_TYPE.equalsIgnoreCase(docHeader.getWorkflowDocument().getDocumentTypeName())) {
            for (AccountGlobalDetail detail : ((AccountGlobal) ((AccountGlobalMaintainableImpl) ((FinancialSystemMaintenanceDocument) doc).getNewMaintainableObject()).getBusinessObject()).getAccountGlobalDetails()) {
                if (!StringUtils.isBlank(detail.getAccountNumber())) {
                    DocumentAttributeString.Builder searchableAttributeValue = DocumentAttributeString.Builder.create(KFSPropertyConstants.ACCOUNT_NUMBER);
                    searchableAttributeValue.setValue(detail.getAccountNumber());
                    searchAttrValues.add(searchableAttributeValue.build());
                }
            }
        }
    }
    return searchAttrValues;
}
Also used : WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) DocumentAttributeDecimal(org.kuali.rice.kew.api.document.attribute.DocumentAttributeDecimal) DocumentAttributeString(org.kuali.rice.kew.api.document.attribute.DocumentAttributeString) Document(org.kuali.kfs.krad.document.Document) GeneralLedgerPostingDocument(org.kuali.kfs.sys.document.GeneralLedgerPostingDocument) FinancialSystemMaintenanceDocument(org.kuali.kfs.sys.document.FinancialSystemMaintenanceDocument) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) DocumentHeader(org.kuali.kfs.krad.bo.DocumentHeader) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) DocumentService(org.kuali.kfs.krad.service.DocumentService) LaborLedgerPostingDocumentForSearching(org.kuali.kfs.integration.ld.LaborLedgerPostingDocumentForSearching) FinancialSystemMaintenanceDocument(org.kuali.kfs.sys.document.FinancialSystemMaintenanceDocument) GeneralLedgerPostingDocument(org.kuali.kfs.sys.document.GeneralLedgerPostingDocument) AccountGlobal(org.kuali.kfs.coa.businessobject.AccountGlobal) DocumentAttribute(org.kuali.rice.kew.api.document.attribute.DocumentAttribute) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) DocumentAttributeString(org.kuali.rice.kew.api.document.attribute.DocumentAttributeString) AmountTotaling(org.kuali.kfs.sys.document.AmountTotaling)

Example 9 with WorkflowException

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

the class CheckReconciliationMaintainableImpl method doRouteStatusChange.

/**
 * @see org.kuali.kfs.kns.maintenance.KualiMaintainableImpl#doRouteStatusChange(org.kuali.kfs.kns.bo.DocumentHeader)
 */
public void doRouteStatusChange(DocumentHeader documentHeader) {
    WorkflowDocument workflowDocument = documentHeader.getWorkflowDocument();
    if (workflowDocument.isProcessed() && !KFSConstants.MAINTENANCE_NEW_ACTION.equalsIgnoreCase(getMaintenanceAction())) {
        DocumentService documentService = SpringContext.getBean(DocumentService.class);
        MaintenanceDocument document;
        try {
            document = (MaintenanceDocument) documentService.getByDocumentHeaderId(documentHeader.getDocumentNumber());
            CheckReconciliation oldCr = (CheckReconciliation) document.getOldMaintainableObject().getBusinessObject();
            CheckReconciliation newCr = (CheckReconciliation) document.getNewMaintainableObject().getBusinessObject();
            if (ObjectUtils.isNotNull(oldCr) && !oldCr.getStatus().equalsIgnoreCase(newCr.getStatus())) {
                Date currentDate = SpringContext.getBean(DateTimeService.class).getCurrentSqlDate();
                newCr.setStatusChangeDate(currentDate);
                // KFSUPGRADE-377
                if (CRConstants.CANCELLED.equalsIgnoreCase(newCr.getStatus())) {
                    newCr.setCancelDocHdrId(documentHeader.getDocumentNumber());
                }
            }
        } catch (WorkflowException e) {
            throw new RuntimeCacheException(e);
        }
    }
}
Also used : RuntimeCacheException(org.apache.ojb.broker.cache.RuntimeCacheException) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) CheckReconciliation(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation) DateTimeService(org.kuali.rice.core.api.datetime.DateTimeService) DocumentService(org.kuali.kfs.krad.service.DocumentService) Date(java.sql.Date)

Example 10 with WorkflowException

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

the class CuPurapServiceImpl method saveRoutingDataForRelatedDocuments.

// ==== CU Customization (KFSPTS-1656): Save IWantDocument routing data. ====
@Override
public void saveRoutingDataForRelatedDocuments(Integer accountsPayablePurchasingDocumentLinkIdentifier) {
    super.saveRoutingDataForRelatedDocuments(accountsPayablePurchasingDocumentLinkIdentifier);
    try {
        // Save IWNT routing data.
        @SuppressWarnings("unchecked") List<IWantView> iWantViews = getRelatedViews(IWantView.class, accountsPayablePurchasingDocumentLinkIdentifier);
        for (Iterator<IWantView> iterator = iWantViews.iterator(); iterator.hasNext(); ) {
            IWantView view = (IWantView) iterator.next();
            Document doc = documentService.getByDocumentHeaderId(view.getDocumentNumber());
            doc.getDocumentHeader().getWorkflowDocument().saveDocumentData();
        }
    } catch (WorkflowException e) {
        throw new InfrastructureException("unable to save routing data for related docs", e);
    }
}
Also used : WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) IWantView(edu.cornell.kfs.module.purap.businessobject.IWantView) VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) Document(org.kuali.kfs.krad.document.Document) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument) InfrastructureException(org.kuali.kfs.krad.exception.InfrastructureException)

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