Describe the issue
CalcVATAmountLines in table 5902 "Service Line" diverges from the Sales Line / Purchase Line implementation, causing two defects visible on Service Statistics when invoice rounding and VAT difference are both enabled:
- VAT Difference is double-counted when accumulating the rounding residual:
TotalVATAmount += ServiceLine."Amount Including VAT" - ServiceLine.Amount + ServiceLine."VAT Difference";
Sales Line accumulates SalesLine."Amount Including VAT" - SalesLine.Amount only. Since Amount Including VAT - Amount already contains the VAT Difference, the Service version adds it twice, and the excess is dumped onto the 0% invoice-rounding VAT line, so the VAT specification shows an incorrect VAT amount on the rounding line.
- The filters set by
FindVATAmountLine in the invoice-rounding block are never reset, so OnAfterCalcVATAmountLines fires with a filtered VATAmountLine, and the VAT Specification subform on page 6030 "Service Statistics" can show a single VAT line instead of all lines. Sales Line clears these filters before the event.
Verified still present in current main in BOTH src/Layers/W1/BaseApp/Service/Document/ServiceLine.Table.al and the NA layer's full table copy src/Layers/NA/BaseApp/Service/Document/ServiceLine.Table.al (the only country layer that overrides table 5902).
Expected behavior
Service document VAT statistics match the Sales/Purchase behavior: no double-counted VAT Difference on the invoice-rounding VAT line, and all VAT specification lines visible after recalculation.
Steps to reproduce
- Enable invoice rounding (Sales & Receivables Setup) and Allow VAT Difference with a Max. VAT Difference Allowed.
- Create a Service Invoice whose amounts require an invoice rounding line.
- Open Service Statistics and manually change the VAT amount (creating a VAT Difference) on a VAT line.
- The rounding VAT line receives the VAT Difference amount again (incorrect VAT amount), and the VAT specification can collapse to a single line.
Additional context
This is a copy of microsoft/BusinessCentralApps#1562 and microsoft/BusinessCentralApps#1563 (both labeled Approved/Finance in the contribution pilot). Both were being fixed together in microsoft/BusinessCentralApps#1913, which received a code-owner approval, but the internal merge attempt reported test failures and the PR was closed unmerged when the repository was retired. The likely cause of those failures has been identified: the fix patched the W1 layer only, while the NA layer's full copy of table 5902 kept the defects, so localization runs of the new W1 tests failed. The re-submitted fix will cover both layers.
I will provide a fix for a bug
Describe the issue
CalcVATAmountLinesin table 5902 "Service Line" diverges from the Sales Line / Purchase Line implementation, causing two defects visible on Service Statistics when invoice rounding and VAT difference are both enabled:Sales Line accumulates
SalesLine."Amount Including VAT" - SalesLine.Amountonly. SinceAmount Including VAT - Amountalready contains the VAT Difference, the Service version adds it twice, and the excess is dumped onto the 0% invoice-rounding VAT line, so the VAT specification shows an incorrect VAT amount on the rounding line.FindVATAmountLinein the invoice-rounding block are never reset, soOnAfterCalcVATAmountLinesfires with a filteredVATAmountLine, and the VAT Specification subform on page 6030 "Service Statistics" can show a single VAT line instead of all lines. Sales Line clears these filters before the event.Verified still present in current main in BOTH
src/Layers/W1/BaseApp/Service/Document/ServiceLine.Table.aland the NA layer's full table copysrc/Layers/NA/BaseApp/Service/Document/ServiceLine.Table.al(the only country layer that overrides table 5902).Expected behavior
Service document VAT statistics match the Sales/Purchase behavior: no double-counted VAT Difference on the invoice-rounding VAT line, and all VAT specification lines visible after recalculation.
Steps to reproduce
Additional context
This is a copy of microsoft/BusinessCentralApps#1562 and microsoft/BusinessCentralApps#1563 (both labeled Approved/Finance in the contribution pilot). Both were being fixed together in microsoft/BusinessCentralApps#1913, which received a code-owner approval, but the internal merge attempt reported test failures and the PR was closed unmerged when the repository was retired. The likely cause of those failures has been identified: the fix patched the W1 layer only, while the NA layer's full copy of table 5902 kept the defects, so localization runs of the new W1 tests failed. The re-submitted fix will cover both layers.
I will provide a fix for a bug