Skip to content

[E-Document Formats][OIOUBL] Migrate NAV PR 247162 into BCApps#9682

Open
Groenbech96 wants to merge 3 commits into
mainfrom
oioubl-edocument-structured-reader
Open

[E-Document Formats][OIOUBL] Migrate NAV PR 247162 into BCApps#9682
Groenbech96 wants to merge 3 commits into
mainfrom
oioubl-edocument-structured-reader

Conversation

@Groenbech96

@Groenbech96 Groenbech96 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Migrates internal NAV PR 247162 (OIOUBL structured E-Document reader) into BCApps, mirroring ALAppExtensions #29056 (Invoice + CreditNote only). Follows the same pattern as the PINT A-NZ / Factura-E migration (#9426).

Changes

OIOUBL format (src/Apps/DK/EDocumentFormatOIOUBL)

  • E-Document OIOUBL Handler (codeunit 13913) — new IStructuredFormatReader.ReadIntoDraft implementation parsing OIOUBL Invoice/CreditNote XML into the purchase draft staging tables (E-Document Purchase Header/E-Document Purchase Line). Vendor lookup via VAT reg. no., GLN, or PEPPOL participant id.
  • OIOUBL EDoc Read into Draft (enumext 13911) — registers the handler on "E-Doc. Read into Draft".
  • New test app (E-Document Format for OIOUBL Tests) with structured integration tests, validation codeunit and an OIOUBL invoice test resource.

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

  • Grant internalsVisibleTo to the new OIOUBL test app.

Adaptations from the NAV source

  • Uses the public E-Document PEPPOL Utility helper (BCApps) instead of NAV's EDocument XML Helper; View() uses temporary buffer records for the now-public SetBuffer.
  • Test app depends on E-Document Core Tests; NAV's duplicate format-mock files (would clash with the existing 6160 "Mock" value) and NAV-only Eng/Core/Build registrations are not mirrored.

Verification

Every referenced type, field, procedure, enum value, namespace and object ID verified against main; implementation mirrors the already-merged PINT A-NZ handler pattern.

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

Work item

Adds the OIOUBL (Danish UBL) structured import reader to the E-Document
V2.0 pipeline, mirroring internal NAV PR 247162 (which itself mirrors
ALAppExtensions #29056, Invoice + CreditNote only). Follows the same
pattern as the PINT A-NZ / Factura-E migration (#9426).

Changes (src/Apps/DK/EDocumentFormatOIOUBL):
- E-Document OIOUBL Handler: new IStructuredFormatReader.ReadIntoDraft
  implementation that parses OIOUBL Invoice/CreditNote XML into the
  purchase draft staging tables. Vendor lookup via VAT reg. no., GLN, or
  PEPPOL participant id.
- OIOUBL EDoc Read into Draft: enum extension registering the handler on
  "E-Doc. Read into Draft".
- Test app with structured integration tests, validation codeunit and
  OIOUBL invoice test resource.

E-Document Core (src/Apps/W1/EDocument): grant internalsVisibleTo to the
new "E-Document Format for OIOUBL Tests" app.

Adaptations from the NAV source:
- Uses the public "E-Document PEPPOL Utility" helper (BCApps) instead of
  NAV's "EDocument XML Helper"; View() uses temporary buffer records for
  the now-public SetBuffer.
- Test app depends on "E-Document Core Tests"; the duplicate format-mock
  files and NAV-only Eng/Core/Build registrations are not mirrored.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Groenbech96
Groenbech96 requested review from a team July 23, 2026 08:19
@Groenbech96
Groenbech96 requested review from a team as code owners July 23, 2026 08:19
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 Integration GitHub request for Integration area labels Jul 23, 2026
OIOUBLXml: XmlDocument;
XmlNamespaces: XmlNamespaceManager;
XmlElement: XmlElement;
CommonAggregateComponentsTok: Label 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2', Locked = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Style}$

Four namespace-URI Labels (CommonAggregateComponentsTok, CommonBasicComponentsTok, DefaultInvoiceTok, DefaultCreditNoteTok) are declared inside ReadIntoDraft's procedure-local var block instead of the codeunit's top-level var block. The sibling FacturaE and PINT A-NZ handlers in this same E-Document module declare their equivalent namespace-URI Labels (FacturaENamespaceTok, DigitalSignatureNamespaceTok, etc.) at object scope, which is the supported pattern for translation-pipeline discovery and reviewer visibility. Move these four Labels to the codeunit's top-level var block alongside GLNTok, InvoiceLineTok, and CreditNoteLineTok.

Knowledge:

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

var
EDocumentXMLHelper: Codeunit "E-Document PEPPOL Utility";
EDocumentImportHelper: Codeunit "E-Document Import Helper";
DKCVRTok: Label 'DK:CVR', Locked = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Style}$

DKCVRTok is declared inside ParseAccountingSupplierParty's procedure-local var block instead of the codeunit's top-level var block, the same anti-pattern as the namespace Labels in ReadIntoDraft. Declare it at object scope alongside the codeunit's other Locked tokens (GLNTok, InvoiceLineTok, CreditNoteLineTok).

Knowledge:

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

@github-actions github-actions Bot added this to the Version 29.0 milestone Jul 23, 2026
- Return correct E-Doc. Process Draft enum (Purchase Invoice / Purchase
  Credit Memo) instead of the obsolete Purchase Document value.
- Validate root element and namespace; reject unsupported roots.
- Reset draft header and lines on re-read to avoid duplicate lines.
- Read credit-note due date and invoice fallback from PaymentMeans/PaymentDueDate.
- Store credit-note BillingReference in Applies-to Ext. Invoice No.
- Fall back to PartyIdentification/ID for vendor identifier when VAT Id empty.
- Move test app/objects into valid Danish test id range (148061-148062)
  and hoist procedure-local labels to codeunit scope.
- Add regression tests and OIOUBL credit-note test fixture.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f304ccff-cedb-4561-b6da-97f63a379b2d
Assert.AreEqual(0, PurchaseLine."Line Discount Amount", StrSubstNo(MockDataMismatchErr, PurchaseLine.FieldCaption("Line Discount Amount"), PurchaseLine.TableCaption(), 0, PurchaseLine."Line Discount Amount"));
// In the import file we have a name 'Bicycle' but because of Item Cross Reference validation Item description is being used
if Item."No." <> '' then begin
Assert.AreEqual('Bicycle', PurchaseLine.Description, StrSubstNo(MockDataMismatchErr, PurchaseLine.FieldCaption(Description), PurchaseLine.TableCaption(), Item."No.", PurchaseLine.Description));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Testing}$

In AssertPurchaseDocument, the Assert.AreEqual check compares PurchaseLine.Description against the literal 'Bicycle', but the failure message built by StrSubstNo reports the expected value as Item."No." instead of 'Bicycle'. If this assertion ever fails, the diagnostic message will show the wrong expected value, misleading whoever investigates the failure. This looks like a copy-paste artifact from the following line, which correctly uses Item."No." for its own comparison.

Recommendation:

  • use 'Bicycle' as the third StrSubstNo argument, matching the value actually asserted.
Suggested change
Assert.AreEqual('Bicycle', PurchaseLine.Description, StrSubstNo(MockDataMismatchErr, PurchaseLine.FieldCaption(Description), PurchaseLine.TableCaption(), Item."No.", PurchaseLine.Description));
Assert.AreEqual('Bicycle', PurchaseLine.Description, StrSubstNo(MockDataMismatchErr, PurchaseLine.FieldCaption(Description), PurchaseLine.TableCaption(), 'Bicycle', PurchaseLine.Description));

Agent judgement — not directly backed by a BCQuality knowledge article.

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

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 Integration GitHub request for Integration area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant