Skip to content

[DE][Codeunit][6620][Copy Document Mgt.] OnBeforeInsertOldSalesDocNoLine and OnBeforeInsertOldPurchDocNoLine #29515

@dannoe

Description

@dannoe

Why do you need this change?

We want to add more lines, so we need to increase the 'NextLineNo' for the next upcoming lines.

Describe the request

local procedure InsertOldPurchDocNoLine(ToPurchHeader: Record "Purchase Header"; OldDocNo: Code[20]; OldDocType: Integer; var NextLineNo: Integer)
    var
        ToPurchLine2: Record "Purchase Line";
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforeInsertOldPurchDocNoLineProcedure(ToPurchHeader, ToPurchLine2, OldDocType, OldDocNo, IsHandled);
        if IsHandled then
            exit;

        if ShouldSkipCopyFromDescription() then
            exit;

        NextLineNo := NextLineNo + 10000;
        ToPurchLine2.Init();
        ToPurchLine2."Line No." := NextLineNo;
        ToPurchLine2."Document Type" := ToPurchHeader."Document Type";
        ToPurchLine2."Document No." := ToPurchHeader."No.";

        TranslationHelper.SetGlobalLanguageByCode(ToPurchHeader."Language Code");
        if InsertCancellationLine then
            ToPurchLine2.Description := StrSubstNo(CrMemoCancellationMsg, OldDocNo)
        else
            ToPurchLine2.Description := StrSubstNo(Text015, SelectStr(OldDocType, Text014), OldDocNo);
        TranslationHelper.RestoreGlobalLanguage();

        IsHandled := false;
-       OnBeforeInsertOldPurchDocNoLine(ToPurchHeader, ToPurchLine2, OldDocType, OldDocNo, IsHandled);
+       OnBeforeInsertOldPurchDocNoLine(ToPurchHeader, ToPurchLine2, OldDocType, OldDocNo, NextLineNo, IsHandled);
        if not IsHandled then
            ToPurchLine2.Insert();
    end;

    [IntegrationEvent(true, false)]
-   local procedure OnBeforeInsertOldPurchDocNoLine(ToPurchHeader: Record "Purchase Header"; var ToPurchLine: Record "Purchase Line"; OldDocType: Option; OldDocNo: Code[20]; var IsHandled: Boolean)
+   local procedure OnBeforeInsertOldPurchDocNoLine(ToPurchHeader: Record "Purchase Header"; var ToPurchLine: Record "Purchase Line"; OldDocType: Option; OldDocNo: Code[20]; var NextLineNo: Integer;var IsHandled: Boolean) 
    begin
    end;
    procedure InsertOldSalesDocNoLine(ToSalesHeader: Record "Sales Header"; OldDocNo: Code[20]; OldDocType: Integer; var NextLineNo: Integer)
    var
        ToSalesLine2: Record "Sales Line";
        ShouldIncrementNextLineNo: Boolean;
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforeInsertOldSalesDocNoLineProcedure(ToSalesHeader, ToSalesLine2, OldDocType, OldDocNo, IsHandled);
        if IsHandled then
            exit;

        if ShouldSkipCopyFromDescription() then
            exit;

        ShouldIncrementNextLineNo := true;
        OnInsertOldSalesDocNoLineOnBeforeIncrementNextLineNo(ToSalesHeader, ShouldIncrementNextLineNo, NextLineNo);
        if ShouldIncrementNextLineNo then
            NextLineNo := NextLineNo + 10000;
        ToSalesLine2.Init();
        ToSalesLine2."Line No." := NextLineNo;
        ToSalesLine2."Document Type" := ToSalesHeader."Document Type";
        ToSalesLine2."Document No." := ToSalesHeader."No.";

        TranslationHelper.SetGlobalLanguageByCode(ToSalesHeader."Language Code");
        if InsertCancellationLine then
            ToSalesLine2.Description := StrSubstNo(CrMemoCancellationMsg, OldDocNo)
        else
            ToSalesLine2.Description := StrSubstNo(Text015, SelectStr(OldDocType, Text013), OldDocNo);
        TranslationHelper.RestoreGlobalLanguage();

        IsHandled := false;
-       OnBeforeInsertOldSalesDocNoLine(ToSalesHeader, ToSalesLine2, OldDocType, OldDocNo, IsHandled);
+        OnBeforeInsertOldSalesDocNoLine(ToSalesHeader, ToSalesLine2, OldDocType, OldDocNo, NextLineNo, IsHandled);
        if not IsHandled then
            ToSalesLine2.Insert();
    end;

   [IntegrationEvent(true, false)]
-   local procedure OnBeforeInsertOldSalesDocNoLine(var ToSalesHeader: Record "Sales Header"; var ToSalesLine: Record "Sales Line"; OldDocType: Option; OldDocNo: Code[20]; var IsHandled: Boolean)
+   local procedure OnBeforeInsertOldSalesDocNoLine(var ToSalesHeader: Record "Sales Header"; var ToSalesLine: Record "Sales Line"; OldDocType: Option; OldDocNo: Code[20]; var NextLineNo: Integer; var IsHandled: Boolean)
    begin
    end;

Internal work item: AB#616636

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM areaevent-requestRequest for adding an eventships-in-future-updateFix ships in a future update

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions