I wrote the proc below but it's not working.
codeunit 50109 WSBCareAPICASITaxRotuine
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnAfterPostSalesDoc', '', false, false)]
local procedure OnAfterSalesInvoicePost(SalesHeader: Record "Sales Header")
var
GLAcc: Record "G/L Account";
GenJnlLine: Record "G/L Entry";
SalesLine: Record "Sales Line";
CSI_TaxAmount: Decimal;
begin
SalesLine.SetRange("Document Type", SalesLine."Document Type"::Invoice);
SalesLine.SetRange("Document No.", SalesHeader."No.");
if SalesLine.FindSet() then
repeat
if SalesLine."CSI Tax" <> 0 then
CSI_TaxAmount := SalesLine."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 SalesLine.Next() = 0;
end;
}