P1: e-invoice core — EN16931 → e-SLOG 2.0 / UBL (generate + validate)#1
Merged
Conversation
Public EN16931 core-invoice model (valibot, BT-annotated) → three outputs: - e-SLOG 2.0 (owned serializer; UN/EDIFACT-INVOIC XML, urn:eslog:2.00) - UBL / CII via @e-invoice-eu/core (model → ubl:Invoice internal JSON) - EN16931 structural validation via the lib's JSON Schema (Ajv 2019-09) Effect-native API (parseInvoice / validateEn16931 / generateEInvoice) plus a Promise boundary (createEInvoice) for non-Effect hosts. Framework-agnostic — no Medusa coupling; the medusa plugin track wraps this as a leaf dep. e-SLOG mapping grounded in the epos.si spec + cross-checked vs the MIT Media24si/eslog2 reference. 25 tests pass; tsc clean. Coverage/roadmap in ROADMAP.md (e-SLOG XSD/schematron output validation + allowances deferred). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
P1 of the fiscalization toolkit (ticket:
grunt-it/tickets/fiscalization-einvoicing-toolkit.md): the e-invoice core. A clean, EN16931-alignedInvoicedomain model → three outputs:urn:eslog:2.00). The Slovenian delta the upstream lib lacks.@e-invoice-eu/core(model →ubl:Invoiceinternal JSON → lib).Standalone + framework-agnostic, Effect-native API, with a Promise boundary (
createEInvoice) so the separate@grunt-it/medusa-plugin-si-fiscalizationtrack can wrap it as a leaf dep. No Medusa coupling.Key decision (approved by coordinator): depend-on + adapt, not fork
@e-invoice-eu/coreis WTFPL, on npm, bun-installable. We depend on it for the maintained EN16931 model + UBL/CII/Peppol/Factur-X serialization + validation, and own only the e-SLOG 2.0 serializer. Forking the upstream pnpm/NestJS monorepo would fork us off its update path — which fights the ticket's "track EN16931/Peppol rule changes via upkeep" goal.Correction surfaced during the build
e-SLOG 2.0 is not "UBL + a CIUS" — it's EN16931-compliant but has its own XSD (UN/EDIFACT INVOIC-derived). So the e-SLOG serializer is real owned work, not a thin UBL wrapper. Verdict (don't fork) unchanged and reinforced.
Architecture
src/lib/invoice/parseInvoicesrc/lib/eslog/serializeEslog) + documented EDIFACT qualifier codessrc/lib/einvoice/@e-invoice-eu/core: model → internal JSON,generateEInvoice,validateEn16931src/lib/foundation/runSafe)createEInvoice(input, { format })runs parse → (validate for ubl/cii) → generate, returning{ ok, data | error }.Grounding (compliance correctness)
e-SLOG mapping grounded in the official spec (epos.si) and cross-checked element-by-element against the MIT-licensed reference generator
Media24si/eslog2(itsinv.xmlsample). Mapping is keyed to EN16931 Business Terms throughout (document totals → MOA79/260/259/389/176/388/9, VAT breakdown →G_SG52, etc.). SI VAT EAS code9949verified against the Peppol code list.Verification
bun test→ 25 pass / 0 fail (e-SLOG segment assertions, UBL/CII generation via the lib, EN16931 validation, parse positive/negative, end-to-end pipeline).bunx tsc --noEmit→ clean.@e-invoice-eu/core+ transitive deps install and generate UBL/CII with no native-dep issues.Scope & deferrals
P1 maps the mandatory + common core. Deferred (in
ROADMAP.md): e-SLOG XSD/schematron output validation, document/line-level allowances/charges, contacts/delivery address, multiple payment means, cross-border EAS map, XAdES signature, credit-note negative-amount rules. P2 = FURS (ZOI/EOR); P3 = integration surface; P4 = service + MCP.Reviewer notes / judgment calls
@grunt-it/utility-belt) so the medusa-plugin track can install it.🤖 Generated with Claude Code