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 7302 "WMS Management".CheckItemJnlLineFieldChange #27700

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

Comments

@fridrichovsky
Copy link
Contributor

fridrichovsky commented Nov 26, 2024

Describe the request

Please add new event

procedure CheckItemJnlLineFieldChange(ItemJnlLine: Record "Item Journal Line"; xItemJnlLine: Record "Item Journal Line"; CurrFieldCaption: Text[30])
    var
        BinContent: Record "Bin Content";
        WhseItemJournal: Page "Whse. Item Journal";
        WhsePhysInvtJournal: Page "Whse. Phys. Invt. Journal";
        BinIsEligible: Boolean;
        IsHandled: Boolean;
        Cubage: Decimal;
        Weight: Decimal;
    begin
        IsHandled := false;
        OnBeforeCheckItemJnlLineFieldChange(ItemJnlLine, xItemJnlLine, CurrFieldCaption, IsHandled);
        if IsHandled then
            exit;

        GetLocation(ItemJnlLine."Location Code");
        OnCheckIfBinIsEligible(ItemJnlLine, BinIsEligible);

        ShowError := CheckBinCodeChange(ItemJnlLine."Location Code", ItemJnlLine."Bin Code", xItemJnlLine."Bin Code") and not BinIsEligible;
        if not ShowError then
            ShowError := CheckBinCodeChange(ItemJnlLine."New Location Code", ItemJnlLine."New Bin Code", xItemJnlLine."New Bin Code");
        //-----------------------------------------------------------OnCheckItemJnlLineFieldChangeOnAfterCheclBinCodeChange:BEGIN
        OnCheckItemJnlLineFieldChangeOnAfterCheckBinCodeChange(ItemJnlLine, xItemJnlLine, CurrFieldCaption, ShowError, BinIsEligible)
        //-----------------------------------------------------------OnCheckItemJnlLineFieldChangeOnAfterCheclBinCodeChange:END
        if ShowError then
            Error(Text015,
              CurrFieldCaption,
              LowerCase(Location.TableCaption()), Location.Code, Location.FieldCaption("Directed Put-away and Pick"));

        if ItemJnlLine."Entry Type" in
           [ItemJnlLine."Entry Type"::"Negative Adjmt.", ItemJnlLine."Entry Type"::"Positive Adjmt.", ItemJnlLine."Entry Type"::Sale, ItemJnlLine."Entry Type"::Purchase]
        then begin
            if (ItemJnlLine."Location Code" <> xItemJnlLine."Location Code") and (xItemJnlLine."Location Code" <> '') then begin
                GetLocation(xItemJnlLine."Location Code");
                ShowError := Location."Directed Put-away and Pick";
            end;

            if ((ItemJnlLine."Item No." <> xItemJnlLine."Item No.") and (xItemJnlLine."Item No." <> '')) or
               ((ItemJnlLine.Quantity <> xItemJnlLine.Quantity) and (xItemJnlLine.Quantity <> 0)) or
               (ItemJnlLine."Variant Code" <> xItemJnlLine."Variant Code") or
               (ItemJnlLine."Unit of Measure Code" <> xItemJnlLine."Unit of Measure Code") or
               (ItemJnlLine."Entry Type" <> xItemJnlLine."Entry Type") or
               (ItemJnlLine."Phys. Inventory" and
                (ItemJnlLine."Qty. (Phys. Inventory)" <> xItemJnlLine."Qty. (Phys. Inventory)") or
                (ItemJnlLine.Quantity <> xItemJnlLine.Quantity))
            then begin
                GetLocation(ItemJnlLine."Location Code");
                ShowError := Location."Directed Put-away and Pick";
            end;
            //----------------------------------------------------------------------OnCheckItemJnlLineFieldChangeOnAfterAssignShowError:BEGIN
            OnCheckItemJnlLineFieldChangeOnAfterAssignShowError(ItemJnlLine, xItemJnlLine, CurrFieldCaption, ShowError)
            //----------------------------------------------------------------------OnCheckItemJnlLineFieldChangeOnAfterAssignShowError:END
            if ShowError then begin
                if ItemJnlLine."Phys. Inventory" then
                    Error(Text010,
                      CurrFieldCaption,
                      Location.TableCaption(), Location.Code, Location.FieldCaption("Directed Put-away and Pick"),
                      WhsePhysInvtJournal.Caption);

                Error(Text010,
                  CurrFieldCaption,
                  Location.TableCaption(), Location.Code, Location.FieldCaption("Directed Put-away and Pick"),
                  WhseItemJournal.Caption);
            end;
            GetLocation(ItemJnlLine."Location Code");
            if not Location."Bin Mandatory" then
                exit;
            if Location."Bin Capacity Policy" <> Location."Bin Capacity Policy"::"Never Check Capacity" then begin
                if ItemJnlLine."Bin Code" <> '' then begin
                    CalcCubageAndWeight(ItemJnlLine."Item No.", ItemJnlLine."Unit of Measure Code", ItemJnlLine.Quantity, Cubage, Weight);
                    if BinContent.Get(Location.Code, ItemJnlLine."Bin Code", ItemJnlLine."Item No.", ItemJnlLine."Variant Code", ItemJnlLine."Unit of Measure Code") then
                        BinContent.CheckIncreaseBinContent(ItemJnlLine.Quantity, 0, 0, 0, Cubage, Weight, false, false)
                    else begin
                        GetBin(Location.Code, ItemJnlLine."Bin Code");
                        Bin.CheckIncreaseBin(Bin.Code, ItemJnlLine."Item No.", ItemJnlLine.Quantity, 0, 0, Cubage, Weight, false, false);
                    end;
                end
            end else
                CheckWarehouseClass(Location.Code, ItemJnlLine."Bin Code", ItemJnlLine."Item No.", ItemJnlLine."Variant Code", ItemJnlLine."Unit of Measure Code");
        end;
    end;

    //-----------------------------------------------------------OnCheckItemJnlLineFieldChangeOnAfterCheclBinCodeChange:BEGIN
    [IntegrationEvent(true, false)]
    local procedure OnCheckItemJnlLineFieldChangeOnAfterCheckBinCodeChange(var ItemJnlLine: Record "Item Journal Line"; var xItemJnlLine: Record "Item Journal Line"; CurrFieldCaption: Text[30]; var ShowError: Boolean; var BinIsEligible: Boolean)

    begin
    end;
    //-----------------------------------------------------------OnCheckItemJnlLineFieldChangeOnAfterCheclBinCodeChange:END

    //----------------------------------------------------------------------OnCheckItemJnlLineFieldChangeOnAfterAssignShowError:BEGIN
    [IntegrationEvent(true, false)]
    local procedure OnCheckItemJnlLineFieldChangeOnAfterAssignShowError(var ItemJnlLine: Record "Item Journal Line"; var xItemJnlLine: Record "Item Journal Line"; CurrFieldCaption: Text[30]; var ShowError: Boolean)
    begin
    end;
    //----------------------------------------------------------------------OnCheckItemJnlLineFieldChangeOnAfterAssignShowError:END

Additional context

We need option change if error is show or not, because we do our different checks
Internal work item: AB#558859

@ChethanT ChethanT added event-request Request for adding an event SCM GitHub request for SCM area labels Nov 27, 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