Skip to content

[W1][Codeunit][7312][Create Pick] Add integration event OnUpdateToQtyToPickOnBeforeSetToQtyToPickBase in procedure UpdateToQtyToPick #30075

@mavohra

Description

@mavohra

Why do you need this change?

We need to intercept the calculation of ToQtyToPickBase in UpdateToQtyToPick in Codeunit 7312 "Create Pick" before the standard block that assigns ToQtyToPickBase := QtyAvailableBase and caps it to TotalQtyToPickBase. At this point all input quantities are resolved, making it the correct position to apply an alternative base quantity calculation.

The standard block unconditionally sets ToQtyToPickBase to QtyAvailableBase and then caps it to TotalQtyToPickBase. This comparison does not account for scenarios where a near-zero rounding threshold must be applied to determine whether the available quantity covers the total, requiring a different condition to decide which value to assign to ToQtyToPickBase.

No event exists in UpdateToQtyToPick at any point. The public OnBeforeUpdateQuantitiesToPick event fires in UpdateQuantitiesToPick before the call to UpdateToQtyToPick and exposes all quantity parameters with IsHandled, but its scope covers the entire UpdateQuantitiesToPick call chain including UpdateFromQtyToPick and UpdateTotalQtyToPick. A subscriber there would have to replicate all three sub-procedures to bypass only the ToQtyToPickBase assignment inside UpdateToQtyToPick.

Describe the request

Add an integration event OnUpdateToQtyToPickOnBeforeSetToQtyToPickBase in UpdateToQtyToPick in Codeunit 7312 "Create Pick" before the standard ToQtyToPickBase assignment block, with IsHandled to allow a subscriber to set ToQtyToPickBase and skip the standard assignment.

local procedure UpdateToQtyToPick(QtyAvailableBase: Decimal; ToQtyPerUOM: Decimal; var ToQtyToPick: Decimal; var ToQtyToPickBase: Decimal; TotalQtyToPick: Decimal; TotalQtyToPickBase: Decimal)
var
    IsHandled: Boolean;
begin
    IsHandled := false;
    OnUpdateToQtyToPickOnBeforeSetToQtyToPickBase(QtyAvailableBase, ToQtyPerUOM, ToQtyToPick, ToQtyToPickBase, TotalQtyToPick, TotalQtyToPickBase, IsHandled); // <---- New Event
    if not IsHandled then begin
        ToQtyToPickBase := QtyAvailableBase;
        if ToQtyToPickBase > TotalQtyToPickBase then
            ToQtyToPickBase := TotalQtyToPickBase;
    end;

    ToQtyToPick := Round(ToQtyToPickBase / ToQtyPerUOM, UnitOfMeasureManagement.QtyRndPrecision());
    if ToQtyToPick > TotalQtyToPick then
        ToQtyToPick := TotalQtyToPick;
    if (ToQtyToPick <> TotalQtyToPick) and (ToQtyToPickBase = TotalQtyToPickBase) then
        if Abs(1 - ToQtyToPick / TotalQtyToPick) <= UnitOfMeasureManagement.QtyRndPrecision() then
            ToQtyToPick := TotalQtyToPick;
end;

Event Signature:

[IntegrationEvent(false, false)]
local procedure OnUpdateToQtyToPickOnBeforeSetToQtyToPickBase(QtyAvailableBase: Decimal; ToQtyPerUOM: Decimal; var ToQtyToPick: Decimal; var ToQtyToPickBase: Decimal; TotalQtyToPick: Decimal; TotalQtyToPickBase: Decimal; var IsHandled: Boolean)
begin
end;

Alternatives evaluated: OnBeforeUpdateQuantitiesToPick fires in UpdateQuantitiesToPick before the call to UpdateToQtyToPick and exposes all quantity parameters with IsHandled, but bypassing it requires reimplementing the full UpdateFromQtyToPick and UpdateTotalQtyToPick logic alongside, since the entire call chain is skipped. No event exists inside UpdateToQtyToPick at any point.

Metadata

Metadata

Assignees

No one assigned

    Labels

    missing-infoThe issue misses information that prevents it from completion.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions