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] Sales Header - GetQtyReservedFromStockState #27652

Open
fvet opened this issue Nov 19, 2024 · 0 comments
Open

[Event Request] Sales Header - GetQtyReservedFromStockState #27652

fvet opened this issue Nov 19, 2024 · 0 comments
Labels
event-request Request for adding an event SCM GitHub request for SCM area

Comments

@fvet
Copy link
Contributor

fvet commented Nov 19, 2024

Describe the request

In table 36 Sales Header, GetQtyReservedFromStockState, we would like to exclude certain sales lines that will never have reservations from the 'outstanding qty' calculation used by the 'reserved from stock' calculation.

Suggestion 1

 #region GetQtyReservedFromStockState
    internal procedure GetQtyReservedFromStockState() Result: Enum "Reservation From Stock"
    var
        SalesLineLocal: Record "Sales Line";
        QtyReservedFromStock: Decimal;
    begin
        QtyReservedFromStock := SalesLineReserve.GetReservedQtyFromInventory(Rec);

        SalesLineLocal.SetRange("Document Type", "Document Type");
        SalesLineLocal.SetRange("Document No.", "No.");
        SalesLineLocal.SetRange(Type, SalesLineLocal.Type::Item);

        OnBeforeGetQtyReservedFromStockState(SalesLineLocal); // Added publisher here

        SalesLineLocal.CalcSums("Outstanding Qty. (Base)");

        case QtyReservedFromStock of
            0:
                exit(Result::None);
            SalesLineLocal."Outstanding Qty. (Base)":
                exit(Result::Full);
            else
                exit(Result::Partial);
        end;
    end;
    #endregion GetQtyReservedFromStockState

    [IntegrationEvent(false, false)]
    local procedure OnGetQtyReservedFromStockStateOnSetSalesLineFilters(var SalesLine: Record "Sales Line")
    begin
    end;

Suggestion 2 (Prefered)


 #region GetQtyReservedFromStockState
    internal procedure GetQtyReservedFromStockState() Result: Enum "Reservation From Stock"    
    begin        
        case SalesLineReserve.GetReservedQtyFromInventory(Rec) of
            0:
                exit(Result::None);
            GetOutstandingQuantity(): // Move inside case = less reduncant calls if no reservations at all
                exit(Result::Full);
            else
                exit(Result::Partial);
        end;
    end;
    #endregion GetQtyReservedFromStockState

    #region GetOutstandingQuantity
    local procedure GetOutstandingQuantity() : Decimal
    var
        SalesLineLocal: Record "Sales Line";
    begin
       // Move to separate function, cleaner signature together with OnBefore publisher

        OnBeforeGetOutstandingQuantity(SalesLineLocal);

        SalesLineLocal.SetRange("Document Type", "Document Type");
        SalesLineLocal.SetRange("Document No.", "No.");
        SalesLineLocal.SetRange(Type, SalesLineLocal.Type::Item);

        SalesLineLocal.CalcSums("Outstanding Qty. (Base)");
        exit(SalesLineLocal."Outstanding Qty. (Base)");
    end;
    #endregion GetOutstandingQuantity

     [IntegrationEvent(false, false)]
    local procedure OnGetQtyReservedFromStockStateOnSetSalesLineFilters(var SalesLine: Record "Sales Line")
    begin
    end;

Additional context

x
Internal work item: AB#558149

@JesperSchulz JesperSchulz added event-request Request for adding an event SCM GitHub request for SCM area labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event-request Request for adding an event SCM GitHub request for SCM area
Projects
None yet
Development

No branches or pull requests

2 participants