Add VAT rate resolution and VAT amount difference for E-Document purchases#8251
Conversation
…te/ventselartur/PayablesAgentVATSpike
…Line Prefer TaxRate (string, unambiguous percentage) over Tax (currency, ambiguous). Fall back to computing Tax/Amount*100 only when Tax contains a monetary amount (no % in value_text). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds enum value 2 ("VAT Rate Mismatch") to E-Document Notification Type,
with parallel Add/Dismiss/Disable procedures in the notification codeunit
and an updated SendPurchaseDocumentDraftNotifications that fans out to both
notification types via SetFilter.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Prepare Draft Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nvoice line Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…repare Draft Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaces the notification banner approach with a persisted boolean field and an inline warning column on the draft subform, following the PO matching warning pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…racted rate Instead of blindly clearing the mismatch flag when any posting group is selected, look up the VAT Posting Setup and compare its VAT % against the line's extracted VAT Rate. Only clear the warning when the rates actually match. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…date Remove rounding tolerance — compare VAT % from setup against extracted rate with exact equality. Zero-rate lines also go through the comparison instead of being skipped. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The lookup opens the VAT Posting Setup page filtered by the vendor's VAT Bus. Posting Group so the user only sees relevant combinations. Selection runs through Validate to trigger mismatch re-evaluation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…te/ventselartur/PayablesAgentVATSpike
Full VAT and Sales Tax do not use VAT % for rate-based matching. Filter FindVATProductPostingGroup, OnValidate, and OnLookup to exclude those calculation types. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…alidate Tests cover: Full VAT and Sales Tax ignored during Prepare Draft, Reverse Charge VAT resolved, OnValidate clears/keeps mismatch based on rate comparison, mismatch set when clearing posting group, Full VAT skips comparison, and zero-rate matching. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7 tasks covering: table field + triggers, Prepare Draft refactor, subform warning column, notification removal, and 9 tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…. Posting Group Field 111 [BC] VAT Rate Mismatch persists whether VAT resolution failed. OnValidate re-evaluates mismatch by comparing VAT Posting Setup rate against extracted rate, filtering to Normal/Reverse Charge VAT only. OnLookup opens VAT Posting Setup filtered by vendor's bus posting group.
…re Draft Replace HasUnresolvedVATLines + notification call with direct [BC] VAT Rate Mismatch field assignment. Filter FindVATProductPostingGroup to Normal VAT and Reverse Charge VAT calculation types only.
Per-line warning with Ambiguous styling, conditional visibility when any line has a mismatch, and drill-down showing the extracted VAT rate. Follows the PO matching warning pattern.
Notification replaced by persisted [BC] VAT Rate Mismatch field and inline warning column on draft subform.
…notification Rename and rewrite the mismatch test to assert [BC] VAT Rate Mismatch boolean. Add mismatch=false assertion to the successful resolution test.
Full VAT and Sales Tax setups are excluded from resolution. Reverse Charge VAT setups are matched successfully.
Covers: rate match clears mismatch, rate mismatch persists, clearing group sets mismatch, Full VAT skips comparison, zero-rate matching works.
Extract 10 VAT-related test procedures into new codeunit 139896 for better organization. No test logic changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All three VAT rate assertions changed to same valueThree separate line assertions (originally 6, 3, 1) have all been changed to 10 without a corresponding update to the mock ADI test data source. This suggests the new Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
Misleading Procedure Name: No 'Apply' HappensComputeAndApplyVATAmountDifference() computes the VAT diff and logs it, but does not actually apply it to any line — that happens later in ApplyVATDifferenceToLines(). The name implies a side-effect that does not occur here, which is confusing for future maintainers. Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
Missing Newline at End of FileThe file ends without a trailing newline (git diff shows '\ No newline at end of file'). This causes noise in diffs, breaks some Unix tooling, and violates the repo's consistent file formatting. Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
Why
When importing e-documents for purchase processing, the system did not automatically resolve VAT Product Posting Groups from extracted VAT rates. Users had to manually identify and assign the correct VAT posting group for each line, which was error-prone and time-consuming. Additionally, rounding differences between the document's total VAT and the computed line-level VAT amounts were not reconciled, leading to posting discrepancies.
Summary
[BC] VAT Prod. Posting Groupand[BC] VAT Rate Mismatchfields on E-Document Purchase Line with OnValidate/OnLookup supporttaxRatefield and properly disambiguate thetaxfield between percentage and monetary valuesE-Doc Purch. VAT Testscovering resolution, mismatch detection, OnValidate behavior, and VAT calculation type filteringFixes AB#619564