Why do you need this change?
We need to override the freshly initialized entry counters at the start of a G/L posting cycle with values captured from a prior posting cycle. When a G/L posting cycle follows another posting context that already created G/L entries and VAT entries, the next entry number, next VAT entry number, and next transaction number must continue sequentially rather than starting from freshly queried database values.
The standard StartPosting procedure calls InitNextEntryNo which sets NextEntryNo and NextTransactionNo from the last G/L entry in the database. It then initializes NextVATEntryNo from the last VAT entry. These values are used to set GLReg."From Entry No." and GLReg."From VAT Entry No.". There is no way for a subscriber to override these counter values before they are written into the register record.
The existing OnAfterInitGLRegister event fires after the GLReg record fields are set and passes GLReg as a var parameter. A subscriber can override the register record itself but cannot directly set NextEntryNo, NextVATEntryNo, or NextTransactionNo to values captured from a prior cycle. These counters are needed for subsequent ContinuePosting calls and for the OnBeforeContinuePosting event.
Describe the request
Add var NextEntryNo: Integer, var NextVATEntryNo: Integer, and var NextTransactionNo: Integer to the existing integration event OnAfterInitGLRegister in the StartPosting procedure in Codeunit 12 "Gen. Jnl.-Post Line". The new parameters follow the existing parameters at the end.
GLReg."User ID" := CopyStr(UserId(), 1, MaxStrLen(GLReg."User ID"));
IsGLRegInserted := false;
OnAfterInitGLRegister(GLReg, GenJnlLine, NextEntryNo, NextVATEntryNo, NextTransactionNo); // <---- New parameters at end
GetCurrencyExchRate(GenJnlLine);
TempGLEntryBuf.DeleteAll();
TempGLEntryPreview.DeleteAll();
Event Signature:
[IntegrationEvent(false, false)]
local procedure OnAfterInitGLRegister(var GLRegister: Record "G/L Register"; var GenJournalLine: Record "Gen. Journal Line"; var NextEntryNo: Integer; var NextVATEntryNo: Integer; var NextTransactionNo: Integer)
begin
end;
Alternatives evaluated: OnBeforeStartPosting fires at the very top of StartPosting before InitNextEntryNo runs, so the entry counters have not yet been resolved from the database. OnAfterStartPosting fires at the end of StartPosting after CalculateCurrentBalance has already used the freshly initialized register state. OnBeforeContinuePosting fires at the start of ContinuePosting and passes GLReg, NextEntryNo, and NextTransactionNo as var parameters but fires once per journal line rather than once per posting cycle and does not include NextVATEntryNo. No event currently allows overriding all entry counters together with the register record at the single initialization point.
Internal work item: AB#639006
Why do you need this change?
We need to override the freshly initialized entry counters at the start of a G/L posting cycle with values captured from a prior posting cycle. When a G/L posting cycle follows another posting context that already created G/L entries and VAT entries, the next entry number, next VAT entry number, and next transaction number must continue sequentially rather than starting from freshly queried database values.
The standard
StartPostingprocedure callsInitNextEntryNowhich setsNextEntryNoandNextTransactionNofrom the last G/L entry in the database. It then initializesNextVATEntryNofrom the last VAT entry. These values are used to setGLReg."From Entry No."andGLReg."From VAT Entry No.". There is no way for a subscriber to override these counter values before they are written into the register record.The existing
OnAfterInitGLRegisterevent fires after theGLRegrecord fields are set and passesGLRegas avarparameter. A subscriber can override the register record itself but cannot directly setNextEntryNo,NextVATEntryNo, orNextTransactionNoto values captured from a prior cycle. These counters are needed for subsequentContinuePostingcalls and for theOnBeforeContinuePostingevent.Describe the request
Add
var NextEntryNo: Integer,var NextVATEntryNo: Integer, andvar NextTransactionNo: Integerto the existing integration eventOnAfterInitGLRegisterin theStartPostingprocedure in Codeunit 12 "Gen. Jnl.-Post Line". The new parameters follow the existing parameters at the end.Event Signature:
Alternatives evaluated:
OnBeforeStartPostingfires at the very top ofStartPostingbeforeInitNextEntryNoruns, so the entry counters have not yet been resolved from the database.OnAfterStartPostingfires at the end ofStartPostingafterCalculateCurrentBalancehas already used the freshly initialized register state.OnBeforeContinuePostingfires at the start ofContinuePostingand passesGLReg,NextEntryNo, andNextTransactionNoasvarparameters but fires once per journal line rather than once per posting cycle and does not includeNextVATEntryNo. No event currently allows overriding all entry counters together with the register record at the single initialization point.Internal work item: AB#639006