Skip to content

Bugs/bug 646637 main posting errorwith50 per non deductible vat - #10214

Open
sanjmaurya wants to merge 3 commits into
microsoft:mainfrom
sanjmaurya:bugs/Bug-646637-Main-PostingErrorwith50PerNonDeductibleVAT
Open

Bugs/bug 646637 main posting errorwith50 per non deductible vat#10214
sanjmaurya wants to merge 3 commits into
microsoft:mainfrom
sanjmaurya:bugs/Bug-646637-Main-PostingErrorwith50PerNonDeductibleVAT

Conversation

@sanjmaurya

@sanjmaurya sanjmaurya commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Bug 646637: [all-e][Master]Posting Error with 50% Non-Deductible VAT when "Check Source Currency Consistency" is enabled in "General Ledger Setup" page

Fixes AB#646637

Issue :- Posting Error with 50% Non-Deductible VAT when "Check Source Currency Consistency" is enabled in "General Ledger Setup" page

Cause :- When a purchase document is posted with partial non-deductible VAT in a foreign currency and “Check Source Curr. Consistency” is enabled in General Ledger Setup, the source-currency VAT amount on the deductible VAT G/L entry is created using the full source-currency VAT amount instead of subtracting the non-deductible VAT portion.

This causes the G/L source currency totals to become unbalanced, and the posting fails with the source currency consistency validation error.

Solutions:- Adjust the source-currency amount used for the deductible VAT G/L entry to exclude the non-deductible VAT portion:

Before:

GenJnlLine."Source Curr. VAT Amount"
After:

GenJnlLine."Source Curr. VAT Amount" - CalcAmountSrcCurr(GenJnlLine, VATPostingParameters."Non-Deductible VAT Amount")
This keeps the source-currency balance consistent for postings where only part of the VAT is deductible, while preserving the correct deductible VAT posting behavior.

@github-actions github-actions Bot added From Fork Pull request is coming from a fork Linked Issue is linked to a Azure Boards work item labels Aug 12, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 12, 2026
@github-actions github-actions Bot added the Finance GitHub request for Finance area label Aug 12, 2026
@sanjmaurya
sanjmaurya marked this pull request as ready for review August 13, 2026 08:57
@sanjmaurya
sanjmaurya requested a review from a team August 13, 2026 08:57
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Agentic PR Review - Round 1

Recommendation: Accept with Suggestions

What this PR does

This PR fixes a purchase posting failure for foreign-currency invoices with partial non-deductible VAT when source-currency consistency is enabled. The changed CreateNormalVATGLEntries call now posts the deductible VAT G/L entry with the full source-currency VAT amount minus the non-deductible source-currency part, while the non-deductible entry keeps its own source-currency amount.

The fix is targeted at the system-created purchase posting path that the work item describes. Using the non-deductible amount as a residual split is also safer for rounding than recalculating both parts independently, because the two source-currency VAT pieces still add back to the original source-currency VAT amount. I found the same normal VAT posting procedure across the changed country layers, and the PR applies the same correction consistently.

Suggestions

S1 - Assert the source-currency split amounts
The new test proves that all source-currency amounts balance. Add assertions for the source-currency amount on the deductible VAT G/L entry and the non-deductible VAT entry, so a future change cannot balance the document with the wrong amounts on the wrong accounts.

Risk assessment and necessity

Risk: This is a financial posting path: an incorrect source-currency amount can either block posting when consistency checking is enabled or persist wrong source-currency totals on G/L entries. The code change is narrow and does not change public APIs, events, or concurrency behavior, but it affects all changed BaseApp country variants of GenJnlPostLine.Codeunit.al. The added W1 and APAC tests cover the reported posting failure and source-currency balance; the remaining risk is the exact per-account source-currency split noted in S1.

Necessity: The work item and PR description describe a concrete customer path with purchase invoice posting, 50% non-deductible VAT, foreign currency, and Check Source Curr. Consistency enabled. Without this fix, users must disable the consistency check or avoid the partial non-deductible VAT setup, which is not a good workaround for a valid VAT posting scenario.


[AI-PR-REVIEW] version=1 promptVersion=2 system=github pr=10214 round=1 by=alexei-dobriansky at=2026-08-13T12:46:55Z lastSha=0f77c8e0bc524b084e37cc2de3980e93bb96c0ef reviewKey=75f2e849cb8ff5287628d838aa83e635d3c2b9327c0a047c53d6317f3a9538cf suggestions=S1@c44b4c1d

@sanjmaurya

Copy link
Copy Markdown
Contributor Author

HI alexei-dobriansky

We have done the S1. Please review

@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Agentic PR Review - Round 2

Recommendation: Accept

What this PR does

Since round 1, the PR updates the W1 and APAC non-deductible VAT currency tests. The test now uses a dedicated non-deductible purchase VAT account and checks the source-currency amount on both the deductible VAT account and the non-deductible VAT account.

This directly addresses the previous concern. The production fix is unchanged, and the new assertions prove the VAT source-currency split is correct, not only that the total source-currency amount balances.

Status of previous suggestions
ID Title Status Author response
S1 Assert the source-currency split amounts Addressed Added exact source-currency assertions for the purchase VAT account and the non-deductible purchase VAT account in W1 and APAC tests.
New observations (commits since round 1)

None - changes only addressed prior suggestions.

Risk assessment and necessity

Risk: The underlying production change is still in a financial posting path across the changed GenJnlPostLine.Codeunit.al country variants, so wrong source-currency amounts would be serious. The latest commit only changes tests and adds exact account-level assertions. It does not change public APIs, events, or posting behavior.

Necessity: The work item describes a concrete purchase posting failure with partial non-deductible VAT, foreign currency, and source-currency consistency enabled. The fix remains narrow and needed, and the added tests now cover the important source-currency split.


[AI-PR-REVIEW] version=1 promptVersion=2 system=github pr=10214 round=2 by=alexei-dobriansky at=2026-08-14T10:08:16Z lastSha=4146779c15e28e082737f24a4d88d7339a670e41 reviewKey=na suggestions=S1@c44b4c1d:addressed parentRound=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Finance GitHub request for Finance area From Fork Pull request is coming from a fork Linked Issue is linked to a Azure Boards work item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants