Skip to content

[Event Request] codeunit 1322 "Correct PstdSalesInv (Yes/No)" - procedure "CancelPostedInvoiceAndOpenSalesOrder" #30329

Description

@lapasti

Dear ALAppExtensions Team,

Scenario:
Following #29949 (shipped in 28.2), an extension can now change what happens to the originating sales order's quantities when a posted sales invoice is corrected/cancelled (from page actions).
When that behavior is changed, the standard confirmation text shown to the user before the action becomes inaccurate because it states that the original quantities will be reverted.
We need a way to override the confirmation question text without duplicating this procedure's logic.

Here's the callstack:
UpdateSalesOrderLinesFromCancelledInvoice (\App\Codeunit\1303\Correct Posted Sales Invoice.dal:1120)
OnRun (\App\Codeunit\1303\Correct Posted Sales Invoice.dal:65)
CreateCreditMemo (\App\Codeunit\1303\Correct Posted Sales Invoice.dal:153)
CancelPostedInvoice (\App\Codeunit\1303\Correct Posted Sales Invoice.dal:142)
CancelPostedInvoice (\App\Codeunit\1322\Correct PstdSalesInv (YesΓüäNo).dal:106)
CorrectInvoice (\App\Codeunit\1322\Correct PstdSalesInv (YesΓüäNo).dal:53)
OnRun (\App\Codeunit\1322\Correct PstdSalesInv (YesΓüäNo).dal:21)
CorrectInvoice - OnAction (\App\Page\143\Posted Sales Invoices.dal:551)

We would like to request the following change:

local procedure CancelPostedInvoiceAndOpenSalesOrder(var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesHeader: Record "Sales Header"): Boolean
    var
        ConfirmManagement: Codeunit "Confirm Management";
        CorrectPostedSalesInvoice: Codeunit "Correct Posted Sales Invoice";
        IsHandled: Boolean;
        // --> event request
        ConfirmQuestion: Text;
        // <-- event request
    begin
        // --> event request
        ConfirmQuestion := CorrectPostedInvoiceFromSingleOrderQst;
        OnCancelPostedInvoiceAndOpenSalesOrderOnBeforeConfirm(SalesInvoiceHeader, SalesHeader, ConfirmQuestion);
        // <-- event request
        if ConfirmManagement.GetResponse(ConfirmQuestion, false) then begin
            if not CorrectPostedSalesInvoice.CancelPostedInvoice(SalesInvoiceHeader) then
                exit(false);
            SalesHeader.Find();
            OnCorrectInvoiceOnBeforeOpenSalesOrderPage(SalesHeader, IsHandled);
            if not IsHandled then
                PAGE.Run(PAGE::"Sales Order", SalesHeader);
            exit(true);
        end;
        exit(false);
    end;

    // --> event request
    [IntegrationEvent(false, false)]
    local procedure OnCancelPostedInvoiceAndOpenSalesOrderOnBeforeConfirm(var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesHeader: Record "Sales Header"; var ConfirmQuestion: Text)
    begin
    end;
    // <-- event request

Internal work item: AB#641734

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM areaevent-requestRequest for adding an event

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions