Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Event Request] Codeunit 5896 "Calc. Inventory Adjmt. - Order" - Procedure CalcExactCostReversingQty - OnAfterCalcExactCostReversingQty #28019

Open
mavohra opened this issue Jan 30, 2025 · 0 comments

Comments

@mavohra
Copy link

mavohra commented Jan 30, 2025

Describe the request

Please add an event OnAfterCalcExactCostReversingQty in the procedure CalcExactCostReversingQty in Codeunit 5896 "Calc. Inventory Adjmt. - Order"

local procedure CalcExactCostReversingQty(ItemLedgEntry: Record "Item Ledger Entry") Qty: Decimal
    var
        OutbndItemLedgEntry: Record "Item Ledger Entry";
        ItemApplnEntry: Record "Item Application Entry";
        TempItemLedgEntryInChain: Record "Item Ledger Entry" temporary;

    begin

        OutbndItemLedgEntry.SetCurrentKey("Order Type", "Order No.", "Order Line No.", "Entry Type");
        OutbndItemLedgEntry.SetRange("Order Type", ItemLedgEntry."Order Type");
        OutbndItemLedgEntry.SetRange("Order No.", ItemLedgEntry."Order No.");
        OutbndItemLedgEntry.SetRange("Order Line No.", ItemLedgEntry."Order Line No.");
        OutbndItemLedgEntry.SetRange("Entry Type", ItemLedgEntry."Entry Type");
        OutbndItemLedgEntry.SetRange(Positive, false);
        OutbndItemLedgEntry.SetFilter("Applies-to Entry", '<>0');
        if OutbndItemLedgEntry.IsEmpty() then
            exit(0);

        ItemApplnEntry.GetVisitedEntries(ItemLedgEntry, TempItemLedgEntryInChain, true);
        TempItemLedgEntryInChain.SetRange("Order Type", ItemLedgEntry."Order Type");
        TempItemLedgEntryInChain.SetRange("Order No.", ItemLedgEntry."Order No.");
        TempItemLedgEntryInChain.SetRange("Order Line No.", ItemLedgEntry."Order Line No.");
        TempItemLedgEntryInChain.SetRange("Entry Type", ItemLedgEntry."Entry Type");
        TempItemLedgEntryInChain.SetRange(Positive, false);
        TempItemLedgEntryInChain.SetFilter("Applies-to Entry", '<>0');
        TempItemLedgEntryInChain.CalcSums(Quantity);
        Qty := TempItemLedgEntryInChain.Quantity;

        OnAfterCalcExactCostReversingQty(ItemLedgEntry, Qty); // <--- New Event
    end;
[IntegrationEvent(false, false)]
    local procedure OnAfterCalcExactCostReversingQty(ItemLedgEntry: Record "Item Ledger Entry"; var Qty: Decimal)
    begin
    end;

Additional context

We want to override the calculation of Qty with our own logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant