Search in sources :

Example 6 with Document

use of org.kuali.kfs.krad.document.Document in project cu-kfs by CU-CommunityApps.

the class CuAdvanceDepositAction method insertBONote.

/**
 * Overridden to treat "Confidential" add-attachment authorization failures as validation errors, rather than throwing an authorization exception.
 *
 * @see org.kuali.kfs.kns.web.struts.action.KualiDocumentActionBase#insertBONote(
 * org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm,
 * javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@SuppressWarnings("deprecation")
@Override
public ActionForward insertBONote(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    AdvanceDepositForm adForm = (AdvanceDepositForm) form;
    Note newNote = adForm.getNewNote();
    Document document = adForm.getDocument();
    if (!ConfidentialAttachmentUtil.attachmentIsNonConfidentialOrCanAddConfAttachment(newNote, document, adForm.getAttachmentFile(), getDocumentHelperService().getDocumentAuthorizer(document))) {
        return mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
    return super.insertBONote(mapping, form, request, response);
}
Also used : Note(org.kuali.kfs.krad.bo.Note) AdvanceDepositForm(org.kuali.kfs.fp.document.web.struts.AdvanceDepositForm) Document(org.kuali.kfs.krad.document.Document)

Example 7 with Document

use of org.kuali.kfs.krad.document.Document 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)

Example 8 with Document

use of org.kuali.kfs.krad.document.Document in project cu-kfs by CU-CommunityApps.

the class SubmitTripWebServiceImpl method canViewKfsDocument.

/**
 * @param viewerNetId
 * @param docID
 * @return
 * @throws Exception
 */
public boolean canViewKfsDocument(String viewerNetId, String docID) throws Exception {
    Person viewer = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(viewerNetId);
    Document document = SpringContext.getBean(DocumentService.class).getByDocumentHeaderIdSessionless(docID);
    DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(document);
    return documentAuthorizer.canOpen(document, viewer);
}
Also used : PersonService(org.kuali.rice.kim.api.identity.PersonService) DocumentAuthorizer(org.kuali.kfs.krad.document.DocumentAuthorizer) Document(org.kuali.kfs.krad.document.Document) DistributionOfIncomeAndExpenseDocument(org.kuali.kfs.fp.document.DistributionOfIncomeAndExpenseDocument) CuDistributionOfIncomeAndExpenseDocument(edu.cornell.kfs.fp.document.CuDistributionOfIncomeAndExpenseDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) Person(org.kuali.rice.kim.api.identity.Person) DocumentService(org.kuali.kfs.krad.service.DocumentService) DocumentHelperService(org.kuali.kfs.kns.service.DocumentHelperService)

Example 9 with Document

use of org.kuali.kfs.krad.document.Document in project cu-kfs by CU-CommunityApps.

the class CuPendingTransactionServiceImpl method reverseSourceDocumentsEntries.

/**
 * Reverses the entries of the source documents
 *
 * @param paymentDetail
 * @param sequenceHelper
 */
protected void reverseSourceDocumentsEntries(PaymentDetail paymentDetail, GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
    // Need to reverse the payment document's GL entries if the check is stopped or cancelled
    if (PurapConstants.PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT.equalsIgnoreCase(paymentDetail.getFinancialDocumentTypeCode()) || CUPdpConstants.PdpDocumentTypes.DISBURSEMENT_VOUCHER.equalsIgnoreCase(paymentDetail.getFinancialDocumentTypeCode()) || CUPdpConstants.PdpDocumentTypes.CREDIT_MEMO.equalsIgnoreCase(paymentDetail.getFinancialDocumentTypeCode())) {
        try {
            String sourceDocumentNumber = paymentDetail.getCustPaymentDocNbr();
            try {
                Long.valueOf(sourceDocumentNumber);
            } catch (NumberFormatException nfe) {
                sourceDocumentNumber = null;
            }
            if (sourceDocumentNumber != null && StringUtils.isNotBlank(sourceDocumentNumber)) {
                Document doc = (AccountingDocumentBase) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(paymentDetail.getCustPaymentDocNbr());
                if (ObjectUtils.isNotNull(doc)) {
                    if (doc instanceof DisbursementVoucherDocument) {
                        // KFSUPGRADE-775
                        DisbursementVoucherDocument dv = (DisbursementVoucherDocument) doc;
                        generateDisbursementVoucherReversalEntries(dv, sequenceHelper);
                    // end KFSUPGRADE-775
                    } else if (doc instanceof VendorCreditMemoDocument) {
                        // KFSPTS-2719
                        String crCmCancelNote = parameterService.getParameterValueAsString(VendorCreditMemoDocument.class, CUPurapParameterConstants.PURAP_CR_CM_CANCEL_NOTE);
                        VendorCreditMemoDocument cmDocument = (VendorCreditMemoDocument) doc;
                        String crCancelMaintDocNbr = getCrCancelMaintenancedocumentNumber(paymentDetail);
                        crCmCancelNote = crCmCancelNote + crCancelMaintDocNbr;
                        try {
                            Note noteObj = documentService.createNoteFromDocument(cmDocument, crCmCancelNote);
                            cmDocument.addNote(noteObj);
                            noteService.save(noteObj);
                        } catch (Exception e) {
                            throw new RuntimeException(e.getMessage());
                        }
                        // KFSUPGRADE-775
                        VendorCreditMemoDocument cm = (VendorCreditMemoDocument) doc;
                        AccountsPayableDocumentSpecificService accountsPayableDocumentSpecificService = cm.getDocumentSpecificService();
                        accountsPayableDocumentSpecificService.updateStatusByNode("", cm);
                        // end KFSUPGRADE-775
                        generateCreditMemoReversalEntries((VendorCreditMemoDocument) doc);
                    } else if (doc instanceof PaymentRequestDocument) {
                        // KFSPTS-2719
                        String crPreqCancelNote = parameterService.getParameterValueAsString(PaymentRequestDocument.class, CUPurapParameterConstants.PURAP_CR_PREQ_CANCEL_NOTE);
                        PaymentRequestDocument paymentRequest = (PaymentRequestDocument) doc;
                        String crCancelMaintDocNbr = getCrCancelMaintenancedocumentNumber(paymentDetail);
                        crPreqCancelNote = crPreqCancelNote + crCancelMaintDocNbr;
                        try {
                            Note cancelNote = documentService.createNoteFromDocument(paymentRequest, crPreqCancelNote);
                            paymentRequest.addNote(cancelNote);
                            noteService.save(cancelNote);
                        } catch (Exception e) {
                            throw new RuntimeException(PurapConstants.REQ_UNABLE_TO_CREATE_NOTE + " " + e);
                        }
                        // cancel extracted should not reopen PO
                        paymentRequest.setReopenPurchaseOrderIndicator(false);
                        // KFSUPGRADE-775
                        AccountsPayableDocumentSpecificService accountsPayableDocumentSpecificService = paymentRequest.getDocumentSpecificService();
                        accountsPayableDocumentSpecificService.updateStatusByNode("", paymentRequest);
                        // end KFSUPGRADE-775
                        generatePaymentRequestReversalEntries(paymentRequest);
                    }
                }
            }
        } catch (WorkflowException we) {
            System.out.println("Exception retrieving document " + paymentDetail.getCustPaymentDocNbr());
        }
    }
}
Also used : VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) AccountsPayableDocumentSpecificService(org.kuali.kfs.module.purap.document.service.AccountsPayableDocumentSpecificService) Note(org.kuali.kfs.krad.bo.Note) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) AccountingDocumentBase(org.kuali.kfs.sys.document.AccountingDocumentBase) VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) Document(org.kuali.kfs.krad.document.Document) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException)

Example 10 with Document

use of org.kuali.kfs.krad.document.Document in project cu-kfs by CU-CommunityApps.

the class CreateAccountingDocumentServiceImplTest method buildMockDocumentService.

private DocumentService buildMockDocumentService() throws Exception {
    DocumentService documentService = EasyMock.createMock(DocumentService.class);
    Capture<Document> documentArg = EasyMock.newCapture();
    EasyMock.expect(documentService.routeDocument(EasyMock.capture(documentArg), EasyMock.anyObject(), EasyMock.anyObject())).andStubAnswer(() -> recordAndReturnDocumentIfValid(documentArg.getValue()));
    EasyMock.replay(documentService);
    return documentService;
}
Also used : Document(org.kuali.kfs.krad.document.Document) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) InternalBillingDocument(org.kuali.kfs.fp.document.InternalBillingDocument) DocumentService(org.kuali.kfs.krad.service.DocumentService)

Aggregations

Document (org.kuali.kfs.krad.document.Document)17 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)5 DocumentService (org.kuali.kfs.krad.service.DocumentService)5 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)5 Note (org.kuali.kfs.krad.bo.Note)4 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)3 VendorCreditMemoDocument (org.kuali.kfs.module.purap.document.VendorCreditMemoDocument)3 AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)3 HashMap (java.util.HashMap)2 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)2 Attachment (org.kuali.kfs.krad.bo.Attachment)2 DocumentHeader (org.kuali.kfs.krad.bo.DocumentHeader)2 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)2 Person (org.kuali.rice.kim.api.identity.Person)2 AccountExtendedAttribute (edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute)1 AppropriationAccount (edu.cornell.kfs.coa.businessobject.AppropriationAccount)1 SubFundProgram (edu.cornell.kfs.coa.businessobject.SubFundProgram)1 AccountReversionTrickleDownInactivationService (edu.cornell.kfs.coa.service.AccountReversionTrickleDownInactivationService)1 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)1 CuDistributionOfIncomeAndExpenseDocument (edu.cornell.kfs.fp.document.CuDistributionOfIncomeAndExpenseDocument)1