Add new Event in codeunit 12 "Gen. Jnl.-Post Line"
Why do you need this change?
Dear Microsoft team,
We have a client for whom we are upgrading from BC14 to the latest version. In Codeunit 12, my client has customized the program logic based on the NextVATEntryNo variable. This variable is used throughout the codeunit in various places, and in all of them we are able to subscribe and apply the client's previous logic. However, in this specific function, at the point IΓÇÖm highlighting, we are not able to modify this variable, and our client requires it. We would kindly ask if you could add the event, as indicated below._
Thank you very much in advance.
Describe the request
I am requesting a new event in Codeunit 12 'Gen. Jnl.-Post Line', in the PostUnapply procedure, at the point where IΓÇÖve added the comment: //New Event, Insert here.
local procedure PostUnapply(GenJnlLine: Record "Gen. Journal Line"; var VATEntry: Record "VAT Entry"; VATEntryType: Enum "General Posting Type"; BilltoPaytoNo: Code[20]; TransactionNo: Integer; UnapplyVATEntries: Boolean; var TempVATEntry: Record "VAT Entry" temporary)
var
VATPostingSetup: Record "VAT Posting Setup";
VATEntry2: Record "VAT Entry";
AccNo: Code[20];
TempVATEntryNo: Integer;
GLEntryNoFromVAT: Integer;
IsHandled: Boolean;
begin
IsHandled := false;
OnBeforePostUnapply(GenJnlLine, VATEntry, VATEntryType, BilltoPaytoNo, TransactionNo, UnapplyVATEntries, TempVATEntry, IsHandled, NextVATEntryNo);
if IsHandled then
exit;
TempVATEntryNo := 1;
VATEntry.SetCurrentKey(Type, "Bill-to/Pay-to No.", "Transaction No.");
VATEntry.SetRange(Type, VATEntryType);
VATEntry.SetRange("Bill-to/Pay-to No.", BilltoPaytoNo);
VATEntry.SetRange("Transaction No.", TransactionNo);
OnPostUnapplyOnAfterVATEntrySetFilters(VATEntry, GenJnlLine);
if VATEntry.FindSet() then
repeat
VATPostingSetup.Get(VATEntry."VAT Bus. Posting Group", VATEntry."VAT Prod. Posting Group");
OnPostUnapplyOnBeforeUnapplyVATEntry(VATEntry, UnapplyVATEntries);
if UnapplyVATEntries or (VATEntry."Unrealized VAT Entry No." <> 0) then begin
InsertTempVATEntry(GenJnlLine, VATEntry, TempVATEntryNo, TempVATEntry);
if VATEntry."Unrealized VAT Entry No." <> 0 then begin
VATPostingSetup.Get(VATEntry."VAT Bus. Posting Group", VATEntry."VAT Prod. Posting Group");
if VATPostingSetup."VAT Calculation Type" in
[VATPostingSetup."VAT Calculation Type"::"Normal VAT",
VATPostingSetup."VAT Calculation Type"::"Full VAT"]
then
GLEntryNoFromVAT := PostUnrealVATByUnapply(GenJnlLine, VATPostingSetup, VATEntry, TempVATEntry)
else
if VATPostingSetup."VAT Calculation Type" = VATPostingSetup."VAT Calculation Type"::"Reverse Charge VAT" then begin
GLEntryNoFromVAT := PostUnrealVATByUnapply(GenJnlLine, VATPostingSetup, VATEntry, TempVATEntry);
CreateGLEntry(
GenJnlLine, VATPostingSetup.GetRevChargeAccount(true),
-VATEntry.Amount, CalcAddCurrForUnapplication(VATEntry."Posting Date", -VATEntry.Amount), false);
CreateGLEntry(
GenJnlLine, VATPostingSetup.GetRevChargeAccount(false),
VATEntry.Amount, CalcAddCurrForUnapplication(VATEntry."Posting Date", VATEntry.Amount), false);
end else
GLEntryNoFromVAT := PostUnrealVATByUnapply(GenJnlLine, VATPostingSetup, VATEntry, TempVATEntry);
VATEntry2 := TempVATEntry;
VATEntry2."Entry No." := NextVATEntryNo;
OnPostUnapplyOnBeforeVATEntryInsert(VATEntry2, GenJnlLine, VATEntry);
VATEntry2.Insert();
OnPostUnapplyOnAfterVATEntryInsert(VATEntry2, GenJnlLine, VATEntry);
if GLEntryNoFromVAT <> 0 then
TempGLEntryVATEntryLink.InsertLinkSelf(GLEntryNoFromVAT, VATEntry2."Entry No.");
GLEntryNoFromVAT := 0;
TempVATEntry.Delete();
//New Event, Insert here
IsHandled := false;
OnBeforeIncrNextVATEntryNoPostUnapply(NextVATEntryNo,GenJnlLine,IsHandled);
if not IsHandle then
//
IncrNextVATEntryNo();
end;
if VATPostingSetup."Adjust for Payment Discount" and not IsNotPayment(VATEntry."Document Type") and
(VATPostingSetup."VAT Calculation Type" =
VATPostingSetup."VAT Calculation Type"::"Reverse Charge VAT") and
(VATEntry."Unrealized VAT Entry No." = 0) and UnapplyVATEntries and (VATEntry.Amount <> 0)
then begin
case VATEntryType of
VATEntry.Type::Sale:
AccNo := VATPostingSetup.GetSalesAccount(false);
VATEntry.Type::Purchase:
AccNo := VATPostingSetup.GetPurchAccount(false);
end;
PostPmtDiscountVATByUnapply(GenJnlLine, VATPostingSetup.GetRevChargeAccount(false), AccNo, VATEntry);
end;
end;
until VATEntry.Next() = 0;
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeIncrNextVATEntryNoPostUnapply(var NextVATEntryNo: integer; GenJnlLine: Record "Gen. Journal Line";var IsHandled : Boolean)
begin
end;
Internal work item: AB#579164
@Abalsells-Summar there is already an IsHandled event for the procedure IncrNextVATEntryNo. Please see if you can use that
Please read the comment above
Availability update: We will publish a fix for this issue in the next update for release 26.
Build ID to track: