Search in sources :

Example 11 with VendorCreditMemoDocument

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

the class CuVendorCreditMemoDocumentPresentationController method getEditModes.

@Override
public Set<String> getEditModes(Document document) {
    Set<String> editModes = super.getEditModes(document);
    // KFSPTS-1891
    editModes.add(KfsAuthorizationConstants.TransactionalEditMode.FRN_ENTRY);
    editModes.add(KfsAuthorizationConstants.TransactionalEditMode.WIRE_ENTRY);
    VendorCreditMemoDocument vendorCreditMemoDocument = (VendorCreditMemoDocument) document;
    // KFSPTS-1891, KFSPTS-2851
    if (canApprove(vendorCreditMemoDocument) && canEditAmount(vendorCreditMemoDocument)) {
        editModes.add(CUPaymentRequestEditMode.EDIT_AMOUNT);
    }
    if (vendorCreditMemoDocument.isDocumentStoppedInRouteNode(PurapConstants.PaymentRequestStatuses.NODE_PAYMENT_METHOD_REVIEW)) {
        editModes.add(CUPaymentRequestEditMode.WAIVE_WIRE_FEE_EDITABLE);
    }
    return editModes;
}
Also used : VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument)

Example 12 with VendorCreditMemoDocument

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

the class CuPurapAccountingServiceImpl method updateAccountAmounts.

/**
 * @see org.kuali.kfs.module.purap.service.PurapAccountingService#updateAccountAmounts(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)
 */
@Override
public void updateAccountAmounts(PurchasingAccountsPayableDocument document) {
    PurchasingAccountsPayableDocumentBase purApDocument = (PurchasingAccountsPayableDocumentBase) document;
    String accountDistributionMethod = purApDocument.getAccountDistributionMethod();
    KualiRuleService kualiRuleService = SpringContext.getBean(KualiRuleService.class);
    WorkflowDocument workflowDocument = purApDocument.getDocumentHeader().getWorkflowDocument();
    Set<String> nodeNames = workflowDocument.getCurrentNodeNames();
    // don't update if past the AP review level
    if ((document instanceof PaymentRequestDocument) && purapService.isFullDocumentEntryCompleted(document)) {
        if (nodeNames.contains(PaymentRequestStatuses.NODE_PAYMENT_METHOD_REVIEW)) {
            // CU needs this update because the customization allows Treasury Manager to change unit/extended price and 'calculate'
            for (PurApItem item : document.getItems()) {
                updatePreqItemAccountAmountsOnly(item);
            }
        } else {
            convertMoneyToPercent((PaymentRequestDocument) document);
        }
        return;
    }
    document.fixItemReferences();
    // if distribution method is sequential and document is PREQ or VCM then...
    if (((document instanceof PaymentRequestDocument) || (document instanceof VendorCreditMemoDocument)) && PurapConstants.AccountDistributionMethodCodes.SEQUENTIAL_CODE.equalsIgnoreCase(accountDistributionMethod)) {
        if (document instanceof VendorCreditMemoDocument) {
            VendorCreditMemoDocument cmDocument = (VendorCreditMemoDocument) document;
            cmDocument.updateExtendedPriceOnItems();
            for (PurApItem item : document.getItems()) {
                for (PurApAccountingLine account : item.getSourceAccountingLines()) {
                    account.setAmount(KualiDecimal.ZERO);
                }
            }
        }
        // update the accounts amounts for PREQ and distribution method = sequential
        for (PurApItem item : document.getItems()) {
            updatePreqItemAccountAmounts(item);
        }
        return;
    }
    // if distribution method is proportional and document is PREQ or VCM then...
    if (((document instanceof PaymentRequestDocument) || (document instanceof VendorCreditMemoDocument)) && PurapConstants.AccountDistributionMethodCodes.PROPORTIONAL_CODE.equalsIgnoreCase(accountDistributionMethod)) {
        // update the accounts amounts for PREQ and distribution method = sequential
        if (document instanceof VendorCreditMemoDocument) {
            VendorCreditMemoDocument cmDocument = (VendorCreditMemoDocument) document;
            cmDocument.updateExtendedPriceOnItems();
            for (PurApItem item : document.getItems()) {
                for (PurApAccountingLine account : item.getSourceAccountingLines()) {
                    account.setAmount(KualiDecimal.ZERO);
                }
            }
        }
        for (PurApItem item : document.getItems()) {
            boolean rulePassed = true;
            // check any business rules
            rulePassed &= kualiRuleService.applyRules(new PurchasingAccountsPayableItemPreCalculateEvent(document, item));
            if (rulePassed) {
                updatePreqProportionalItemAccountAmounts(item);
            }
        }
        return;
    }
    // No recalculate if the account distribution method code is equal to "S" sequential ON REQ or POs..
    if (PurapConstants.AccountDistributionMethodCodes.SEQUENTIAL_CODE.equalsIgnoreCase(accountDistributionMethod)) {
        for (PurApItem item : document.getItems()) {
            boolean rulePassed = true;
            // check any business rules
            rulePassed &= kualiRuleService.applyRules(new PurchasingAccountsPayableItemPreCalculateEvent(document, item));
            return;
        }
    }
    // do recalculate only if the account distribution method code is not equal to "S" sequential method.
    if (!PurapConstants.AccountDistributionMethodCodes.SEQUENTIAL_CODE.equalsIgnoreCase(accountDistributionMethod)) {
        for (PurApItem item : document.getItems()) {
            boolean rulePassed = true;
            // check any business rules
            rulePassed &= kualiRuleService.applyRules(new PurchasingAccountsPayableItemPreCalculateEvent(document, item));
            if (rulePassed) {
                updateItemAccountAmounts(item);
            }
        }
    }
}
Also used : VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurchasingAccountsPayableDocumentBase(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocumentBase) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) PurchasingAccountsPayableItemPreCalculateEvent(org.kuali.kfs.module.purap.document.validation.event.PurchasingAccountsPayableItemPreCalculateEvent)

