Skip to content

[Master][all-e]Purchase Invoice Statistics Non-Deductible VAT Amount does not match VAT Entries and G/L Entries when Non-Deductible VAT is enabled. - #13482

Open
sanjmaurya wants to merge 3 commits into
mainfrom
bugs/Bug-657371-Main-PurchaseInvoiceStatisticsNonDeductibleVATAmountdoesnot
Open

sanjmaurya wants to merge 3 commits into
mainfrom
bugs/Bug-657371-Main-PurchaseInvoiceStatisticsNonDeductibleVATAmountdoesnot

Conversation

@sanjmaurya

@sanjmaurya sanjmaurya commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Bug 657371: [Master][all-e]Purchase Invoice Statistics Non-Deductible VAT Amount does not match VAT Entries and G/L Entries when Non-Deductible VAT is enabled.

Fixes AB#657371

Issue :- Purchase Invoice Statistics shows a Non-Deductible VAT Amount of 286.35, while Preview Posting shows 286.76 in VAT Entries and G/L Entries—a difference of 0.41, depending on how lines are split.

Cause :- Purchase posting allocates non-deductible VAT across document lines using rounding remainders. An invoice-specific calculation then overwrites these allocations by recalculating and rounding non-deductible VAT independently for each posting line. Splitting entries by dimensions or line descriptions therefore changes the total. Credit memos bypass this recalculation.

Solution :- Preserve the document’s allocated non-deductible VAT amounts for manual VAT entries generated by purchase posting. Restrict the recalculation to automatic journal VAT entries, retaining existing journal behavior. Regression tests were added for purchase invoices, prices including VAT, credit memos, and automatic journal calculations.

@github-actions github-actions Bot added the Team: Finance GitHub request for Finance area label Oct 31, 2026
@github-actions github-actions Bot added this to the Version 30.0 milestone Oct 31, 2026
@sanjmaurya
sanjmaurya marked this pull request as ready for review October 31, 2026 06:28
@sanjmaurya
sanjmaurya requested a review from a team as a code owner October 31, 2026 06:28
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 1

Recommendation: Accept

What this PR does

Preserves allocated non-deductible VAT for manual entries generated by purchase posting, while retaining automatic journal recalculation. This prevents split invoice entries from being rounded independently a second time.

Purch.-Post already distributes non-deductible VAT using rounding remainders, and Invoice Posting Buffer copies those amounts into manual VAT entries. The new guard preserves them through VAT/G/L posting. The split-line regression tests would produce 0.04 instead of 0.03 under the old condition; they assert statistics, VAT totals, G/L amounts, and balance. Coverage includes VAT-inclusive prices and credit memos, plus the retained automatic journal calculation.

Problem-solution fit

Fit: Strong

The reported mismatch comes from overwriting document-level rounding allocations during invoice posting. The guard removes that second LCY calculation for document-generated manual VAT entries without changing the calculation used by automatic journals.

Suggestions

None.

Risk assessment and necessity

Risk: VAT and G/L posting are financially sensitive, but the production change is limited to the existing normal-VAT invoice recalculation branch. Credit memos, reverse-charge VAT, full VAT, and additional-currency calculations retain their previous control flow; public signatures and events are unchanged. Sales and Service use the same manual-entry buffer copy, but their standard posting flows do not populate purchase non-deductible VAT allocations. The added tests cover the changed purchase path and the retained automatic-entry branch.

Necessity: Without this change, splitting purchase invoice posting entries can overstate non-deductible VAT and understate deductible VAT, leaving statistics inconsistent with VAT and G/L entries. Avoiding split entries is only a possible workaround where line-description and dimension requirements permit it. Preserving the existing document allocations is a narrow correction with no schema or upgrade changes.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=13482 round=1 by=alexei-dobriansky at=2026-10-31T08:18:16.5673799Z lastSha=7f9db318d8bb176ee9e42c42f01350e6febcb2b9 reviewKey=20e43be19fc30d9baadcb0f9e1dada2db2511727269957feebb58594a42ab170 suggestions=none

…Bug-657371-Main-PurchaseInvoiceStatisticsNonDeductibleVATAmountdoesnot
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 2

Recommendation: Accept

What this PR does

Preserves allocated non-deductible VAT for manual purchase-posting entries instead of rounding each invoice posting line again. Round 2 changes only the regression tests: the handler captures the non-deductible amount displayed by Statistics, and the tests compare both VAT and G/L totals against that amount. This is a suitable oracle for the reported mismatch, not a comparison of the posted result with itself. The tests retain a fixed total VAT assertion of 0.06, an independent 0.03 non-deductible assertion for prices excluding VAT, two-entry counts, deductible VAT assertions, and the G/L balance check. The unchanged automatic-journal test still checks exact recalculated amounts.

Problem-solution fit

Fit: Strong

The reported problem is a mismatch between purchase Statistics and posted VAT/G/L totals after line splitting. The production guard preserves the LCY allocations already copied from the invoice posting buffer for manual entries, while automatic normal-VAT invoices retain their previous recalculation. The revised tests directly compare Statistics with both posted totals while allowing the prices-including-VAT expectation to follow the displayed allocation.

Status of previous suggestions

No previous suggestions.

New observations (commits since round 1)

None. No new issue was found in the PR-owned changes since the previous round.

Risk assessment and necessity

Risk: VAT and G/L posting are financially sensitive, but the only new PR-owned commit changes test expectations and variable-storage handling. The full production fix adds one VAT-posting-mode guard without changing signatures, schema, credit-memo branching, or additional-currency control flow. The captured Statistics value is dequeued before posting and the queue is checked empty; the automatic-journal test retains exact amount assertions.

Necessity: Without the production change, separately rounded invoice posting lines can overstate non-deductible VAT and leave Statistics inconsistent with VAT and G/L entries. Avoiding split entries is only a possible workaround when dimension and description requirements permit it. The Round 2 adjustment keeps regression coverage focused on agreement with Statistics without imposing the same fixed VAT-inclusive allocation on every localization.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=13482 round=2 by=alexei-dobriansky at=2026-11-02T10:35:16.9220003Z lastSha=8ee0069d21b8777da3a9e9fbed15aa476ecfdc3f reviewKey=748547131fc25c09f9ffafdb642c2c4a98f67dc3f9588ec118e20cc387497cab suggestions= parentRound=1

This branch was previously deployed

1 inactive (outdated) deployment
triage — 7f9db318 Deployed Oct 31, 2026 by sanjmaurya via Classify team ownership #9649
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team: Finance GitHub request for Finance area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants