[Backport 28.x] Fix E-Doc V1 PEPPOL import: Sub Total uses LineExtensionAmount from XML (#8313)#8705
Open
Groenbech96 wants to merge 1 commit into
Open
[Backport 28.x] Fix E-Doc V1 PEPPOL import: Sub Total uses LineExtensionAmount from XML (#8313)#8705Groenbech96 wants to merge 1 commit into
Groenbech96 wants to merge 1 commit into
Conversation
…ML (#8313) ## Summary - **`EDocImport.Codeunit.al:843`** — `V1_CopyFromPurchaseLine` was setting `"Sub Total"` as `Direct Unit Cost * Quantity` instead of using `PurchaseLine.Amount` which holds the `LineExtensionAmount` parsed directly from the PEPPOL XML. - **`EDocReceiveTest.Codeunit.al`** — Added regression test `ReceivePeppolInvoice_LineSubTotalFromXml` that verifies `"Sub Total"` = 11.20 for a line with Qty=1.65, Price=6.79, LineExtensionAmount=11.20. - **`PEPPOL_LineRounding.xml`** — Minimal PEPPOL BIS 3.0 test invoice with rounding-sensitive quantities. ## Root cause In the V1 import path, `EDocImportPEPPOLBIS30` reads `LineExtensionAmount` (the vendor-rounded line total) into `PurchaseLine.Amount`. But `V1_CopyFromPurchaseLine` ignored it and recalculated: ```al // Before (bug): EDocumentPurchaseLine."Sub Total" := PurchaseLine."Direct Unit Cost" * PurchaseLine.Quantity; // 6.79 * 1.65 = 11.2035 — wrong, shows unrounded value on E-Document Purchase Draft page // After (fix): EDocumentPurchaseLine."Sub Total" := PurchaseLine.Amount; // 11.20 — correct, preserves vendor-rounded value from XML ``` `PurchaseLine.Amount` is set from the XML via `Evaluate(PurchaseLine.Amount, Value, 9)` at `EDocImportPEPPOLBIS30:503` and is preserved through `MapEDocument` (which copies all fields and only transforms Text/Code types, not Decimal). ## Test plan - [ ] `ReceivePeppolInvoice_LineSubTotalFromXml` passes: asserts `EDocumentPurchaseLine."Sub Total"` = 11.20 Fixes bug [AB#613698](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/613698) --------- Co-authored-by: Magnus Hartvig Grønbech <magnushar@microsoft.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> (cherry picked from commit e9452a1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backports #8313 to
releases/28.x.Cherry-pick of commit e9452a1 (squash-merge of #8313).
Summary
EDocImport.Codeunit.al(V1_CopyFromPurchaseLine) — set"Sub Total"toPurchaseLine.Amount(theLineExtensionAmountparsed from the PEPPOL XML) instead of recalculatingDirect Unit Cost * Quantity, which lost the vendor-rounded value (e.g. 6.79 * 1.65 = 11.2035 instead of the XML's 11.20).ReceivePeppolInvoice_LineSubTotalFromXmland test invoicePEPPOL_LineRounding.xml.Original PR: #8313
AB#613698