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
11 changes: 9 additions & 2 deletions src/Layers/APAC/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -1363,8 +1363,12 @@ table 254 "VAT Entry"
VATEntryLocal.Copy(Rec);
VATEntryLocal.SetRange("G/L Acc. No.", '');
if WithUI then begin
if ShowConfirm then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
if GuiAllowed() then begin
if ShowConfirm and not Response then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
end else
// Background execution has no user to confirm with; proceed so the report can run unattended.
Response := true;
if not Response then
exit;

Expand Down Expand Up @@ -1514,6 +1518,9 @@ table 254 "VAT Entry"
VATEntryUpdate.SetRange("G/L Acc. No.", '');
VATEntryUpdate.SetFilter("Entry No.", EntryNoFilter.ToText());
VATEntryUpdate.ModifyAll("G/L Acc. No.", GLAccountNo, false);
// Persist each batch so a long-running adjustment that times out can resume from where it
// left off instead of restarting from scratch and never completing.
Commit();
EntryNoFilter.Clear();
TotalChunkDuration += CurrentDateTime() - StartTime;
ChunkCount += 1;
Expand Down
11 changes: 9 additions & 2 deletions src/Layers/BE/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -1170,8 +1170,12 @@ table 254 "VAT Entry"
VATEntryLocal.Copy(Rec);
VATEntryLocal.SetRange("G/L Acc. No.", '');
if WithUI then begin
if ShowConfirm then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
if GuiAllowed() then begin
if ShowConfirm and not Response then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
end else
// Background execution has no user to confirm with; proceed so the report can run unattended.
Response := true;
if not Response then
exit;

Expand Down Expand Up @@ -1321,6 +1325,9 @@ table 254 "VAT Entry"
VATEntryUpdate.SetRange("G/L Acc. No.", '');
VATEntryUpdate.SetFilter("Entry No.", EntryNoFilter.ToText());
VATEntryUpdate.ModifyAll("G/L Acc. No.", GLAccountNo, false);
// Persist each batch so a long-running adjustment that times out can resume from where it
// left off instead of restarting from scratch and never completing.
Commit();
EntryNoFilter.Clear();
TotalChunkDuration += CurrentDateTime() - StartTime;
ChunkCount += 1;
Expand Down
11 changes: 9 additions & 2 deletions src/Layers/CH/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -1193,8 +1193,12 @@ table 254 "VAT Entry"
VATEntryLocal.Copy(Rec);
VATEntryLocal.SetRange("G/L Acc. No.", '');
if WithUI then begin
if ShowConfirm then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
if GuiAllowed() then begin
if ShowConfirm and not Response then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
end else
// Background execution has no user to confirm with; proceed so the report can run unattended.
Response := true;
if not Response then
exit;

Expand Down Expand Up @@ -1344,6 +1348,9 @@ table 254 "VAT Entry"
VATEntryUpdate.SetRange("G/L Acc. No.", '');
VATEntryUpdate.SetFilter("Entry No.", EntryNoFilter.ToText());
VATEntryUpdate.ModifyAll("G/L Acc. No.", GLAccountNo, false);
// Persist each batch so a long-running adjustment that times out can resume from where it
// left off instead of restarting from scratch and never completing.
Commit();
EntryNoFilter.Clear();
TotalChunkDuration += CurrentDateTime() - StartTime;
ChunkCount += 1;
Expand Down
11 changes: 9 additions & 2 deletions src/Layers/DACH/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -1153,8 +1153,12 @@ table 254 "VAT Entry"
VATEntryLocal.Copy(Rec);
VATEntryLocal.SetRange("G/L Acc. No.", '');
if WithUI then begin
if ShowConfirm then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
if GuiAllowed() then begin
if ShowConfirm and not Response then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
end else
// Background execution has no user to confirm with; proceed so the report can run unattended.
Response := true;
if not Response then
exit;

Expand Down Expand Up @@ -1304,6 +1308,9 @@ table 254 "VAT Entry"
VATEntryUpdate.SetRange("G/L Acc. No.", '');
VATEntryUpdate.SetFilter("Entry No.", EntryNoFilter.ToText());
VATEntryUpdate.ModifyAll("G/L Acc. No.", GLAccountNo, false);
// Persist each batch so a long-running adjustment that times out can resume from where it
// left off instead of restarting from scratch and never completing.
Commit();
EntryNoFilter.Clear();
TotalChunkDuration += CurrentDateTime() - StartTime;
ChunkCount += 1;
Expand Down
11 changes: 9 additions & 2 deletions src/Layers/ES/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -1274,8 +1274,12 @@ table 254 "VAT Entry"
VATEntryLocal.Copy(Rec);
VATEntryLocal.SetRange("G/L Acc. No.", '');
if WithUI then begin
if ShowConfirm then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
if GuiAllowed() then begin
if ShowConfirm and not Response then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
end else
// Background execution has no user to confirm with; proceed so the report can run unattended.
Response := true;
if not Response then
exit;

