Skip to content

[29.X]-Source Currency Amount calculation causes discrepancies with Foreign Currency G/L Entries whit Reversal Charge VAT. - #11632

Open
Fixes4BC (neeleshsinghal) wants to merge 20 commits into
releases/29.xfrom
bugs/Bug-647818-Source-Currency-Amount-FCY-GL-Entries-Reversal-Charg29
Open

Fixes4BC (neeleshsinghal) wants to merge 20 commits into
releases/29.xfrom
bugs/Bug-647818-Source-Currency-Amount-FCY-GL-Entries-Reversal-Charg29

Conversation

@neeleshsinghal

@neeleshsinghal Fixes4BC (neeleshsinghal) commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Fixes AB#650406

…Line.Codeunit.al

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@neeleshsinghal Fixes4BC (neeleshsinghal) changed the title Bugs/bug 647818 source currency amount fcy gl entries reversal charg29 [29.X]-Source Currency Amount calculation causes discrepancies with Foreign Currency G/L Entries whit Reversal Charge VAT. Sep 20, 2026
@github-actions github-actions Bot added the Team: Finance GitHub request for Finance area label Sep 20, 2026
@github-actions github-actions Bot added this to the Version 29.1 milestone Sep 20, 2026
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 1

Recommendation: Request Changes

What this PR does

This change makes reverse charge VAT G/L entries use the source-currency VAT amount that was already calculated on the originating system-created journal line. That addresses the foreign-currency rounding case, but the new condition also treats a blank source currency as a foreign currency when an LCY code is configured. That can change LCY reverse charge posting from a calculated source amount to zero.

Problem-solution fit

Fit: Partial

The fix matches the reported foreign-currency rounding problem and the tests cover that shape well. It does not fully protect the existing LCY path, because a blank source currency can take the new branch even though there is no foreign source currency to preserve.

Suggestions

S1 (🔴 High): Blank source currency uses zero VAT amount
For system-created LCY lines, Source Currency Code is blank, so this condition can still be true when the LCY code is not blank. Then the reverse charge entries use Source Curr. VAT Amount, which is zero on that path, instead of calculating the LCY amount. Check for a non-blank foreign source currency before using the preserved VAT amount; otherwise keep CalcAmountSrcCurr.

Risk assessment and necessity

Risk: This is a financially sensitive posting path. The changed branch is copied across several country layers, so the same LCY regression can affect reverse charge VAT G/L entries in more than one localization.

Necessity: The change is needed because recalculating source-currency VAT from rounded LCY values can create wrong source-currency balances. The scope is right for the foreign-currency bug, but the condition must avoid changing the LCY behavior.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=11632 round=1 by=alexei-dobriansky at=2026-09-20T13:18:03Z lastSha=3098e0b99e78047a494acd527fefdd853216558d reviewKey=61eeaf1eff42ecbe4e9aefa33a01cd15876e2b8a2db6a453c5b1bfbb5faeeeb6 suggestions=S1@d0b12656

@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 2

Recommendation: Request Changes

What this PR does

The latest commit only removes an unneeded handler attribute from one ES test. The full change still makes reverse charge VAT G/L entries reuse the preserved source-currency VAT amount on system-created lines, which fits the foreign-currency rounding scenario. However, the condition still treats a blank source currency as different from a configured LCY code, so LCY system-created lines can still take the preserved-amount path even when there is no foreign source amount to preserve.

Status of previous suggestions
ID Title Status Author response
S1 Blank source currency uses zero VAT amount Not addressed No response. The current code still checks only Source Currency Code <> GLSetup."LCY Code"; no non-blank foreign-currency guard was added.
New observations (commits since round 1)

None - the new commit only removes an unneeded test handler attribute and does not change the posting logic that was flagged in round 1.

Risk assessment and necessity

