Skip to content

[E-Document Formats] Migrate NAV PRs 247170 and 247176 into BCApps#9426

Merged
aholstrup1 merged 16 commits into
mainfrom
user/magnushar/migrate-nav-pr-247170-247176
Jul 23, 2026
Merged

[E-Document Formats] Migrate NAV PRs 247170 and 247176 into BCApps#9426
aholstrup1 merged 16 commits into
mainfrom
user/magnushar/migrate-nav-pr-247170-247176

Conversation

@Groenbech96

@Groenbech96 Groenbech96 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Migrates the PINT A-NZ and Factura-E e-document formats onto the E-Document V2.0 structured import pipeline. Each format now provides an IStructuredFormatReader implementation that reads the received XML directly into the purchase draft staging tables (E-Document Purchase Header/E-Document Purchase Line), replacing the legacy import flow.

AB#580191

Changes

PINT A-NZ (src/Apps/APAC/EDocumentFormats/PINT A-NZ)

  • EDocumentPINTANZHandler — new IStructuredFormatReader.ReadIntoDraft implementation that parses the PINT A-NZ UBL invoice/credit-memo into the purchase draft buffers.
  • PINT A-NZ EDoc Read into Draft — enum extension registering the handler on "E-Doc. Read into Draft".
  • Test resource (pint_a-nz-invoice-0.xml), structured tests and validation codeunit.

Factura-E (src/Apps/ES/EDocumentFormats/FacturaE)

  • EDocumentFacturaEHandler — new IStructuredFormatReader.ReadIntoDraft implementation for the Factura-E 3.2.2 XML, including unit-of-measure mapping from Factura-E international codes to BC units of measure.
  • Factura-E EDoc Read into Draft — enum extension registering the handler on "E-Doc. Read into Draft".
  • Test resource (facturae-invoice-0.xml), structured tests and validation codeunit.

E-Document core (src/Apps/W1/EDocument)

  • E-Document PEPPOL Utility — new public helper codeunit with reusable PEPPOL BIS 3.0 UBL extraction logic (namespaces, party, amounts, lines, attachments, currency) shared by the format readers.
  • E-Doc. Readable Purchase Doc.SetBuffer promoted from internal to public (with documentation) so format readers can present extracted data without persisting a draft.

Tests

Each format has structured integration tests covering:

  • Full content extraction into the draft staging tables.
  • Purchase invoice creation from a valid document (lines auto-matched to items via item reference).
  • Updating a draft line through the UI and finalizing the document.

All new tests run in the IntegrationTests bucket (AU/NZ for PINT A-NZ, ES for Factura-E).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Groenbech96
Groenbech96 requested review from a team July 14, 2026 11:53
@Groenbech96
Groenbech96 requested review from a team as code owners July 14, 2026 11:53
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Jul 14, 2026
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Copilot PR Review

Iteration 7 · Outcome: completed

Knowledge source: https://github.com/microsoft/BCQuality@186d8a131465475c79244d994acb872cd5c0d4bf

Findings by domain

Findings split into Knowledge-backed (cite a BCQuality article) and Agent (the agent's own judgement, no matching BCQuality rule).

Domain Findings Knowledge-backed Agent Inline Fallback
Interfaces 1 1 0 0 0
Privacy 2 2 0 2 0
Style 1 1 0 1 0
Testing 2 2 0 0 0

Totals: 6 knowledge-backed · 0 agent findings.

Orchestrator pre-filter (2 file(s) excluded)

  • layer-disabled (knowledge) : 2 file(s)

Findings produced by the AL review agent v1.7.3. Reply 👎 on any inline comment to flag false positives.

Magnus Hartvig Grønbech and others added 2 commits July 14, 2026 17:58
Resolves Pull Request Build failures AL0185 (missing 'EDocument XML Helper') and AL0297 (Factura-E object id range).

[bcapps-fix-loop attempt 1]

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Groenbech96

Copy link
Copy Markdown
Contributor Author

Follow-up on the work-item check: I could not infer a valid ADO work item from the mirrored source PRs, so this needs a human-provided work item ID. Once an ID is provided, add AB# (or Fixes AB#) to the PR description and the check should pass.

Comment thread src/Apps/W1/EDocument/App/src/Helpers/EDocumentXMLHelper.Codeunit.al Outdated
Comment thread src/Apps/W1/EDocument/App/app.json Outdated
- Change codeunit ID 6410 -> 6430 (6410 clashes with another object in the repo)

- Fix inverted #pragma warning disable/restore AA0139 in PINT A-NZ handler

- Move procedure-local Label vars to codeunit scope in both handlers

[bcapps-fix-loop attempt 2]

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread src/Apps/ES/EDocumentFormats/FacturaE/test/src/LibraryEDocument.Codeunit.al Outdated
Comment thread src/Apps/W1/EDocument/App/src/Helpers/EDocumentXMLHelper.Codeunit.al Outdated
Comment thread src/Apps/APAC/EDocumentFormats/PINT A-NZ/test/src/EDocFormatMock.EnumExt.al Outdated
Comment thread src/Apps/ES/EDocumentFormats/FacturaE/test/src/EDocFormatMock.EnumExt.al Outdated
- Move XML helper APIs into codeunit 6401 (E-Document PEPPOL Utility)

- Switch Factura-E and PINT A-NZ handlers to use PEPPOL utility

- Remove temporary EDocument XML Helper codeunit and unnecessary internalsVisibleTo entries

- Reassign Factura-E handler from conflicting 10776 to 10766 and update idRanges

[bcapps-fix-loop attempt 3]

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve compile issues from migrated handlers by using E-Document document type, replacing inaccessible View implementation, and switching to TryGetStringValue-based field extraction.

[bcapps-fix-loop attempt 4]

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@JesperSchulz JesperSchulz added the Integration GitHub request for Integration area label Jul 17, 2026
@github-actions github-actions Bot added the Other GitHub request for other area than SCM, Finance or Integration label Jul 17, 2026
magnushar and others added 2 commits July 21, 2026 08:52
Magnus Hartvig Grønbech and others added 2 commits July 21, 2026 09:26
- Implement View() in PINT A-NZ and Factura-E handlers to open the readable purchase document page instead of erroring, so the ViewExtractedData tests exercise real view behavior.
- Make E-Doc. Readable Purchase Doc. SetBuffer public so format apps can reuse it.
- Consolidate XML extraction: call shared E-Document PEPPOL Utility SetStringValueInField/SetCurrencyValueInField and remove duplicate local wrappers in both handlers (SetStringValueInField now takes a Text destination).
- Guard XmlDocument.ReadFrom and move error/root-element messages to Labels.
- Guard Factura-E unit-of-measure Evaluate and enum range lookup.
- Use a local line counter instead of GetNextLineNo per row, and build each line document with XmlDocument.Create()/Add().
- Move procedure-local Item labels to object scope in the structured validations codeunits.
- Add XML documentation to new public PEPPOL utility procedures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ssertions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

$\textbf{🟡\ Medium\ Severity\ —\ Error\ Handling}$

The new PINT A-NZ and Factura-E readers rely on the shared SetNumberValueInField/SetDateValueInField helpers, which call Evaluate without checking its Boolean result. These two new, untrusted-XML entry points substantially increase exposure to this pre-existing gap: if a required XML node is present with malformed numeric/date content, the import surfaces a raw conversion exception instead of a controlled document-format error. Guard these Evaluate calls and translate bad values into a reader-specific parse/validation failure.

Line mapping was unavailable, so this was posted as an issue comment.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.12.4

The UpdateDraftAndFinalize tests manually reassigned the draft line item via the page, but Prepare Draft had already matched the line to an item via Item Reference (product code 1000/2000). On Finish Draft the stale [BC] Item Reference No. re-resolved the line back to the referenced item, so the manual assignment (and raw 'Bicycle' description) was lost. Clear the item reference on the draft line after reassigning, and give the generic item a Purchase unit of measure so the resulting purchase line UoM is deterministic. Also set the PINT A-NZ line type to Item, mirroring the Factura-E test.

For Factura-E, the finalized purchase lines resolve through Item Reference (UoM 'PCS'), so the purchase-line UoM assertions must expect the mapped BC unit of measure 'PCS' rather than the raw Factura-E code '01' (which remains correct only for the extracted E-Document line).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The previous attempt cleared the matched item reference through the draft subform's Item Reference No. control, but that control is Visible = false so the test framework could not find it (The field with ID ... is not found on the page). Close the draft page after the manual reassignment and clear [BC] Item Reference No. directly on the E-Document Purchase Line, so Finish Draft keeps the manually assigned item instead of re-resolving it from the product code's item reference.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aholstrup1
aholstrup1 merged commit 03a98e8 into main Jul 23, 2026
326 of 332 checks passed
@aholstrup1
aholstrup1 deleted the user/magnushar/migrate-nav-pr-247170-247176 branch July 23, 2026 07:20
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 Other GitHub request for other area than SCM, Finance or Integration Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants