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 99000773 "Calculate Prod. Order" - Procedure InitProdOrderRoutingLine - OnAfterCopyFromRoutingLine #28026

Open
mavohra opened this issue Jan 30, 2025 · 0 comments

Comments

@mavohra
Copy link

mavohra commented Jan 30, 2025

Describe the request

Please add an event OnAfterCopyFromRoutingLine in the procedure InitProdOrderRoutingLine in Codeunit 99000773 "Calculate Prod. Order"

 procedure InitProdOrderRoutingLine(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; RoutingLine: Record "Routing Line")
    var
        WorkCenter: Record "Work Center";
        MachineCenter: Record "Machine Center";
    begin
        ProdOrderRoutingLine.Init();
        ProdOrderRoutingLine.Status := ProdOrderLine.Status;
        ProdOrderRoutingLine."Prod. Order No." := ProdOrderLine."Prod. Order No.";
        ProdOrderRoutingLine."Routing Reference No." := ProdOrderLine."Routing Reference No.";
        ProdOrderRoutingLine."Routing No." := ProdOrderLine."Routing No.";
        ProdOrderRoutingLine.CopyFromRoutingLine(RoutingLine);

        OnAfterCopyFromRoutingLine(ProdOrderRoutingLine, RoutingLine); // <--- New Event

        case ProdOrderRoutingLine.Type of
            ProdOrderRoutingLine.Type::"Work Center":
                begin
                    WorkCenter.Get(RoutingLine."Work Center No.");
                    ProdOrderRoutingLine."Flushing Method" := WorkCenter."Flushing Method";
                end;
            ProdOrderRoutingLine.Type::"Machine Center":
                begin
                    MachineCenter.Get(ProdOrderRoutingLine."No.");
                    ProdOrderRoutingLine."Flushing Method" := MachineCenter."Flushing Method";
                end;
        end;

        OnTransferRoutingOnBeforeCalcRoutingCostPerUnit(ProdOrderRoutingLine, ProdOrderLine, RoutingLine);
        CostCalcMgt.CalcRoutingCostPerUnit(
            ProdOrderRoutingLine.Type, ProdOrderRoutingLine."No.",
            ProdOrderRoutingLine."Direct Unit Cost", ProdOrderRoutingLine."Indirect Cost %", ProdOrderRoutingLine."Overhead Rate",
            ProdOrderRoutingLine."Unit Cost per", ProdOrderRoutingLine."Unit Cost Calculation");

        OnTransferRoutingOnbeforeValidateDirectUnitCost(ProdOrderRoutingLine, ProdOrderLine, RoutingLine);

        ProdOrderRoutingLine.Validate("Direct Unit Cost");
        ProdOrderRoutingLine."Starting Time" := ProdOrderLine."Starting Time";
        ProdOrderRoutingLine."Starting Date" := ProdOrderLine."Starting Date";
        ProdOrderRoutingLine."Ending Time" := ProdOrderLine."Ending Time";
        ProdOrderRoutingLine."Ending Date" := ProdOrderLine."Ending Date";
        ProdOrderRoutingLine.UpdateDatetime();
        OnAfterTransferRoutingLine(ProdOrderLine, RoutingLine, ProdOrderRoutingLine);
        ProdOrderRoutingLine.Insert();
        OnAfterInsertProdRoutingLine(ProdOrderRoutingLine, ProdOrderLine);
    end;
[IntegrationEvent(false, false)]
    local procedure OnAfterCopyFromRoutingLine(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; RoutingLine: Record "Routing Line")
    begin
    end;

Additional context

We need to add our custom logic related to initializing Unit Costs and our custom fields after ProdOrderRoutingLine.CopyFromRoutingLine(RoutingLine); is called and before the case statement to check the ProdOrderRoutingLine.Type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant