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

Add parameter to a publisher and a handler event in report 790 "Calculate Inventory" #28177

Open
jmartin93 opened this issue Feb 19, 2025 · 0 comments

Comments

@jmartin93
Copy link

Describe the request

Hi there,
This is related to #26525 (comment), we still need a few more changes to make it work and split by item tracking.

In the requested event that is already added, we need the global WhseEntry as a parameter:

Previous:

local procedure ItemBinLocationIsCalculated(BinCode: Code[20]): Boolean
    var
        IsHandled: Boolean;
        IsCalculated: Boolean;
    begin
        IsHandled := false;
        OnBeforeItemBinLocationIsCalculated("Item Ledger Entry", IsHandled, IsCalculated);
        if IsHandled then
            exit(IsCalculated);

        TempQuantityOnHandBuffer.Reset();
        TempQuantityOnHandBuffer.SetRange("Item No.", "Item Ledger Entry"."Item No.");
        TempQuantityOnHandBuffer.SetRange("Variant Code", "Item Ledger Entry"."Variant Code");
        TempQuantityOnHandBuffer.SetRange("Location Code", "Item Ledger Entry"."Location Code");
        TempQuantityOnHandBuffer.SetRange("Bin Code", BinCode);
        exit(TempQuantityOnHandBuffer.Find('-'));
    end;
[IntegrationEvent(false, false)]
    local procedure OnBeforeItemBinLocationIsCalculated(ItemLedgerEntry: Record "Item Ledger Entry"; var IsHandled: Boolean; var IsCalculated: Boolean)
    begin
    end;

New:

[IntegrationEvent(false, false)]
    local procedure OnBeforeItemBinLocationIsCalculated(ItemLedgerEntry: Record "Item Ledger Entry"; var IsHandled: Boolean; var IsCalculated: Boolean; var WarehouseEntry: Record "Warehouse Entry")
    begin
    end;
    local procedure ItemBinLocationIsCalculated(BinCode: Code[20]): Boolean
    var
        IsHandled: Boolean;
        IsCalculated: Boolean;
    begin
        IsHandled := false;
        <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        OnBeforeItemBinLocationIsCalculated("Item Ledger Entry", IsHandled, IsCalculated, WhseEntry);
        >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        if IsHandled then
            exit(IsCalculated);

        TempQuantityOnHandBuffer.Reset();
        TempQuantityOnHandBuffer.SetRange("Item No.", "Item Ledger Entry"."Item No.");
        TempQuantityOnHandBuffer.SetRange("Variant Code", "Item Ledger Entry"."Variant Code");
        TempQuantityOnHandBuffer.SetRange("Location Code", "Item Ledger Entry"."Location Code");
        TempQuantityOnHandBuffer.SetRange("Bin Code", BinCode);
        exit(TempQuantityOnHandBuffer.Find('-'));
    end;

And a handler publisher to skip the findlast that moves the pointer for all the same bin codes, in the OnAfterGetRecord of "Item Ledger Entry":

if ExecuteLoop then begin
        WhseEntry.SetRange("Item No.", "Item No.");
        WhseEntry.SetRange("Location Code", "Location Code");
        WhseEntry.SetRange("Variant Code", "Variant Code");
        if WhseEntry.Find('-') then
            if WhseEntry."Entry No." <> OldWhseEntry."Entry No." then begin
                OldWhseEntry := WhseEntry;
                repeat
                    WhseEntry.SetRange("Bin Code", WhseEntry."Bin Code");
                    if not ItemBinLocationIsCalculated(WhseEntry."Bin Code") then begin
                        WhseEntry.CalcSums("Qty. (Base)");
                        OnItemLedgerEntryOnAfterGetRecordOnBeforeUpdateBuffer(WhseEntry);
                        UpdateBuffer(WhseEntry."Bin Code", WhseEntry."Qty. (Base)", false);
                    end;
                    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                    IsHandled := false;
                    OnWhseEntryLoopOnBeforeFindlast(WhseEntry, IsHandled);
                    if not isHandled then
                    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                        WhseEntry.Find('+');
                    Item.CopyFilter("Bin Filter", WhseEntry."Bin Code");
                until WhseEntry.Next() = 0;
            end;
 end;
[IntegrationEvent(false, false)]
    local procedure OnWhseEntryLoopOnBeforeFindlast(var WarehouseEntry: Record "Warehouse Entry"; var Ishandled: Boolean)
    begin
    end;

Additional context

We need this to split by item tracking in report 790 "Calculate Inventory" in the specific case of bin codes

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