[E-Document Formats][OIOUBL] Migrate NAV PR 247162 into BCApps#9682
[E-Document Formats][OIOUBL] Migrate NAV PR 247162 into BCApps#9682Groenbech96 wants to merge 3 commits into
Conversation
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>
| OIOUBLXml: XmlDocument; | ||
| XmlNamespaces: XmlNamespaceManager; | ||
| XmlElement: XmlElement; | ||
| CommonAggregateComponentsTok: Label 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2', Locked = true; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
- 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)); |
There was a problem hiding this comment.
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.
| 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
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) — newIStructuredFormatReader.ReadIntoDraftimplementation parsing OIOUBLInvoice/CreditNoteXML 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".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)internalsVisibleToto the new OIOUBL test app.Adaptations from the NAV source
E-Document PEPPOL Utilityhelper (BCApps) instead of NAV'sEDocument XML Helper;View()uses temporary buffer records for the now-publicSetBuffer.E-Document Core Tests; NAV's duplicate format-mock files (would clash with the existing6160 "Mock"value) and NAV-onlyEng/Core/Buildregistrations 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