Expand Down Expand Up @@ -1425,6 +1429,9 @@ table 254 "VAT Entry"
VATEntryUpdate.SetRange("G/L Acc. No.", '');
VATEntryUpdate.SetFilter("Entry No.", EntryNoFilter.ToText());
VATEntryUpdate.ModifyAll("G/L Acc. No.", GLAccountNo, false);
// Persist each batch so a long-running adjustment that times out can resume from where it
// left off instead of restarting from scratch and never completing.
Commit();
EntryNoFilter.Clear();
TotalChunkDuration += CurrentDateTime() - StartTime;
ChunkCount += 1;
Expand Down
11 changes: 9 additions & 2 deletions src/Layers/FI/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -1130,8 +1130,12 @@ table 254 "VAT Entry"
VATEntryLocal.Copy(Rec);
VATEntryLocal.SetRange("G/L Acc. No.", '');
if WithUI then begin
if ShowConfirm then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
if GuiAllowed() then begin
if ShowConfirm and not Response then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
end else
// Background execution has no user to confirm with; proceed so the report can run unattended.
Response := true;
if not Response then
exit;

Expand Down Expand Up @@ -1281,6 +1285,9 @@ table 254 "VAT Entry"
VATEntryUpdate.SetRange("G/L Acc. No.", '');
VATEntryUpdate.SetFilter("Entry No.", EntryNoFilter.ToText());
VATEntryUpdate.ModifyAll("G/L Acc. No.", GLAccountNo, false);
// Persist each batch so a long-running adjustment that times out can resume from where it
// left off instead of restarting from scratch and never completing.
Commit();
EntryNoFilter.Clear();
TotalChunkDuration += CurrentDateTime() - StartTime;
ChunkCount += 1;
Expand Down
11 changes: 9 additions & 2 deletions src/Layers/FR/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,12 @@ table 254 "VAT Entry"
VATEntryLocal.Copy(Rec);
VATEntryLocal.SetRange("G/L Acc. No.", '');
if WithUI then begin
if ShowConfirm then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
if GuiAllowed() then begin
if ShowConfirm and not Response then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
end else
// Background execution has no user to confirm with; proceed so the report can run unattended.
Response := true;
if not Response then
exit;

Expand Down Expand Up @@ -1299,6 +1303,9 @@ table 254 "VAT Entry"
VATEntryUpdate.SetRange("G/L Acc. No.", '');
VATEntryUpdate.SetFilter("Entry No.", EntryNoFilter.ToText());
VATEntryUpdate.ModifyAll("G/L Acc. No.", GLAccountNo, false);
// Persist each batch so a long-running adjustment that times out can resume from where it
// left off instead of restarting from scratch and never completing.
Commit();
EntryNoFilter.Clear();
TotalChunkDuration += CurrentDateTime() - StartTime;
ChunkCount += 1;
Expand Down
11 changes: 9 additions & 2 deletions src/Layers/IT/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -1476,8 +1476,12 @@ table 254 "VAT Entry"
VATEntryLocal.Copy(Rec);
VATEntryLocal.SetRange("G/L Acc. No.", '');
if WithUI then begin
if ShowConfirm then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
if GuiAllowed() then begin
if ShowConfirm and not Response then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
end else
// Background execution has no user to confirm with; proceed so the report can run unattended.
Response := true;
if not Response then
exit;

Expand Down Expand Up @@ -1627,6 +1631,9 @@ table 254 "VAT Entry"
VATEntryUpdate.SetRange("G/L Acc. No.", '');
VATEntryUpdate.SetFilter("Entry No.", EntryNoFilter.ToText());
VATEntryUpdate.ModifyAll("G/L Acc. No.", GLAccountNo, false);
// Persist each batch so a long-running adjustment that times out can resume from where it
// left off instead of restarting from scratch and never completing.
Commit();
EntryNoFilter.Clear();
TotalChunkDuration += CurrentDateTime() - StartTime;
ChunkCount += 1;
Expand Down
11 changes: 9 additions & 2 deletions src/Layers/NA/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -1150,8 +1150,12 @@ table 254 "VAT Entry"
VATEntryLocal.Copy(Rec);
VATEntryLocal.SetRange("G/L Acc. No.", '');
if WithUI then begin
if ShowConfirm then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
if GuiAllowed() then begin
if ShowConfirm and not Response then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
end else
// Background execution has no user to confirm with; proceed so the report can run unattended.
Response := true;
if not Response then
exit;

