Skip to content

[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
releases/28.xfrom
backport/releases/28.x/8313
Open

[Backport 28.x] Fix E-Doc V1 PEPPOL import: Sub Total uses LineExtensionAmount from XML (#8313)#8705
Groenbech96 wants to merge 1 commit into
releases/28.xfrom
backport/releases/28.x/8313

Conversation

@Groenbech96

@Groenbech96 Groenbech96 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Backports #8313 to releases/28.x.

Cherry-pick of commit e9452a1 (squash-merge of #8313).

Summary

  • EDocImport.Codeunit.al (V1_CopyFromPurchaseLine) — set "Sub Total" to PurchaseLine.Amount (the LineExtensionAmount parsed from the PEPPOL XML) instead of recalculating Direct Unit Cost * Quantity, which lost the vendor-rounded value (e.g. 6.79 * 1.65 = 11.2035 instead of the XML's 11.20).
  • Adds regression test ReceivePeppolInvoice_LineSubTotalFromXml and test invoice PEPPOL_LineRounding.xml.

Original PR: #8313
AB#613698

…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)
@Groenbech96 Groenbech96 requested review from a team June 22, 2026 08:17
@Groenbech96 Groenbech96 requested a review from a team as a code owner June 22, 2026 08:17
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Jun 22, 2026
@github-actions github-actions Bot added this to the Version 28.3 milestone Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant