Skip to content

[PEPPOL] Add PEPPOL SE localization: Swedish organisation number for endpoints under scheme 0007#8646

Open
Franco111000 wants to merge 9 commits into
microsoft:mainfrom
Franco111000:fix/7723-se-peppol-endpoint-orgno
Open

[PEPPOL] Add PEPPOL SE localization: Swedish organisation number for endpoints under scheme 0007#8646
Franco111000 wants to merge 9 commits into
microsoft:mainfrom
Franco111000:fix/7723-se-peppol-endpoint-orgno

Conversation

@Franco111000

@Franco111000 Franco111000 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

What and why

Swedish PEPPOL BIS 3.0 documents fail at the access point because the supplier/customer electronic address (cbc:EndpointID) and the cac:PartyLegalEntity/cbc:CompanyID are emitted as the full 14-character Swedish VAT number (for example SE733078715601) under schemeID="0007". Scheme 0007 is SE:ORGNR, which per PEPPOL-COMMON-R049 must be exactly the 10-digit Swedish organisation number (7330787156).

Per review feedback, the fix is implemented as a new PEPPOL SE localization app (src/Apps/SE/PeppolSE), following the PEPPOL DE pattern, and the earlier changes to the shared W1 PEPPOL codeunit are fully reverted:

  • PEPPOL 3.0 Format enum extension adds PEPPOL 3.0 - SE Sales and PEPPOL 3.0 - SE Service, binding the PEPPOL Party Info Provider to a new PEPPOL30 SE Party Info codeunit (standard W1 validation and iterator are reused).
  • The SE party info provider delegates every method to the standard PEPPOL30 implementation and post-processes only four of them: the endpoint identifiers are reduced to the 10-digit organisation number when the emitted schemeID is 0007, and the legal entity identifiers when the party's Country/Region VAT Scheme is 0007. GLN setups (0088), Denmark (0184), and Swedish parties registered under EAS 9955 (SE:VAT, where the full VAT is correct) are untouched by construction. cac:PartyTaxScheme/cbc:CompanyID (BT-31/BT-48) keeps the full VAT number.
  • New PEPPOL 3.0 Setup records default to the SE formats on insert, mirroring PEPPOL DE. Existing setups keep their configured format; an install/upgrade step re-defaulting existing SE tenants can be added if preferred.
  • A PEPPOL SE Tests app covers the provider through the enum interface dispatch, plus a posted sales invoice XML export.

Note: for a blank bill-to country the country scheme falls back to the company's country, which is the same fallback the W1 implementation already uses to emit the endpoint schemeID, so the value stays consistent with the declared scheme.

Linked work

Fixes #7723

How I validated

  • Unit tests through the SE format dispatch: supplier and customer EndpointID and PartyLegalEntity/CompanyID return 7330787156 under scheme 0007
  • Regression test: an SE party under scheme 9955 keeps the full VAT (not stripped)
  • Test: PartyTaxScheme/CompanyID keeps the full VAT
  • Test: a newly created PEPPOL 3.0 Setup defaults to the SE formats
  • End-to-end test: a PEPPOL BIS 3.0 sales invoice export asserts both endpoints and the preserved PartyTaxScheme
  • Relied on PR CI for compilation and the full test run (this repo builds via AL-Go)

Risk and compatibility

  • The shared W1 PEPPOL app is unchanged in this PR; every other country is byte-for-byte unaffected.
  • The SE behaviour only activates when the SE formats are selected in PEPPOL 3.0 Setup (defaulted for new setups in the SE localization).
  • No schema, table, or API changes.

PEPPOL BIS 3.0 scheme 0007 (SE:ORGNR) requires the 10-digit Swedish
organisation number, but the EndpointID and PartyLegalEntity CompanyID
carried the full 14-char VAT (SE...01), which access points reject
(PEPPOL-COMMON-R049). Extract the organisation number for SE parties
whose Country/Region VAT Scheme is 0007, leaving the PartyTaxScheme VAT
identifier and all other countries unchanged. Add SE coverage to the
PEPPOL BIS billing tests.
@Franco111000 Franco111000 requested a review from a team as a code owner June 17, 2026 09:59
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork needs-approval Workflow runs require maintainer approval to start labels Jun 17, 2026
Comment thread src/Apps/W1/PEPPOL/App/src/Common/PEPPOL30Impl.Codeunit.al Outdated
Comment thread src/Apps/W1/PEPPOL/App/src/Common/PEPPOL30Impl.Codeunit.al Outdated
@github-actions github-actions Bot removed the needs-approval Workflow runs require maintainer approval to start label Jun 18, 2026
@JesperSchulz JesperSchulz added the Finance GitHub request for Finance area label Jun 18, 2026
The new Swedish organisation-number branches used else-if, which AA0018
rejects. Split them so the if starts its own line, and document the
keep-only-digits extraction in GetSwedishOrgNo.
@Franco111000

Franco111000 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Pushed b4b5c7604 addressing the review feedback and the failing build:

  • Split the new Swedish organisation-number branches so each if starts its own line (the build was red on AA0018); this is purely stylistic and the logic is unchanged.
  • Documented the digit-extraction step in GetSwedishOrgNo (per the inline suggestion).
  • Merged the latest main.

Also replied inline on the silent-fallback point.

@github-actions github-actions Bot added the needs-approval Workflow runs require maintainer approval to start label Jun 22, 2026
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Copilot PR Review

Iteration 3 · Outcome: completed

All sub-skills ran; al-privacy-review found no domain-matching worklist candidates (no-knowledge) and al-ui-review found no page/UI files in the diff (not-applicable). No sub-skill produced findings at or above the Medium/minor severity floor; the self-review cross-cutting pass produced no candidate clearing the precision bar.

Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630

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

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

Findings produced by the Copilot CLI agent against BCQuality at 822cae1b2771ac25f665f73369f69093bd4fd630. Reply 👎 on any inline comment to flag false positives.

@github-actions github-actions Bot removed the needs-approval Workflow runs require maintainer approval to start label Jun 29, 2026
@AndersLarsenMicrosoft AndersLarsenMicrosoft added Integration GitHub request for Integration area and removed Finance GitHub request for Finance area labels Jul 1, 2026
…ort test

Validating a changed Country/Region Code on Company Information clears
City, Post Code and County, so the SE export test failed the PEPPOL
company checks with "City must have a value". Set City and Post Code
after switching the company to SE. Test-only change.
@Franco111000

Copy link
Copy Markdown
Contributor Author

Pushed 6fd2805c06 fixing the failing test ExportXml_PEPPOL_BIS3_SalesInvoice_SEOrgNo: validating the changed Country/Region Code on Company Information clears City and Post Code, so the PEPPOL company checks failed with "City must have a value". The test helper now restores both after switching the company to SE. Test-only change; the app code is untouched.

@github-actions github-actions Bot added the needs-approval Workflow runs require maintainer approval to start label Jul 2, 2026
@JesperSchulz JesperSchulz self-assigned this Jul 7, 2026
@JesperSchulz JesperSchulz added the Linked Issue is linked to a Azure Boards work item label Jul 7, 2026
@github-actions github-actions Bot removed the needs-approval Workflow runs require maintainer approval to start label Jul 7, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Jul 7, 2026
@Groenbech96

Copy link
Copy Markdown
Contributor

I think the proper design is to create swedish localization, that implemetns the GetAccountingSupplierPartyInfo.
There are examples of this for Norway, BE, and other countries.

So should be fairly trivial change. Long term better design choice.

@Groenbech96 Groenbech96 left a comment

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.

See my comment.

…ndpoints

