Skip to content

[Master]-Withholding Tax Posting generates Unbalanced G/L Entries when Multiple Withholding Tax Rates are used on one Purchase Invoice. - #10073

Draft
neeleshsinghal wants to merge 1 commit into
mainfrom
bugs/Bug-646139-Withholding-Tax-Unbalanced-GL-Multiple-Withholding-Tax-Rate-New
Draft

[Master]-Withholding Tax Posting generates Unbalanced G/L Entries when Multiple Withholding Tax Rates are used on one Purchase Invoice.#10073
neeleshsinghal wants to merge 1 commit into
mainfrom
bugs/Bug-646139-Withholding-Tax-Unbalanced-GL-Multiple-Withholding-Tax-Rate-New

Conversation

@neeleshsinghal

@neeleshsinghal neeleshsinghal commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Fixes AB#646139

@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 Finance GitHub request for Finance area labels Aug 10, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 10, 2026
@neeleshsinghal
neeleshsinghal requested a lite review from Copilot August 10, 2026 06:45

Copilot AI left a comment

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.

Pull request overview

Fixes an issue in the Withholding Tax purchase posting flow where multiple withholding tax entries (from multiple WHT rates/product posting groups on the same purchase invoice) could result in incorrect vendor liability adjustments and unbalanced G/L entries.

Changes:

  • Accumulate Purchase Header."Withholding Tax Amount" across all relevant Withholding Tax Entries during posting (instead of overwriting it per entry).
  • Add a regression test covering multiple WHT rates on a single purchase invoice, plus helper procedures to set up lines and posting setups.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/Apps/W1/WithholdingTax/app/src/Purchase/Transaction/WthldgTaxPurchSubscribers.Codeunit.al Fixes posting logic by accumulating withholding tax amounts across multiple WHT entries.
src/Apps/W1/WithholdingTax/Test/src/ERMWithholdingTaxTestsI.Codeunit.al Adds regression coverage for multiple WHT rates on one invoice and supporting test helpers.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Initialize();

// [GIVEN] Withholding Tax enabled and two WHT Posting Setups sharing the WHT Bus. Posting Group but with different WHT Prod. Posting Groups and percentages.
UpdateGeneralLedgerSetup(true, false); // Round Amount for WHT Calc and True as Enable WHT.
Comment on lines +1938 to +1940
ExpectedWHTAmount :=
Round(LineAmount1 * WHTPostingSetup1."Withholding Tax %" / 100) +
Round(LineAmount2 * WHTPostingSetup2."Withholding Tax %" / 100);
LineAmount := PurchaseLine."Line Amount";
end;

local procedure CreateSecondWHTPostingSetupForSameBusGroup(var WHTPostingSetup2: Record "Withholding Tax Posting Setup"; WHTPostingSetup1: Record "Withholding Tax Posting Setup"; WHTPct: Decimal)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1 Finance GitHub request for Finance area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants