Skip to content

[Event Request] codeunit 1303 "Correct Posted Sales Invoice" - procedure "CreateCreditMemoCopyDocument" #30331

Description

@lapasti

Dear ALAppExtensions Team,

Scenario:
With #29949 (shipped in 28.2), an extension can change what happens to the originating sales order's quantities when a "Create Corrective Cr. Memo" action is called for a posted sales invoice.
When an extension changes what happens to the originating sales order's quantities, the standard confirmation text becomes inaccurate because it states that the original quantities will be reverted.
The existing OnBeforeCreateCreditMemoCopyDocument event has no IsHandled/text parameter, so it cannot be used to adjust this specific Confirm.

We would like to request the following change:

procedure CreateCreditMemoCopyDocument(var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesHeader: Record "Sales Header"): Boolean
    var
        SalesHdr: Record "Sales Header";
        // --> event request
        ConfirmQuestion: Text;
        // <-- event request
    begin
        OnBeforeCreateCreditMemoCopyDocument(SalesInvoiceHeader);
        TestNoFixedAssetInSalesInvoice(SalesInvoiceHeader);
        TestNotSalesPrepaymentlInvoice(SalesInvoiceHeader);
        TestIfDropShipmentDocument(SalesInvoiceHeader);
        if not SalesInvoiceHeader.IsFullyOpen() then begin
            ShowInvoiceAppliedNotification(SalesInvoiceHeader);
            exit(false);
        end;
        SalesHdr.SetRange("Document Type", SalesHdr."Document Type"::Order);
        SalesHdr.SetRange("No.", SalesInvoiceHeader."Order No.");
        if not SalesHdr.IsEmpty then begin
            // --> event request
            ConfirmQuestion := CreateCreditMemoQst;
            OnCreateCreditMemoCopyDocumentOnBeforeConfirm(SalesInvoiceHeader, SalesHeader, ConfirmQuestion);
            // <-- event request
            if not Confirm(ConfirmQuestion) then
                exit(false);
        end;
        CreateCopyDocument(SalesInvoiceHeader, SalesHeader, SalesHeader."Document Type"::"Credit Memo", false);
        if SalesInvoiceLinesContainJob(SalesInvoiceHeader."No.") then
            CreateAndProcessJobPlanningLines(SalesHeader);
        exit(true);
    end;

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions