Skip to content

[Event Request] Codeunit 80 "Sales-Post" - Procedure SyncSurPlusItemTracking #29683

@cperezsx

Description

@cperezsx

Why do you need this change?

We would like to be able to customize the synchronization of reservations by expanding or modifying existing functionality.

Describe the request

Add new event "OnSyncSurPlusItemTrackingOnBeforeSetSourceFromSalesLine" to the procedure "SyncSurPlusItemTracking" of codeunit 80 "Sales-Post" Also change the check mark symbol < to <= on line 10451

`local procedure SyncSurPlusItemTracking(SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line")
var
Location2: Record Location;
ReservEntry: Record "Reservation Entry";
TempTrackingSpecification2: Record "Tracking Specification" temporary;
TempWarehouseActivityLine: Record "Warehouse Activity Line" temporary;
WarehouseAvailabilityMgt: Codeunit "Warehouse Availability Mgt.";
QtyReservedForCurrLine: Decimal;
SurplusQtyToHandle: Decimal;
isHandled: Boolean; //>New var
begin
if not SalesHeader.Ship then
exit;
if not (SalesHeader."Document Type" in [SalesHeader."Document Type"::Invoice, SalesHeader."Document Type"::Order]) then
exit;

    if (SalesLine."Location Code" = '') or
       not Location2.Get(SalesLine."Location Code") or
       not Location2."Require Shipment"
    then
        exit;
    //>New code begin
    OnSyncSurPlusItemTrackingOnBeforeSetSourceFromSalesLine(SalesHeader,SalesLine,IsHandled);
    if IsHandled then
         exit;
   //<<New Code End
    TempTrackingSpecification2.SetSourceFromSalesLine(SalesLine);
    TempTrackingSpecification2.SetSourceFromSalesLine(SalesLine);
    QtyReservedForCurrLine := Abs(WarehouseAvailabilityMgt.CalcLineReservedQtyOnInvt(
        TempTrackingSpecification2."Source Type", TempTrackingSpecification2."Source Subtype", TempTrackingSpecification2."Source ID", TempTrackingSpecification2."Source Ref. No.",
        0, false, TempWarehouseActivityLine));

    if QtyReservedForCurrLine = 0 then
        exit;

    ReservEntry.SetSourceFilter(
                             TempTrackingSpecification2."Source Type", TempTrackingSpecification2."Source Subtype",
                             TempTrackingSpecification2."Source ID", TempTrackingSpecification2."Source Ref. No.", true);
    ReservEntry.SetSourceFilter('', TempTrackingSpecification2."Source Prod. Order Line");
    ReservEntry.SetRange("Reservation Status", ReservEntry."Reservation Status"::Surplus);
    if not ReservEntry.FindSet() then
        exit;

    ReservEntry.CalcSums("Qty. to Handle (Base)");
    SurplusQtyToHandle := Abs(ReservEntry."Qty. to Handle (Base)");
    //>Change code Begin
    // if (QtyReservedForCurrLine + SurplusQtyToHandle) < SalesLine."Qty. to Ship (Base)" then> old Code
    if (QtyReservedForCurrLine + SurplusQtyToHandle) <= SalesLine."Qty. to Ship (Base)" then //> New code
    //>Change code end
        exit;

    ReservEntry.ModifyAll("Qty. to Handle (Base)", 0);
    ReservEntry.ModifyAll("Qty. to Invoice (Base)", 0);
end;

//>>New Code Begin
[IntegrationEvent(false, false)]
local procedure OnSyncSurPlusItemTrackingOnBeforeSetSourceFromSalesLine(SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; var isHandled: Boolean)
begin
end;
//<<New Code End`

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