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 1004 "Job Transfer Line".FromPlanningSalesLineToJnlLine #27935

Open
fridrichovsky opened this issue Jan 13, 2025 · 0 comments
Labels
event-request Request for adding an event SCM GitHub request for SCM area

Comments

@fridrichovsky
Copy link
Contributor

fridrichovsky commented Jan 13, 2025

Describe the request

Please add new event

procedure FromPlanningSalesLineToJnlLine(JobPlanningLine: Record "Job Planning Line"; SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; var JobJnlLine: Record "Job Journal Line"; EntryType: Enum "Job Journal Line Entry Type")
    var
        SourceCodeSetup: Record "Source Code Setup";
        JobTask: Record "Job Task";
        //-----------------------------------------------------------OnFromPlanningSalesLineToJnlLineOnBeforeInitAmounts:BEGIN
        IsHandled: Boolean;
        //-----------------------------------------------------------OnFromPlanningSalesLineToJnlLineOnBeforeInitAmounts:END
    begin
        OnBeforeFromPlanningSalesLineToJnlLine(JobPlanningLine, SalesHeader, SalesLine, JobJnlLine, EntryType);

        JobJnlLine."Line No." := SalesLine."Line No.";
        JobJnlLine."Job No." := JobPlanningLine."Job No.";
        JobJnlLine."Job Task No." := JobPlanningLine."Job Task No.";
        JobJnlLine.Type := JobPlanningLine.Type;
        JobTask.SetLoadFields("Job No.", "Job Task No.");
        JobTask.Get(JobPlanningLine."Job No.", JobPlanningLine."Job Task No.");
        JobJnlLine."Posting Date" := SalesHeader."Posting Date";
        JobJnlLine."Document Date" := SalesHeader."Document Date";
        JobJnlLine."Document No." := SalesLine."Document No.";
        JobJnlLine."Entry Type" := EntryType;
        JobJnlLine."Posting Group" := SalesLine."Posting Group";
        JobJnlLine."Gen. Bus. Posting Group" := SalesLine."Gen. Bus. Posting Group";
        JobJnlLine."Gen. Prod. Posting Group" := SalesLine."Gen. Prod. Posting Group";
        JobJnlLine.CopyTrackingFromJobPlanningLine(JobPlanningLine);
        JobJnlLine."No." := JobPlanningLine."No.";
        JobJnlLine.Description := SalesLine.Description;
        JobJnlLine."Description 2" := SalesLine."Description 2";
        JobJnlLine."Unit of Measure Code" := JobPlanningLine."Unit of Measure Code";
        JobJnlLine.Validate("Qty. per Unit of Measure", SalesLine."Qty. per Unit of Measure");
        JobJnlLine."Work Type Code" := JobPlanningLine."Work Type Code";
        JobJnlLine."Variant Code" := JobPlanningLine."Variant Code";
        JobJnlLine."Line Type" := JobPlanningLine.ConvertToJobLineType();
        JobJnlLine."Currency Code" := JobPlanningLine."Currency Code";
        JobJnlLine."Currency Factor" := JobPlanningLine."Currency Factor";
        JobJnlLine."Resource Group No." := JobPlanningLine."Resource Group No.";
        JobJnlLine."Customer Price Group" := JobPlanningLine."Customer Price Group";
        JobJnlLine."Location Code" := SalesLine."Location Code";
        JobJnlLine."Bin Code" := SalesLine."Bin Code";
        SourceCodeSetup.Get();
        JobJnlLine."Source Code" := SourceCodeSetup.Sales;
        JobJnlLine."Reason Code" := SalesHeader."Reason Code";
        JobJnlLine."External Document No." := SalesHeader."External Document No.";

        JobJnlLine."Transport Method" := SalesLine."Transport Method";
        JobJnlLine."Transaction Type" := SalesLine."Transaction Type";
        JobJnlLine."Transaction Specification" := SalesLine."Transaction Specification";
        JobJnlLine."Entry/Exit Point" := SalesLine."Exit Point";
        JobJnlLine.Area := SalesLine.Area;
        JobJnlLine."Country/Region Code" := JobPlanningLine."Country/Region Code";

        JobJnlLine."Shortcut Dimension 1 Code" := SalesLine."Shortcut Dimension 1 Code";
        JobJnlLine."Shortcut Dimension 2 Code" := SalesLine."Shortcut Dimension 2 Code";
        JobJnlLine."Dimension Set ID" := SalesLine."Dimension Set ID";

        case SalesHeader."Document Type" of
            SalesHeader."Document Type"::Invoice:
                JobJnlLine.Validate(Quantity, SalesLine.Quantity);
            SalesHeader."Document Type"::"Credit Memo":
                JobJnlLine.Validate(Quantity, -SalesLine.Quantity);
        end;
        //-----------------------------------------------------------OnFromPlanningSalesLineToJnlLineOnBeforeInitAmounts:BEGIN
        //OnFromPlanningSalesLineToJnlLineOnBeforeInitAmounts(JobJnlLine, SalesLine, SalesHeader);
        IsHandled := false;
        OnFromPlanningSalesLineToJnlLineOnBeforeInitAmounts(JobJnlLine, SalesLine, SalesHeader, JobPlanningLine, IsHandled);
        if not IsHandled then begin
        //-----------------------------------------------------------OnFromPlanningSalesLineToJnlLineOnBeforeInitAmounts:END
            JobJnlLine."Direct Unit Cost (LCY)" := JobPlanningLine."Direct Unit Cost (LCY)";
            if (JobPlanningLine."Currency Code" = '') and (SalesHeader."Currency Factor" <> 0) then begin
                GetCurrencyRounding(SalesHeader."Currency Code");
                ValidateUnitCostAndPrice(
                  JobJnlLine, SalesLine, SalesLine."Unit Cost (LCY)",
                  JobPlanningLine."Unit Price");
            end else
                ValidateUnitCostAndPrice(JobJnlLine, SalesLine, SalesLine."Unit Cost", JobPlanningLine."Unit Price");
            JobJnlLine.Validate("Line Discount %", SalesLine."Line Discount %");
        //-----------------------------------------------------------OnFromPlanningSalesLineToJnlLineOnBeforeInitAmounts:BEGIN
        end;
        //-----------------------------------------------------------OnFromPlanningSalesLineToJnlLineOnBeforeInitAmounts:END

        OnAfterFromPlanningSalesLineToJnlLine(JobJnlLine, JobPlanningLine, SalesHeader, SalesLine, EntryType);
    end;

    //-----------------------------------------------------------OnFromPlanningSalesLineToJnlLineOnBeforeInitAmounts:BEGIN
    //[IntegrationEvent(false, false)]
    [IntegrationEvent(true, false)]
    //local procedure OnFromPlanningSalesLineToJnlLineOnBeforeInitAmounts(var JobJournalLine: Record "Job Journal Line"; var SalesLine: Record "Sales Line"; var SalesHeader: Record "Sales Header")
    local procedure OnFromPlanningSalesLineToJnlLineOnBeforeInitAmounts(var JobJournalLine: Record "Job Journal Line"; var SalesLine: Record "Sales Line"; var SalesHeader: Record "Sales Header"; var JobPlanningLine: Record "Job Planning Line"; var IsHandled: Boolean)
    begin
    end;
    //-----------------------------------------------------------OnFromPlanningSalesLineToJnlLineOnBeforeInitAmounts:END

Additional context

we need option how to init values different way then standard.
Internal work item: AB#562607

@JesperSchulz JesperSchulz added event-request Request for adding an event SCM GitHub request for SCM area labels Jan 16, 2025
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