Search in sources :

Example 6 with VendorCreditMemoDocument

use of org.kuali.kfs.module.purap.document.VendorCreditMemoDocument in project cu-kfs by CU-CommunityApps.

the class CuBatchExtractServiceImpl method findCreditMemoDocument.

/**
 * Retrieves a credit memo document for a specific document number
 *
 * @param entry GL Line
 * @return CreditMemoDocument
 */
@Override
protected VendorCreditMemoDocument findCreditMemoDocument(Entry entry) {
    VendorCreditMemoDocument creditMemoDocument = null;
    Map<String, String> keys = new LinkedHashMap<String, String>();
    keys.put(CamsPropertyConstants.DOCUMENT_NUMBER, entry.getDocumentNumber());
    Class<? extends Document> docClass = dataDictionaryService.getDocumentClassByTypeName(PurapConstants.PurapDocTypeCodes.CREDIT_MEMO_DOCUMENT);
    Collection<? extends Document> matchingCms = businessObjectService.findMatching(docClass, keys);
    if (matchingCms != null && matchingCms.size() == 1) {
        creditMemoDocument = (VendorCreditMemoDocument) matchingCms.iterator().next();
    }
    return creditMemoDocument;
}
Also used : VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) LinkedHashMap(java.util.LinkedHashMap)

Example 7 with VendorCreditMemoDocument

use of org.kuali.kfs.module.purap.document.VendorCreditMemoDocument 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 8 with VendorCreditMemoDocument

use of org.kuali.kfs.module.purap.document.VendorCreditMemoDocument in project cu-kfs by CU-CommunityApps.

the class CuBatchExtractServiceImplTest method testFindCreditMemoDocument.

@Test
public void testFindCreditMemoDocument() {
    VendorCreditMemoDocument vendorCreditMemoDocument = cuBatchExtractServiceImpl.findCreditMemoDocument(EntryFixture.VCM_5319793.createEntry());
    assertNotNull("vendor credit memo should have been non-null", vendorCreditMemoDocument);
    assertEquals("Wrong credit memo document was retrieved", CuCamsTestConstants.DOC_5319793, vendorCreditMemoDocument.getDocumentNumber());
    vendorCreditMemoDocument = cuBatchExtractServiceImpl.findCreditMemoDocument(EntryFixture.VCM_NONEXISTENT_DOC.createEntry());
    assertNull("vendor credit memo should have been null", vendorCreditMemoDocument);
}
Also used : VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) Test(org.junit.Test)

Example 9 with VendorCreditMemoDocument

use of org.kuali.kfs.module.purap.document.VendorCreditMemoDocument in project cu-kfs by CU-CommunityApps.

the class CuPurchasingAccountsPayableModuleServiceImplTest method testHandlePurchasingBatchCancels_NonCRCancel.

public void testHandlePurchasingBatchCancels_NonCRCancel() throws WorkflowException {
    VendorCreditMemoDocument creditMemoDocument = VendorCreditMemoDocumentFixture.VENDOR_CREDIT_MEMO.createVendorCreditMemoDocument();
    accountsPayableModuleServiceImpl.handlePurchasingBatchCancels(creditMemoDocument.getDocumentNumber(), creditMemoDocument.getDocumentType(), true, false, false);
    assertTrue(PurapConstants.CreditMemoStatuses.CANCELLED_STATUSES.contains(creditMemoDocument.getApplicationDocumentStatus()));
}
Also used : VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument)

Example 10 with VendorCreditMemoDocument

use of org.kuali.kfs.module.purap.document.VendorCreditMemoDocument in project cu-kfs by CU-CommunityApps.

the class CuBatchExtractServiceImpl method separatePOLines.

/**
 * @see org.kuali.kfs.module.cam.batch.service.BatchExtractService#separatePOLines(java.util.List, java.util.List,
 *      java.util.Collection)
 */
@Override
public void separatePOLines(List<Entry> fpLines, List<Entry> purapLines, Collection<Entry> elgibleGLEntries) {
    for (Entry entry : elgibleGLEntries) {
        if (CamsConstants.PREQ.equals(entry.getFinancialDocumentTypeCode())) {
            purapLines.add(entry);
        } else if (!CamsConstants.CM.equals(entry.getFinancialDocumentTypeCode())) {
            fpLines.add(entry);
        } else if (CamsConstants.CM.equals(entry.getFinancialDocumentTypeCode())) {
            Map<String, String> fieldValues = new HashMap<String, String>();
            fieldValues.put(CamsPropertyConstants.GeneralLedgerEntry.DOCUMENT_NUMBER, entry.getDocumentNumber());
            Class<? extends Document> docClass = dataDictionaryService.getDocumentClassByTypeName(PurapConstants.PurapDocTypeCodes.CREDIT_MEMO_DOCUMENT);
            // check if vendor credit memo, then include as FP line
            Collection<? extends Document> matchingCreditMemos = businessObjectService.findMatching(docClass, fieldValues);
            for (Document document : matchingCreditMemos) {
                VendorCreditMemoDocument creditMemoDocument = (VendorCreditMemoDocument) document;
                if (creditMemoDocument.getPurchaseOrderIdentifier() == null) {
                    fpLines.add(entry);
                } else {
                    purapLines.add(entry);
                }
            }
        }
    }
}
Also used : VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) Entry(org.kuali.kfs.gl.businessobject.Entry) GeneralLedgerEntry(org.kuali.kfs.module.cam.businessobject.GeneralLedgerEntry) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) Document(org.kuali.kfs.krad.document.Document) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) PurchasingAccountsPayableDocument(org.kuali.kfs.module.cam.businessobject.PurchasingAccountsPayableDocument)

Aggregations

VendorCreditMemoDocument (org.kuali.kfs.module.purap.document.VendorCreditMemoDocument)18 CuVendorCreditMemoDocument (edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument)7 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)5 Note (org.kuali.kfs.krad.bo.Note)3 LinkedHashMap (java.util.LinkedHashMap)2 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)2 Document (org.kuali.kfs.krad.document.Document)2 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)2 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)2 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)2 CreditMemoWireTransfer (edu.cornell.kfs.module.purap.businessobject.CreditMemoWireTransfer)1 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)1 Entry (org.kuali.kfs.gl.businessobject.Entry)1 ExtraButton (org.kuali.kfs.kns.web.ui.ExtraButton)1