Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ codeunit 12 "Gen. Jnl.-Post Line"
SequenceNoMgt.ClearSequenceNoCheck();

GenJnlLine.Copy(GenJnlLine2);
Code(GenJnlLine, true);
Post(GenJnlLine, true);
OnAfterRunWithCheck(GenJnlLine);
GenJnlLine2 := GenJnlLine;
exit(GLEntryNo);
Expand All @@ -259,13 +259,51 @@ codeunit 12 "Gen. Jnl.-Post Line"
exit(GLEntryNo);

GenJnlLine.Copy(GenJnlLine2);
Code(GenJnlLine, false);
Post(GenJnlLine, false);
OnAfterRunWithoutCheck(GenJnlLine);
GenJnlLine2 := GenJnlLine;
exit(GLEntryNo);
end;

local procedure "Code"(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
/// <summary>
/// A wrapper procedure to delegate to either a procedure that allows commit or a procedure that ignores commit.
/// By default, commits are suppressed during the critical posting window to prevent duplicate-key races
/// on G/L Entry (table 17). Subscribers can opt out by setting IgnoreCommit to false via OnSetCommitBehavior.
/// </summary>
/// <param name="GenJnlLine">The general journal line that is being posted.</param>
/// <param name="CheckLine">Indicates whether to check the lines before posting.</param>
local procedure Post(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
var
IgnoreCommit: Boolean;
begin
IgnoreCommit := true;
OnSetCommitBehavior(IgnoreCommit);

if IgnoreCommit then
PostLineCommitBehaviorIgnore(GenJnlLine, CheckLine)
else
PostLine(GenJnlLine, CheckLine);
end;

/// <summary>
/// A wrapper procedure to delegate to PostLines in order to ignore commits.
/// While this procedure is on the call stack, the platform turns every Commit() into a no-op,
/// preventing intermittent duplicate-key errors on G/L Entry (table 17).
/// </summary>
/// <param name="GenJnlLine">The general journal line that is being posted.</param>
/// <param name="CheckLine">Indicates whether to check the line before posting.</param>
[CommitBehavior(CommitBehavior::Ignore)]
local procedure PostLineCommitBehaviorIgnore(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
begin
PostLine(GenJnlLine, CheckLine);
end;

/// <summary>
/// Posting procedure for general journal lines
/// </summary>
/// <param name="GenJnlLine">The general journal line that is being posted.</param>
/// <param name="CheckLine">Indicates whether to check the line before posting.</param>
local procedure PostLine(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
var
xGLEntryNo: Integer;
Balancing: Boolean;
Expand Down Expand Up @@ -13545,4 +13583,9 @@ codeunit 12 "Gen. Jnl.-Post Line"
local procedure OnPostUnapplyOnBeforeInsertTempVATEntry(var VATEntry: Record "VAT Entry"; var UnapplyVATEntries: Boolean)
begin
end;

[IntegrationEvent(false, false)]
local procedure OnSetCommitBehavior(var IgnoreCommit: Boolean)
begin
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ codeunit 12 "Gen. Jnl.-Post Line"
SequenceNoMgt.ClearSequenceNoCheck();

GenJnlLine.Copy(GenJnlLine2);
Code(GenJnlLine, true);
Post(GenJnlLine, true);
OnAfterRunWithCheck(GenJnlLine);
GenJnlLine2 := GenJnlLine;
exit(GLEntryNo);
Expand All @@ -241,13 +241,51 @@ codeunit 12 "Gen. Jnl.-Post Line"
exit(GLEntryNo);

GenJnlLine.Copy(GenJnlLine2);
Code(GenJnlLine, false);
Post(GenJnlLine, false);
OnAfterRunWithoutCheck(GenJnlLine);
GenJnlLine2 := GenJnlLine;
exit(GLEntryNo);
end;

local procedure "Code"(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
/// <summary>
/// A wrapper procedure to delegate to either a procedure that allows commit or a procedure that ignores commit.
/// By default, commits are suppressed during the critical posting window to prevent duplicate-key races
/// on G/L Entry (table 17). Subscribers can opt out by setting IgnoreCommit to false via OnSetCommitBehavior.
/// </summary>
/// <param name="GenJnlLine">The general journal line that is being posted.</param>
/// <param name="CheckLine">Indicates whether to check the lines before posting.</param>
local procedure Post(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
var
IgnoreCommit: Boolean;
begin
IgnoreCommit := true;
OnSetCommitBehavior(IgnoreCommit);

if IgnoreCommit then
PostLineCommitBehaviorIgnore(GenJnlLine, CheckLine)
else
PostLine(GenJnlLine, CheckLine);
end;

/// <summary>
/// A wrapper procedure to delegate to PostLines in order to ignore commits.
/// While this procedure is on the call stack, the platform turns every Commit() into a no-op,
/// preventing intermittent duplicate-key errors on G/L Entry (table 17).
/// </summary>
/// <param name="GenJnlLine">The general journal line that is being posted.</param>
/// <param name="CheckLine">Indicates whether to check the line before posting.</param>
[CommitBehavior(CommitBehavior::Ignore)]
local procedure PostLineCommitBehaviorIgnore(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
begin
PostLine(GenJnlLine, CheckLine);
end;

/// <summary>
/// Posting procedure for general journal lines
/// </summary>
/// <param name="GenJnlLine">The general journal line that is being posted.</param>
/// <param name="CheckLine">Indicates whether to check the line before posting.</param>
local procedure PostLine(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
var
xGLEntryNo: Integer;
Balancing: Boolean;
Expand Down Expand Up @@ -11146,4 +11184,9 @@ codeunit 12 "Gen. Jnl.-Post Line"
local procedure OnPostUnapplyOnBeforeInsertTempVATEntry(var VATEntry: Record "VAT Entry"; var UnapplyVATEntries: Boolean)
begin
end;

[IntegrationEvent(false, false)]
local procedure OnSetCommitBehavior(var IgnoreCommit: Boolean)
begin
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ codeunit 12 "Gen. Jnl.-Post Line"
SequenceNoMgt.ClearSequenceNoCheck();

GenJnlLine.Copy(GenJnlLine2);
Code(GenJnlLine, true);
Post(GenJnlLine, true);
OnAfterRunWithCheck(GenJnlLine);
GenJnlLine2 := GenJnlLine;
exit(GLEntryNo);
Expand All @@ -242,13 +242,51 @@ codeunit 12 "Gen. Jnl.-Post Line"
exit(GLEntryNo);

GenJnlLine.Copy(GenJnlLine2);
Code(GenJnlLine, false);
Post(GenJnlLine, false);
OnAfterRunWithoutCheck(GenJnlLine);
GenJnlLine2 := GenJnlLine;
exit(GLEntryNo);
end;

local procedure "Code"(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
/// <summary>
/// A wrapper procedure to delegate to either a procedure that allows commit or a procedure that ignores commit.
/// By default, commits are suppressed during the critical posting window to prevent duplicate-key races
/// on G/L Entry (table 17). Subscribers can opt out by setting IgnoreCommit to false via OnSetCommitBehavior.
/// </summary>
/// <param name="GenJnlLine">The general journal line that is being posted.</param>
/// <param name="CheckLine">Indicates whether to check the lines before posting.</param>
local procedure Post(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
var
IgnoreCommit: Boolean;
begin
IgnoreCommit := true;
OnSetCommitBehavior(IgnoreCommit);

if IgnoreCommit then
PostLineCommitBehaviorIgnore(GenJnlLine, CheckLine)
else
PostLine(GenJnlLine, CheckLine);
end;

/// <summary>
/// A wrapper procedure to delegate to PostLines in order to ignore commits.
/// While this procedure is on the call stack, the platform turns every Commit() into a no-op,
/// preventing intermittent duplicate-key errors on G/L Entry (table 17).
/// </summary>
/// <param name="GenJnlLine">The general journal line that is being posted.</param>
/// <param name="CheckLine">Indicates whether to check the line before posting.</param>
[CommitBehavior(CommitBehavior::Ignore)]
local procedure PostLineCommitBehaviorIgnore(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
begin
PostLine(GenJnlLine, CheckLine);
end;

/// <summary>
/// Posting procedure for general journal lines
/// </summary>
/// <param name="GenJnlLine">The general journal line that is being posted.</param>
/// <param name="CheckLine">Indicates whether to check the line before posting.</param>
local procedure PostLine(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
var
xGLEntryNo: Integer;
Balancing: Boolean;
Expand Down Expand Up @@ -11168,4 +11206,9 @@ codeunit 12 "Gen. Jnl.-Post Line"
local procedure OnPostUnapplyOnBeforeInsertTempVATEntry(var VATEntry: Record "VAT Entry"; var UnapplyVATEntries: Boolean)
begin
end;

[IntegrationEvent(false, false)]
local procedure OnSetCommitBehavior(var IgnoreCommit: Boolean)
begin
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ codeunit 12 "Gen. Jnl.-Post Line"
exit(GLEntryNo);

GenJnlLine.Copy(GenJnlLine2);
Code(GenJnlLine, true);
Post(GenJnlLine, true);
OnAfterRunWithCheck(GenJnlLine);
GenJnlLine2 := GenJnlLine;
exit(GLEntryNo);
Expand All @@ -281,13 +281,51 @@ codeunit 12 "Gen. Jnl.-Post Line"
exit(GLEntryNo);

GenJnlLine.Copy(GenJnlLine2);
Code(GenJnlLine, false);
Post(GenJnlLine, false);
OnAfterRunWithoutCheck(GenJnlLine);
GenJnlLine2 := GenJnlLine;
exit(GLEntryNo);
end;

local procedure "Code"(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
/// <summary>
/// A wrapper procedure to delegate to either a procedure that allows commit or a procedure that ignores commit.
/// By default, commits are suppressed during the critical posting window to prevent duplicate-key races
/// on G/L Entry (table 17). Subscribers can opt out by setting IgnoreCommit to false via OnSetCommitBehavior.
/// </summary>
/// <param name="GenJnlLine">The general journal line that is being posted.</param>
/// <param name="CheckLine">Indicates whether to check the lines before posting.</param>
local procedure Post(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
var
IgnoreCommit: Boolean;
begin
IgnoreCommit := true;
OnSetCommitBehavior(IgnoreCommit);

if IgnoreCommit then
PostLineCommitBehaviorIgnore(GenJnlLine, CheckLine)
else
PostLine(GenJnlLine, CheckLine);
end;

/// <summary>
/// A wrapper procedure to delegate to PostLines in order to ignore commits.
/// While this procedure is on the call stack, the platform turns every Commit() into a no-op,
/// preventing intermittent duplicate-key errors on G/L Entry (table 17).
/// </summary>
/// <param name="GenJnlLine">The general journal line that is being posted.</param>
/// <param name="CheckLine">Indicates whether to check the line before posting.</param>
[CommitBehavior(CommitBehavior::Ignore)]
local procedure PostLineCommitBehaviorIgnore(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
begin
PostLine(GenJnlLine, CheckLine);
end;

/// <summary>
/// Posting procedure for general journal lines
/// </summary>
/// <param name="GenJnlLine">The general journal line that is being posted.</param>
/// <param name="CheckLine">Indicates whether to check the line before posting.</param>
local procedure PostLine(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
var
Balancing: Boolean;
IsTransactionConsistent: Boolean;
Expand Down Expand Up @@ -12859,4 +12897,9 @@ codeunit 12 "Gen. Jnl.-Post Line"
local procedure OnPostUnapplyOnBeforeInsertTempVATEntry(var VATEntry: Record "VAT Entry"; var UnapplyVATEntries: Boolean)
begin
end;

[IntegrationEvent(false, false)]
local procedure OnSetCommitBehavior(var IgnoreCommit: Boolean)
begin
end;
}
Loading
Loading