Risk: This is still a financially sensitive posting path. The same condition is copied across APAC, BE, CH, ES, FI, FR, IT, NA, NO, RU, and W1, so an LCY reverse charge VAT regression can affect several localizations.

Necessity: The foreign-currency rounding fix is needed because recalculating source-currency VAT from LCY values can create wrong source-currency balances. The scope is still right, but the condition must also preserve the existing LCY behavior.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=11632 round=2 by=alexei-dobriansky at=2026-09-21T07:09:34Z lastSha=8c2bd4ac9f31e75be6068a04fe2edbc7fb83d74c reviewKey=118562c70527c1bdd7d442bf1be626cdcae647d34cb5c5eec703de1028e08c91 suggestions=S1@d0b12656:notaddressed parentRound=1

@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 3

Recommendation: Accept with Suggestions

What this PR does

This round updates reverse charge VAT G/L entry creation so system-created foreign-currency lines reuse the already calculated source-currency VAT amount only when the source currency is non-blank. It also adds localized regression tests for the foreign-currency rounding case.

Status of previous suggestions
ID Title Status Author response
S1 Guard blank source currency lines Addressed The preserved source amount branch now requires a non-blank source currency.
New observations (commits since round 2)

S2 (🟠 Moderate): Remove the unneeded IT confirm handler
This new IT test still declares ConfirmHandler, while the parallel ES test removed it. If the posting flow does not ask for confirmation, the expected handler can make the test fail; remove it unless the IT path really needs that confirmation.

Risk assessment and necessity

Risk: Reverse charge VAT source-currency amounts affect persisted ledger balances. The prior LCY regression risk is addressed; the remaining risk is limited to test stability.

Necessity: The change is needed because recalculating source-currency VAT from rounded LCY values can create wrong source-currency balances. The scope is appropriate for the reported foreign-currency rounding issue.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=11632 round=3 by=alexei-dobriansky at=2026-09-21T20:24:12.2309968Z lastSha=9ac3ecf88839292b8828ed47b1d52d08612c27b4 reviewKey=d2a929d009ff21fc58c0ba8f8445c10fdaaac23afee0e000e9be0cbd59acbbca suggestions=S1@old:addressed,S2@itconfirm:new parentRound=2

@neeleshsinghal
Fixes4BC (neeleshsinghal) requested a review from a team September 22, 2026 01:01
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 4

Recommendation: Accept

What this PR does

This round removes the extra confirm-handler binding from the IT regression test. The full PR still preserves source-currency reverse charge VAT amounts for system-created foreign-currency lines, while the non-blank source-currency guard keeps LCY lines on the existing calculated path.

Status of previous suggestions
ID Title Status Author response
S1 Guard blank source currency lines Addressed Already addressed before this round; the preserved source amount branch requires a non-blank source currency.
S2 Remove the unneeded IT confirm handler Addressed The latest commit removes the extra handler attribute from the IT test.
New observations (commits since round 3)

None - the only new commit removes the test handler attribute that was flagged in round 3.

Risk assessment and necessity

Risk: This remains a financial posting path because reverse charge VAT source-currency amounts are persisted to G/L entries across several localizations. The latest change is test-only and reduces test-harness risk.

Necessity: The posting change is needed to avoid source-currency rounding discrepancies for reverse charge VAT. The latest test cleanup is also needed so the new IT regression test matches the posting flow and does not expect a confirmation that is not part of this scenario.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=11632 round=4 by=alexei-dobriansky at=2026-09-22T01:08:49.7622592Z lastSha=686941208c2549f77446aa5af111d376050bd3ab reviewKey=3ded0b0e2ed6f1c40d056dc50c72cf55dbdd93d34c19a284dde668a9f03e9fa0 suggestions=S1@old:addressed,S2@itconfirm:addressed parentRound=3

This branch was successfully deployed

1 active (outdated) deployment
triage 3098e0b9 Deployed Sep 20, 2026 by neeleshsinghal via Classify team ownership #5229
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