Move the Swedish organisation number handling from the shared W1 PEPPOL
codeunit into a new PEPPOL SE localization app, following the PEPPOL DE
pattern. The SE party info provider delegates to the W1 implementation
and reduces endpoint and legal entity identifiers to the 10-digit
organisation number when they are emitted under scheme 0007 (SE:ORGNR),
leaving the party tax scheme VAT identifier and all other countries
untouched. Default new PEPPOL 3.0 Setup records to the SE formats, add
a PEPPOL SE test app covering the provider, and wire both apps into the
SE build project.
@Franco111000 Franco111000 requested a review from a team as a code owner July 9, 2026 09:59
@Franco111000 Franco111000 requested a review from a team as a code owner July 9, 2026 09:59
@Franco111000 Franco111000 changed the title [PEPPOL] Use Swedish organisation number for EndpointID under scheme 0007 [PEPPOL] Add PEPPOL SE localization: Swedish organisation number for endpoints under scheme 0007 Jul 9, 2026
@Franco111000

Copy link
Copy Markdown
Contributor Author

@Groenbech96 Reworked as suggested in b6c2f8f55c: the W1 changes are fully reverted and the fix now lives in a new PEPPOL SE localization app (src/Apps/SE/PeppolSE), following the PEPPOL DE pattern.

  • The SE party info provider delegates to the standard PEPPOL30 implementation and only reduces the endpoint and legal entity identifiers to the 10-digit organisation number when they are emitted under scheme 0007, so GLN setups and Swedish parties registered under EAS 9955 (SE:VAT) are untouched, and PartyTaxScheme keeps the full VAT number.
  • New PEPPOL 3.0 Setup records default to the SE formats on insert, mirroring PEPPOL DE. Existing setups keep their configured format; happy to add an install/upgrade step if you would prefer existing SE tenants to be re-defaulted.
  • Tests moved to a new PEPPOL SE Tests app, exercising the provider through the format dispatch plus a posted invoice XML export.
  • Both apps are wired into the Apps SE build project and build/projects.json; please double-check the internal-path details of the PEPPOL SE entries there, I mirrored PEPPOL DE and SE Core Tests.

The PR description is updated to match.

@github-actions github-actions Bot added Build: scripts & configs Build scripts and configuration files needs-approval Workflow runs require maintainer approval to start and removed AL: Apps (W1) Add-on apps for W1 labels Jul 9, 2026
Groenbech96
Groenbech96 previously approved these changes Jul 9, 2026

@Groenbech96 Groenbech96 left a comment

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.

Great. Maybe consider install codeunit?
To set the SE versions oon the setup table that lives in W1.

Verify App Changes validates the country project settings against the
group metadata, and the new apps were missing from groups.json. Register
PEPPOL SE and PEPPOL SE Tests with the same group memberships as
PEPPOL DE and PEPPOL Tests.
A setup record created before the PEPPOL SE app is installed never runs
the OnAfterInsert subscriber, so existing SE tenants would stay on the
W1 formats. Move an existing setup to the SE formats at install, but
only from the W1 defaults so a deliberately configured format is kept.
@Franco111000

Copy link
Copy Markdown
Contributor Author

@Groenbech96 Thanks! Both points addressed:

  • Install codeunit added in c6d2aadbde: at install it moves an existing PEPPOL 3.0 Setup to the SE formats, but only when the current value is the W1 default, so a deliberately configured format is not overridden. New setups keep being defaulted by the insert subscriber.
  • The failing Verify App Changes check was the new apps missing from build/groups.json; registered PEPPOL SE and PEPPOL SE Tests in 2ddc2a6305 with the same group memberships as PEPPOL DE and PEPPOL Tests (the country settings generator now validates clean locally).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build: scripts & configs Build scripts and configuration files From Fork Pull request is coming from a fork Integration GitHub request for Integration area Linked Issue is linked to a Azure Boards work item needs-approval Workflow runs require maintainer approval to start

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Can't send e-documents with Peppol BIS 3.0 invoices from SE localization

4 participants