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 1303 "Correct Posted Sales Invoice" #26681

Closed
NilsKagel opened this issue Jun 17, 2024 · 1 comment
Closed

[Event Request] Codeunit 1303 "Correct Posted Sales Invoice" #26681

NilsKagel opened this issue Jun 17, 2024 · 1 comment
Labels
event-request Request for adding an event SCM GitHub request for SCM area ships-in-future-update Fix ships in a future update

Comments

@NilsKagel
Copy link

NilsKagel commented Jun 17, 2024

Describe the request

Could you please add the following event to Codeunit 1303 "Correct Posted Sales Invoice" at Function "UpdateSalesOrderLinesFromCancelledInvoice":

        IsHandled := false;
        OnBeforeUpdateSalesOrderLineIfExist(Rec, IsHandled);
        if IsHandled then
            exit;

Example (new code with >>><<<):

local procedure UpdateSalesOrderLinesFromCancelledInvoice(SalesInvoiceHeaderNo: Code[20])
var
	TempItemLedgerEntry: Record "Item Ledger Entry" temporary;
	SalesLine: Record "Sales Line";
	SalesInvoiceLine: Record "Sales Invoice Line";
	UndoPostingManagement: Codeunit "Undo Posting Management";
begin
>>>	
	IsHandled := false;
	OnBeforeUpdateSalesOrderLinesFromCancelledInvoice(SalesInvoiceHeaderNo, IsHandled);
	if IsHandled then
                exit;
<<<
	SalesInvoiceLine.SetRange("Document No.", SalesInvoiceHeaderNo);
	if SalesInvoiceLine.FindSet() then
		repeat
			TempItemLedgerEntry.Reset();
			TempItemLedgerEntry.DeleteAll();
			SalesInvoiceLine.GetItemLedgEntries(TempItemLedgerEntry, false);
			if SalesLine.Get(SalesLine."Document Type"::Order, SalesInvoiceLine."Order No.", SalesInvoiceLine."Order Line No.") then begin
				UpdateSalesOrderLineInvoicedQuantity(SalesLine, SalesInvoiceLine.Quantity, SalesInvoiceLine."Quantity (Base)");
				UpdateSalesOrderLinePrepmtAmount(SalesInvoiceLine);
				if SalesLine."Qty. to Ship" = 0 then
					UpdateWhseRequest(Database::"Sales Line", SalesLine."Document Type".AsInteger(), SalesLine."Document No.", SalesLine."Location Code");
				TempItemLedgerEntry.SetFilter("Item Tracking", '<>%1', TempItemLedgerEntry."Item Tracking"::None.AsInteger());
				UndoPostingManagement.RevertPostedItemTracking(TempItemLedgerEntry, SalesInvoiceLine."Shipment Date", true);
			end;
		until SalesInvoiceLine.Next() = 0;
end;

Additional context

We need this event to create a save way to integrate our own function to correct invoices.
Internal work item: AB#538570

@JesperSchulz JesperSchulz added event-request Request for adding an event SCM GitHub request for SCM area ships-in-future-update Fix ships in a future update labels Jun 17, 2024
@JesperSchulz
Copy link
Contributor

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: 21022.

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 ships-in-future-update Fix ships in a future update
Projects
None yet
Development

No branches or pull requests

2 participants