Announcements
Hi,
The OnAfterPostSalesDoc
event runs after the Sales Header and Lines are transferred to the Posted Sales documents.
You should change it to OnAfterPostSalesLines
.
Additionally, the balancing account details are missing in the General Journal.
Permissions = tabledata "G/L Entry" = rimd;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnAfterPostSalesLines', '', false, false)]
local procedure OnAfterPostSalesLines(var SalesHeader: Record "Sales Header"; var SalesShipmentHeader: Record "Sales Shipment Header"; var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var ReturnReceiptHeader: Record "Return Receipt Header"; WhseShip: Boolean; WhseReceive: Boolean; var SalesLinesProcessed: Boolean; CommitIsSuppressed: Boolean; EverythingInvoiced: Boolean; var TempSalesLineGlobal: Record "Sales Line" temporary)
var
GLAcc: Record "G/L Account";
GenJnlLine: Record "G/L Entry";
CSI_TaxAmount: Decimal;
begin
if TempSalesLineGlobal.FindSet() then
repeat
if TempSalesLineGlobal."CSI Tax" <> 0 then
CSI_TaxAmount := TempSalesLineGlobal."CSI Tax";
if CSI_TaxAmount <> 0 then begin
GenJnlLine.Init();
GenJnlLine."G/L Account No." := '2350';
GenJnlLine."Posting Date" := SalesHeader."Posting Date";
GenJnlLine.Description := 'CSI Tax for Sales Invoice ' + SalesHeader."No.";
GenJnlLine.Amount := CSI_TaxAmount;
GenJnlLine.Insert(true);
CODEUNIT.Run(Codeunit::"Gen. Jnl.-Post Line", GenJnlLine);
end;
until TempSalesLineGlobal.Next() = 0;
end;
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156