[Master]-]Withholding Tax Entries are not generated at payment because the Withholding Tax. Prod. Posting Group field gets not transferred to the payment line#9375
Conversation
…e the Withholding Tax. Prod. Posting Group field gets not transferred to the payment line [AB#639524](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/639524)
Copilot PR ReviewIteration 8 · Outcome: completed Knowledge source: https://github.com/microsoft/BCQuality@186d8a131465475c79244d994acb872cd5c0d4bf Findings by domainFindings split into Knowledge-backed (cite a BCQuality article) and Agent (the agent's own judgement, no matching BCQuality rule).
Totals: 1 knowledge-backed · 0 agent findings. Orchestrator pre-filter (2 file(s) excluded)
Findings produced by the AL review agent v1.7.3. Reply 👎 on any inline comment to flag false positives. |
| GenJournalLine2.SetRange("Journal Batch Name", GenJournalBatch.Name); | ||
| GenJournalLine2.SetRange("Document No.", StartingDocumentNo); | ||
| GenJournalLine2.FindFirst(); | ||
| GenJournalLine2.TestField("Wthldg. Tax Prod. Post. Group", WHTProdPostingGroup.Code); |
There was a problem hiding this comment.
The new test WHTProdPostGroupTravelsFromInvoiceToJournalLineOnApplication enqueues four values into LibraryVariableStorage (template name, batch name, starting document no., bank account) consumed by CreatePaymentPageHandler, but never calls LibraryVariableStorage.AssertEmpty before the test ends.
Per BCQuality guidance, ending a test without AssertEmpty hides a leaked queue or a handler that dequeued fewer/more values than expected, so a future regression in the handler wiring could pass silently. Add LibraryVariableStorage.AssertEmpty() at the end of the test body.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
…iple Payment templates)
…stically in W1 and localizations
| end; | ||
|
|
||
|
|
||
| [EventSubscriber(ObjectType::Page, Page::"Create Payment", OnBeforeUpdateGnlJnlLineDimensionsFromVendorPayment, '', false, false)] |
There was a problem hiding this comment.
AssignWHTPostingGroupOnCreatePayment only subscribes to Page "Create Payment"'s OnBeforeUpdateGnlJnlLineDimensionsFromVendorPayment event, so the Wthldg.
Tax Prod. Post. Group is copied to the payment line only when a payment is created via the Vendor Ledger Entries "Create Payment" action. The very similar OnBeforeUpdateGnlJnlLineDimensionsFromVendorPaymentBuffer event, raised by the Suggest Vendor Payments report/batch job in every localization layer (W1, NA, IT, RU, CH, ES, APAC, FI), has no corresponding subscriber added in this PR. Payment lines generated by Suggest Vendor Payments will therefore still have a blank Wthldg. Tax Prod. Post. Group, leaving the exact bug this PR fixes unresolved for that entry point.
Recommendation:
- add an equivalent subscriber (or shared helper) for OnBeforeUpdateGnlJnlLineDimensionsFromVendorPaymentBuffer so both payment-creation paths populate the field consistently.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| if CheckWithholdingTaxDisabled() then | ||
| exit; | ||
|
|
||
| if GenJournalLine."Applies-to ID" = '' then |
There was a problem hiding this comment.
The guard if GenJournalLine."Applies-to ID" = '' then exit; can never be true for this event: the only publisher, CopyTempPaymentBufferToGenJournalLines in CreatePayment.Page.al, unconditionally sets GenJnlLine."Applies-to ID" := GenJnlLine."Document No." (always a non-blank generated value) before raising OnBeforeUpdateGnlJnlLineDimensionsFromVendorPayment.
The guard is dead code that misleadingly suggests the subscriber skips unapplied payments via this check, while the real filtering is done by the following TempVendorPaymentBuffer."Vendor Ledg. Entry No." = 0 guard.
Recommendation:
- remove the ineffective check or replace it with a check that reflects the real intent (for example,
TempVendorPaymentBuffer."Vendor Ledg. Entry Doc. No." = '') if the goal is to skip payments not applied to a specific document.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
…payment application scenario
AB#639524
Squashed replacement of #9323 (single commit).