Extract AU WHT GenJnlPostBatch#9319
Conversation
| CustLedgEntry: Record "Cust. Ledger Entry"; | ||
| VendLedgEntry: Record "Vendor Ledger Entry"; | ||
| begin | ||
| GLSetup.Get(); |
There was a problem hiding this comment.
The new event subscriber OnPostGenJournalLineOnAfterPrepareGenJnlLineAddCurr calls GLSetup.Get() unconditionally before checking the cheap, already-in-memory GenJnlLine5."Skip WHT" flag.
Per the referenced guidance, cheap in-memory guards should run before any database call. This subscriber fires once per posted journal line, so reordering the check ahead of GLSetup.Get() avoids a setup-table read on every line where Skip WHT is already true.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
Copilot PR ReviewIteration 2 · Outcome: completed Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630 Findings by domainFindings split into Knowledge-backed (cite a BCQuality article) and Agent (the agent's own judgement, no matching BCQuality rule).
Totals: 0 knowledge-backed · 1 agent findings. Orchestrator pre-filter (13 file(s) excluded)
Findings produced by the Copilot CLI agent against BCQuality at |
| end; | ||
|
|
||
| [IntegrationEvent(false, false)] | ||
| local procedure OnPostGenJournalLineOnAfterPrepareGenJnlLineAddCurr(GenJnlLine5: Record "Gen. Journal Line"; CurrGenJnlLine: Record "Gen. Journal Line"; GenJournalLine: Record "Gen. Journal Line") |
There was a problem hiding this comment.
The new IntegrationEvent 'OnPostGenJournalLineOnAfterPrepareGenJnlLineAddCurr' (Gen.
Jnl.-Post Batch codeunit 13) declares its 'GenJnlLine5' parameter by value, not 'var'. The new subscriber in codeunit 'WHT Gen. Jnl.-Post Batch' relies entirely on this event to set 'GenJnlLine5."Skip WHT"' (via CheckWHTCalculationRule/VendorMinWHT/CustomerMinWHT, all of which take 'var GenJnlLine5'). Because AL passes Record parameters by value unless declared 'var', the subscriber mutates only its own local copy; the change is discarded when the event returns. Immediately after the event call, PostGenJournalLine continues to use its own 'GenJnlLine5' unchanged and passes it to GenJnlPostLine.RunWithoutCheck/RunWithCheck, whose logic (see GenJnlPostLine.Codeunit.al, many 'if not GenJnlLine."Skip WHT"' checks) depends on that flag. This silently disables the withholding-tax minimum-invoice-amount 'Skip WHT' computation for the paths that used to run inline before this refactor moved the logic behind the event. Impact would be major/blocker in practice (WHT is calculated/skipped incorrectly for affected postings); this should be promoted to a fix (declare the event parameter 'var GenJnlLine5') before merge, and ideally backed by a BCQuality knowledge rule on IntegrationEvent parameters needing 'var' when the subscriber's contract is to return a computed value to the publisher.
Suggested fix (apply manually — could not be anchored as a one-click suggestion):
[IntegrationEvent(false, false)]
local procedure OnPostGenJournalLineOnAfterPrepareGenJnlLineAddCurr(var GenJnlLine5: Record "Gen. Journal Line"; CurrGenJnlLine: Record "Gen. Journal Line"; GenJournalLine: Record "Gen. Journal Line")
begin
end;👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
What & why
Linked work
Fixes AB#636621
How I validated this
What I tested and the outcome (required — be specific: scenarios, commands, screenshots for UI changes)
Risk & compatibility