Expand Down Expand Up @@ -1301,6 +1305,9 @@ table 254 "VAT Entry"
VATEntryUpdate.SetRange("G/L Acc. No.", '');
VATEntryUpdate.SetFilter("Entry No.", EntryNoFilter.ToText());
VATEntryUpdate.ModifyAll("G/L Acc. No.", GLAccountNo, false);
// Persist each batch so a long-running adjustment that times out can resume from where it
// left off instead of restarting from scratch and never completing.
Commit();
EntryNoFilter.Clear();
TotalChunkDuration += CurrentDateTime() - StartTime;
ChunkCount += 1;
Expand Down
11 changes: 9 additions & 2 deletions src/Layers/NL/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -1134,8 +1134,12 @@ table 254 "VAT Entry"
VATEntryLocal.Copy(Rec);
VATEntryLocal.SetRange("G/L Acc. No.", '');
if WithUI then begin
if ShowConfirm then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
if GuiAllowed() then begin
if ShowConfirm and not Response then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
end else
// Background execution has no user to confirm with; proceed so the report can run unattended.
Response := true;
if not Response then
exit;

Expand Down Expand Up @@ -1285,6 +1289,9 @@ table 254 "VAT Entry"
VATEntryUpdate.SetRange("G/L Acc. No.", '');
VATEntryUpdate.SetFilter("Entry No.", EntryNoFilter.ToText());
VATEntryUpdate.ModifyAll("G/L Acc. No.", GLAccountNo, false);
// Persist each batch so a long-running adjustment that times out can resume from where it
// left off instead of restarting from scratch and never completing.
Commit();
EntryNoFilter.Clear();
TotalChunkDuration += CurrentDateTime() - StartTime;
ChunkCount += 1;
Expand Down
11 changes: 9 additions & 2 deletions src/Layers/NO/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -1152,8 +1152,12 @@ table 254 "VAT Entry"
VATEntryLocal.Copy(Rec);
VATEntryLocal.SetRange("G/L Acc. No.", '');
if WithUI then begin
if ShowConfirm then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
if GuiAllowed() then begin
if ShowConfirm and not Response then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
end else
// Background execution has no user to confirm with; proceed so the report can run unattended.
Response := true;
if not Response then
exit;

Expand Down Expand Up @@ -1303,6 +1307,9 @@ table 254 "VAT Entry"
VATEntryUpdate.SetRange("G/L Acc. No.", '');
VATEntryUpdate.SetFilter("Entry No.", EntryNoFilter.ToText());
VATEntryUpdate.ModifyAll("G/L Acc. No.", GLAccountNo, false);
// Persist each batch so a long-running adjustment that times out can resume from where it
// left off instead of restarting from scratch and never completing.
Commit();
EntryNoFilter.Clear();
TotalChunkDuration += CurrentDateTime() - StartTime;
ChunkCount += 1;
Expand Down
11 changes: 9 additions & 2 deletions src/Layers/RU/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -1298,8 +1298,12 @@ table 254 "VAT Entry"
VATEntryLocal.Copy(Rec);
VATEntryLocal.SetRange("G/L Acc. No.", '');
if WithUI then begin
if ShowConfirm then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
if GuiAllowed() then begin
if ShowConfirm and not Response then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
end else
// Background execution has no user to confirm with; proceed so the report can run unattended.
Response := true;
if not Response then
exit;

Expand Down Expand Up @@ -1449,6 +1453,9 @@ table 254 "VAT Entry"
VATEntryUpdate.SetRange("G/L Acc. No.", '');
VATEntryUpdate.SetFilter("Entry No.", EntryNoFilter.ToText());
VATEntryUpdate.ModifyAll("G/L Acc. No.", GLAccountNo, false);
// Persist each batch so a long-running adjustment that times out can resume from where it
// left off instead of restarting from scratch and never completing.
Commit();
EntryNoFilter.Clear();
TotalChunkDuration += CurrentDateTime() - StartTime;
ChunkCount += 1;
Expand Down
11 changes: 9 additions & 2 deletions src/Layers/W1/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -1130,8 +1130,12 @@ table 254 "VAT Entry"
VATEntryLocal.Copy(Rec);
VATEntryLocal.SetRange("G/L Acc. No.", '');
if WithUI then begin
if ShowConfirm then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
if GuiAllowed() then begin
if ShowConfirm and not Response then
Response := ConfirmManagement.GetResponseOrDefault(ConfirmAdjustQst, false);
end else
// Background execution has no user to confirm with; proceed so the report can run unattended.
Response := true;
if not Response then
exit;