Example 13 with VendorCreditMemoDocument

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

the class CuPurchasingAccountsPayableModuleServiceImplTest method testHandlePurchasingBatchCancels_CRCancel.

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

Example 14 with VendorCreditMemoDocument

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

the class CuCreditMemoServiceImpl method removeHoldOnCreditMemo.

/**
 * @see org.kuali.kfs.module.purap.document.service.CreditMemoService#removeHoldOnCreditMemo(org.kuali.kfs.module.purap.document.CreditMemoDocument,
 *      java.lang.String)
 */
@Override
public VendorCreditMemoDocument removeHoldOnCreditMemo(VendorCreditMemoDocument cmDocument, String note) throws Exception {
    // save the note
    Note noteObj = documentService.createNoteFromDocument(cmDocument, note);
    cmDocument.addNote(noteObj);
    noteService.save(noteObj);
    // retrieve and save with hold indicator set to false
    VendorCreditMemoDocument cmDoc = getCreditMemoDocumentById(cmDocument.getPurapDocumentIdentifier());
    cmDoc.setHoldIndicator(false);
    cmDoc.setLastActionPerformedByPersonId(null);
    purapService.saveDocumentNoValidation(cmDoc);
    // force reindexing
    reIndexDocument(cmDoc);
    // must also save it on the incoming document
    cmDocument.setHoldIndicator(false);
    cmDocument.setLastActionPerformedByPersonId(null);
    // force reindexing
    reIndexDocument(cmDocument);
    return cmDoc;
}
Also used : VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) Note(org.kuali.kfs.krad.bo.Note)

Example 15 with VendorCreditMemoDocument

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

the class CuCreditMemoServiceImpl method addHoldOnCreditMemo.

@Override
public VendorCreditMemoDocument addHoldOnCreditMemo(VendorCreditMemoDocument cmDocument, String note) throws Exception {
    // save the note
    Note noteObj = documentService.createNoteFromDocument(cmDocument, note);
    cmDocument.addNote(noteObj);
    noteService.save(noteObj);
    // retrieve and save with hold indicator set to true
    VendorCreditMemoDocument cmDoc = getCreditMemoDocumentById(cmDocument.getPurapDocumentIdentifier());
    cmDoc.setHoldIndicator(true);
    cmDoc.setLastActionPerformedByPersonId(GlobalVariables.getUserSession().getPerson().getPrincipalId());
    purapService.saveDocumentNoValidation(cmDoc);
    // force reindexing
    reIndexDocument(cmDoc);
    // must also save it on the incoming document
    cmDocument.setHoldIndicator(true);
    cmDocument.setLastActionPerformedByPersonId(GlobalVariables.getUserSession().getPerson().getPrincipalId());
    // force reindexing
    reIndexDocument(cmDocument);
    return cmDoc;
}
Also used : VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) Note(org.kuali.kfs.krad.bo.Note)

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