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 99000872 "Sales Availability Mgt." - SetSalesHeader #28185

Open
fvet opened this issue Feb 20, 2025 · 0 comments
Open

Comments

@fvet
Copy link
Contributor

fvet commented Feb 20, 2025

Describe the request

We've created specific item / inventory sales lines in our add-on which should be excluded from Order Promising calculation.
Therefore, we would like to have an event to filter out sales lines, preferably by adding a filter, alternatively by allowing to bypass the AvailabilityManagement.InsertPromisingLine.

Image

Ideally, we would like to apply a filter using an event which has var access to the SalesLine record.

OnSetSalesHeaderOnBeforeSalesLineFindSet(SalesLine); // var

 procedure SetSalesHeader(var OrderPromisingLine: Record "Order Promising Line"; var SalesHeader: Record "Sales Header"; var CaptionText: Text)
    var
        SalesLine: Record "Sales Line";
        SalesAvailabilityMgt: Codeunit "Sales Availability Mgt.";
    begin
        CaptionText := SalesOrderTxt;
        OrderPromisingLine.DeleteAll();
        SalesLine.SetRange("Document Type", SalesHeader."Document Type");
        SalesLine.SetRange("Document No.", SalesHeader."No.");
        SalesLine.SetRange(Type, SalesLine.Type::Item);
        SalesLine.SetFilter("Outstanding Quantity", '>0');
        OnSetSalesHeaderOnBeforeSalesLineFindSet(SalesLine); // Add New event here
        if SalesLine.FindSet() then
            repeat
                if SalesLine.IsInventoriableItem() then begin
                    OrderPromisingLine.Init();
                    OrderPromisingLine."Entry No." := OrderPromisingLine.GetLastEntryNo() + 10000;
                    SalesAvailabilityMgt.TransferToOrderPromisingLine(OrderPromisingLine, SalesLine);
                    SalesLine.CalcFields("Reserved Qty. (Base)");
                    AvailabilityManagement.InsertPromisingLine(
                        OrderPromisingLine, SalesLine."Outstanding Qty. (Base)" - SalesLine."Reserved Qty. (Base)");
                end;
            until SalesLine.Next() = 0;
    end;

PS: Also provide similar solution for Job Planning and Service lines to be consistent.

Additional context

x

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