Search in sources :

Example 51 with WorkflowException

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

the class FinancialSystemSearchableAttribute method extractDocumentAttributes.

@Override
public List<DocumentAttribute> extractDocumentAttributes(RuleAttribute ruleAttribute, DocumentRouteHeaderValue document) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("extractDocumentAttributes( " + ruleAttribute + ", " + document + " )");
    }
    List<DocumentAttribute> searchAttrValues = super.extractDocumentAttributes(ruleAttribute, document);
    String docId = document.getDocumentId();
    DocumentService docService = SpringContext.getBean(DocumentService.class);
    Document doc = null;
    try {
        doc = docService.getByDocumentHeaderId(docId);
    } catch (WorkflowException we) {
    // ignore
    }
    if (doc != null) {
        if (doc instanceof AmountTotaling && ((AmountTotaling) doc).getTotalDollarAmount() != null) {
            DocumentAttributeDecimal searchableAttributeValue = new DocumentAttributeDecimal(KFSPropertyConstants.FINANCIAL_DOCUMENT_TOTAL_AMOUNT, ((AmountTotaling) doc).getTotalDollarAmount().bigDecimalValue());
            searchAttrValues.add(searchableAttributeValue);
        }
        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 searchableAttributeValue = new DocumentAttributeString(KFSPropertyConstants.ACCOUNT_NUMBER, detail.getAccountNumber());
                    searchAttrValues.add(searchableAttributeValue);
                }
            }
        }
    }
    return searchAttrValues;
}
Also used : WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) DocumentAttributeDecimal(org.kuali.kfs.kew.api.document.attribute.DocumentAttributeDecimal) DocumentAttributeString(org.kuali.kfs.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.kfs.kew.api.document.attribute.DocumentAttribute) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) DocumentAttributeString(org.kuali.kfs.kew.api.document.attribute.DocumentAttributeString) AmountTotaling(org.kuali.kfs.sys.document.AmountTotaling)

Example 52 with WorkflowException

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

the class CuDisbursementVoucherExtractionHelperServiceImplTest method test.

public void test() {
    CuDisbursementVoucherDocument dv = null;
    try {
        dv = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
    } catch (WorkflowException e) {
        throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
    }
    if (dv != null) {
        dv.getDocumentHeader().setDocumentDescription("Test Document Description");
        dv.getDocumentHeader().setExplanation("Stuff");
        dv.initiateDocument();
        VendorDetail vendor = SpringContext.getBean(VendorService.class).getVendorDetail("13366-0");
        VendorAddress vendoraddress = SpringContext.getBean(VendorService.class).getVendorDefaultAddress(vendor.getVendorHeaderGeneratedIdentifier(), vendor.getVendorDetailAssignedIdentifier(), "RM", "");
        System.out.println(vendoraddress.getVendorCityName() + "\n");
        dv.templateVendor(vendor, vendoraddress);
        dv.setPayeeAssigned(true);
        dv.getDvPayeeDetail().setDisbVchrPaymentReasonCode("S");
        dv.setDisbVchrCheckTotalAmount(new KualiDecimal(86.00));
        dv.setDisbVchrPaymentMethodCode("P");
        dv.setDisbVchrCheckStubText("check text");
        dv.setCampusCode("IT");
        SourceAccountingLine accountingLine = new SourceAccountingLine();
        accountingLine.setChartOfAccountsCode("IT");
        accountingLine.setAccountNumber("G081040");
        accountingLine.setFinancialObjectCode("8462");
        accountingLine.setAmount((new KualiDecimal(86.00)));
        accountingLine.setPostingYear(dv.getPostingYear());
        accountingLine.setDocumentNumber(dv.getDocumentNumber());
        dv.addSourceAccountingLine(accountingLine);
        try {
            documentService.saveDocument(dv);
        } catch (WorkflowException e) {
            throw new RuntimeException("Error saving new disbursement voucher document: " + e.getMessage(), e);
        }
    }
    Date transactionTimestamp = new Date(SpringContext.getBean(DateTimeService.class).getCurrentDate().getTime());
    Date processRunDate = new java.sql.Date(transactionTimestamp.getTime());
    PaymentGroup pg = cuDisbursementVoucherExtractionHelperService.createPaymentGroup(dv, processRunDate);
    assertTrue(pg.getPaymentDetails().get(0).getCustPaymentDocNbr().equalsIgnoreCase(dv.getDocumentNumber()));
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) DocumentService(org.kuali.kfs.krad.service.DocumentService) Date(java.sql.Date) VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorService(org.kuali.kfs.vnd.document.service.VendorService) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) DateTimeService(org.kuali.kfs.core.api.datetime.DateTimeService)

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