Expand Down Expand Up @@ -1281,6 +1285,9 @@ table 254 "VAT Entry"
VATEntryUpdate.SetRange("G/L Acc. No.", '');
VATEntryUpdate.SetFilter("Entry No.", EntryNoFilter.ToText());
VATEntryUpdate.ModifyAll("G/L Acc. No.", GLAccountNo, false);
// Persist each batch so a long-running adjustment that times out can resume from where it
// left off instead of restarting from scratch and never completing.
Commit();
EntryNoFilter.Clear();
TotalChunkDuration += CurrentDateTime() - StartTime;
ChunkCount += 1;
Expand Down
27 changes: 27 additions & 0 deletions src/Layers/W1/Tests/VAT/ERMGLVATReconciliation.Codeunit.al
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Microsoft.Finance.VAT.Ledger;

codeunit 134991 "ERM G/L - VAT Reconciliation"
{
Subtype = Test;
Expand Down Expand Up @@ -112,6 +114,31 @@ codeunit 134991 "ERM G/L - VAT Reconciliation"
VerifyGLAccountNoInVATEntries(VATEntry, GLAccountNo);
end;

[Test]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟠\ High\ Severity\ —\ Agent} \quad \color{gray}{\texttt{\small Iteration\ 3}}$

SetGLAccountNoEventPreApprovalSkipsConfirm calls VATEntry.SetGLAccountNo(true), which exercises the new Commit() call inside FlushBatchedGLAccountNoUpdate.

Because the test declares no [TransactionModel(...)] attribute, it runs under the default AutoRollback. The first Commit() inside the tested code will produce a runtime error rather than an assertion failure, leaving the test unable to yield a business-logic verdict. Per the referenced guidance, any test that drives code calling Commit() must carry [TransactionModel(TransactionModel::AutoCommit)]. Add the attribute above [Test] on this method. The codeunit should also be paired with a TestIsolation-enabled test runner so the committed rows are reverted between runs.

Suggested fix (apply manually — could not be anchored as a one-click suggestion):

    [TransactionModel(TransactionModel::AutoCommit)]
    [Test]

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why

procedure SetGLAccountNoEventPreApprovalSkipsConfirm()
var
VATEntry: Record "VAT Entry";
GLVATReconAdjustSubs: Codeunit "GL VAT Recon. Adjust Subs.";
GLAccountNo: array[4] of Code[20];
begin
// [SCENARIO 640489] When a subscriber to OnBeforeSetGLAccountNo pre-approves the adjustment, the confirm is skipped and processing continues, so the report can run unattended
Initialize();

// [GIVEN] 4 G/L Entry - VAT Entry Links, where two of them refer to VAT Entries whose G/L Account Number field is blank
CreateVATEntriesGLEntriesWithLink(GLAccountNo, TransactionNo);
VATEntry.SetRange("Transaction No.", TransactionNo);

// [GIVEN] A subscriber that pre-approves the adjustment via OnBeforeSetGLAccountNo (Response := true)
BindSubscription(GLVATReconAdjustSubs);

// [WHEN] The SetGLAccountNo function is called with WithUI set to true (which also requests a confirm) and no ConfirmHandler is registered
VATEntry.SetGLAccountNo(true);
UnbindSubscription(GLVATReconAdjustSubs);

// [THEN] The G/L Account Number field is correctly set for all the test VAT Entries, without any confirm being raised
VerifyGLAccountNoInVATEntries(VATEntry, GLAccountNo);
end;

local procedure Initialize()
begin
LibraryTestInitialize.OnTestInitialize(Codeunit::"ERM G/L - VAT Reconciliation");
Expand Down
14 changes: 14 additions & 0 deletions src/Layers/W1/Tests/VAT/GLVATReconAdjustSubscriber.Codeunit.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.Finance.VAT.Ledger;

codeunit 134241 "GL VAT Recon. Adjust Subs."
{
EventSubscriberInstance = Manual;

[EventSubscriber(ObjectType::Table, Database::"VAT Entry", OnBeforeSetGLAccountNo, '', false, false)]
local procedure PreApproveAdjustmentOnBeforeSetGLAccountNo(var VATEntry: Record "VAT Entry"; var IsHandled: Boolean; var Response: Boolean)
begin
// Pre-approve the adjustment via the event so the confirm dialog is skipped and processing continues.
// IsHandled is intentionally left false so the standard G/L Account No. adjustment logic still runs.
Response := true;
end;
}
Loading