microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
773 stars 610 forks source link

[Event Change Request] codeunit 1002 "Job Create-Invoice" - OnCreateSalesInvoiceJobTaskOnAfterLinesCreated #26741

Closed pri-kise closed 3 months ago

pri-kise commented 3 months ago

Describe the request

Could you please add the two parameters InvoicePerTask: Boolean; LastJobTask: Boolean to the event OnCreateSalesInvoiceJobTaskOnAfterLinesCreated?

procedure CreateSalesInvoiceJobTask(var JobTask2: Record "Job Task"; PostingDate: Date; DocumentDate: Date; InvoicePerTask: Boolean; var NoOfInvoices: Integer; var OldJobNo: Code[20]; var OldJobTaskNo: Code[20]; LastJobTask: Boolean)
var
    Cust: Record Customer;
    Job: Record Job;
    JobTask: Record "Job Task";
    JobPlanningLine: Record "Job Planning Line";
    JobPlanningLineInvoice: Record "Job Planning Line Invoice";
    IsHandled: Boolean;
begin
    ...

    //+Change
    //-OnCreateSalesInvoiceJobTaskOnAfterLinesCreated(SalesHeader, Job);
    OnCreateSalesInvoiceJobTaskOnAfterLinesCreated(SalesHeader, Job, InvoicePerTask, LastJobTask);
    //-Change

    if LastJobTask then begin
        if NoOfSalesLinesCreated = 0 then
            Error(Text002, JobPlanningLine.TableCaption(), JobPlanningLine.FieldCaption("Qty. to Transfer to Invoice"));
        exit;
    end;

    JobPlanningLine.Reset();
    JobPlanningLine.SetCurrentKey("Job No.", "Job Task No.");
    JobPlanningLine.SetRange("Job No.", JobTask2."Job No.");
    JobPlanningLine.SetRange("Job Task No.", JobTask2."Job Task No.");
    JobPlanningLine.SetFilter("Planning Date", JobTask2.GetFilter("Planning Date Filter"));
    OnCreateSalesInvoiceJobTaskOnAfterJobPlanningLineSetFilters(JobPlanningLine, JobTask2);
    if JobPlanningLine.Find('-') then
        repeat
            if TransferLine(JobPlanningLine) then begin
                TempJobPlanningLine := JobPlanningLine;
                TempJobPlanningLine.Insert();

                if Job."Task Billing Method" = Job."Task Billing Method"::"Multiple customers" then begin
                    TempJobPlanningLine2 := JobPlanningLine;
                    TempJobPlanningLine2.Insert();
                end;
            end;
        until JobPlanningLine.Next() = 0;
end;
[IntegrationEvent(false, false)]
//+Change
//-local procedure OnCreateSalesInvoiceJobTaskOnAfterLinesCreated(var SalesHeader: Record "Sales Header"; var Job: Record Job)
local procedure OnCreateSalesInvoiceJobTaskOnAfterLinesCreated(var SalesHeader: Record "Sales Header"; var Job: Record Job; InvoicePerTask: Boolean; LastJobTask: Boolean)
//-Change
begin
end;

Additional context

The process is very different depending on those two boolean values and therefore we need to know the value. Internal work item: AB#539585

JesperSchulz commented 3 months ago

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

Build ID: 21464.