oioubl

package module
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GOBL ⬅️➡️ Danish OIOUBL 2.1

Danish OIOUBL 2.1 support for GOBL, for invoices and credit notes exchanged over the NemHandel network. Invoice Responses and Reminders are a planned follow-up, not yet implemented here.

Released under the Apache 2.0 LICENSE, Copyright 2026 Invopop S.L..

Lint Test Go Go Report Card codecov GoDoc Latest Tag Ask DeepWiki

This module is two things: a GOBL tax addon (dk-oioubl-v2) carrying the OIOUBL rules and extensions, and a converter in both directions built on gobl.ubl's EN 16931 base.

  • ConvertInvoice(env) — GOBL → OIOUBL 2.1
  • Parse(data) / ParseInvoice(data) — OIOUBL 2.1 → GOBL

Both target the OIOUBL 2.1 profile, schematron v1.17.2.

The addon

dk-oioubl-v2 Requires the EN 16931 addon and layers OIOUBL on top:

  • Tax categories — VAT is restricted to what OIOUBL's taxcategoryid-1.1 codelist supports: standard-rated, zero-rated and reverse-charge. There is no exempt category on the wire, so an exempt VAT key is rejected rather than relabelled — state the supply as zero-rated instead. Excise and other non-VAT duties are modelled as charges (as in EN 16931 / Peppol BIS), not tax categories, and carry a SKAT duty code extension.
  • Payment — the OIOUBL payment channel is derived from the payment means: IBAN, DK:GIRO, DK:FIK, DK:BANK and DK:NEMKONTO. Each shape has its own account rules (Giro's 7-8 digit account, FIK's 8-character creditor account, the 4-digit registration number a domestic transfer needs), and NemKonto rejects account details outright, since it resolves the payee's registered account.
  • Participants — parties are routed by their participant identifier, the same URI Peppol uses: the scheme, the code naming the OIOUBL register and the party's code (iso6523-actorid-upis::0184:12345674 for a CVR, ::0198:DK12345674 for an SE number, ::0088:5798009883735 for a GLN). The prefix follows the ICD rather than the XML: 0184 is the bare CVR, which the converter prefixes with DK on the way out, while the DK of 0198 is part of the identifier. Every register OIOUBL accepts has a code in this scheme, retired ones such as DK:CPR (9901) and DK:VANS (9905) included, so an endpoint has one shape and only this one. The earlier DK:CVR:12345674 spelling is still read, as are the codes Peppol replaced when it re-coded a register. Precedence: a party already addressed by a participant identifier keeps it as its one address, whatever register it names; otherwise an inbox naming an OIOUBL register becomes the endpoint; otherwise a Danish tax identity derives the CVR one. Endpoints on other networks, such as mailto:, are kept alongside.
  • Invoice / credit note — the document type must be an OIOUBL-supported code (325/380/393, or 381 for a credit note), the customer must resolve to an endpoint for NemHandel to route to, every line needs a VAT category and a non-zero quantity, and ordering is required once any line carries an order reference. The customer also needs a contact identifier, since OIOUBL requires a Contact with an ID on the customer: the first person's identity code, or failing that the first email, which the OIOUBL contact guideline recommends as the identifier.

Rules the OIOUBL schematron already enforces are generally left to it rather than duplicated here; the addon aims at the paths a sender realistically hits.

The addon registers extensions, normalizers and validation rules into GOBL's global registry, and lives in its own module so only projects handling Danish documents take on its weight.

The UBL document structs and their XML mapping come from gobl.ubl, reused here as type Invoice ubl.Invoice. There is no OIOUBL context in gobl.ubl — the outbound converter asks it for a plain EN 16931 document (ubl.WithContext(ubl.ContextEN16931)) and does the OIOUBL-specific shaping in this module, so gobl.ubl stays free of anything Danish.

Usage

Import the addon for its side effects to register it, then declare the dk-oioubl-v2 addon on a GOBL document:

import _ "github.com/invopop/gobl.dk.oioubl/addon"
$schema: "https://gobl.org/draft-0/bill/invoice"
$regime: "DK"
$addons:
  - "dk-oioubl-v2"
supplier:
  name: "Eksempel A/S"
  tax_id:
    country: "DK"
    code: "12345674"
  # endpoints may be omitted: the addon derives
  # iso6523-actorid-upis::0184:12345674 from the tax identity.

See examples/ for complete invoice and credit note documents with their calculated envelopes.

Documentation

Overview

Package oioubl converts GOBL documents to OIOUBL 2.1, the Danish NemHandel profile of UBL 2.1. Generic UBL plumbing is shared with gobl.ubl; OIOUBL-specifics live here alongside the dk-oioubl addon subpackage.

Index

Constants

View Source
const (
	CustomizationID = "OIOUBL-2.1"
	ProfileID       = "urn:www.nesubl.eu:profiles:profile5:ver2.0"
)
View Source
const (
	VESIDInvoice    = "dk.oioubl:invoice:1.17.2"
	VESIDCreditNote = "dk.oioubl:credit-note:1.17.2"
)
View Source
const Version = ubl.Version

Variables

View Source
var Addons = []cbc.Key{addon.V2}
View Source
var ErrUnknownDocumentType = ubl.ErrUnknownDocumentType

ErrUnknownDocumentType is the base's error, re-exported so callers can match what Parse returns without importing gobl.ubl.

View Source
var ErrUnsupportedDocumentType = fmt.Errorf("unsupported document type")

Functions

func Bytes

func Bytes(in any) ([]byte, error)

Bytes renders a converted document as indented XML.

func BytesCompact

func BytesCompact(in any) ([]byte, error)

BytesCompact renders a converted document as XML without indentation.

func Convert

func Convert(env *gobl.Envelope) (any, error)

Convert turns a GOBL envelope into an OIOUBL 2.1 document.

func GetVESID

func GetVESID(inv *bill.Invoice) string

GetVESID names the schematron to validate a document against.

func Parse added in v0.0.5

func Parse(data []byte) (any, error)

Parse reads an OIOUBL document off the wire.

Types

type BinaryAttachment added in v0.0.5

type BinaryAttachment = ubl.BinaryAttachment

BinaryAttachment is the base's type, re-exported so callers do not have to import gobl.ubl just to read what ExtractBinaryAttachments hands back.

type Invoice

type Invoice ubl.Invoice

Invoice is the OIOUBL view of a UBL invoice: a defined type over ubl.Invoice, not an alias, so OIOUBL's own methods attach to it without inheriting gobl.ubl's generic Convert.

func ConvertInvoice

func ConvertInvoice(env *gobl.Envelope) (*Invoice, error)

ConvertInvoice is Convert for callers that already know the document is an invoice.

func ParseInvoice added in v0.0.5

func ParseInvoice(data []byte) (*Invoice, error)

ParseInvoice is Parse for callers that already know it is an invoice.

func (*Invoice) Convert added in v0.0.5

func (ui *Invoice) Convert() (*gobl.Envelope, error)

Convert strips the document back to plain EN16931, runs the generic parse, then adds the OIOUBL details the base has no field for.

func (*Invoice) ExtractBinaryAttachments added in v0.0.5

func (ui *Invoice) ExtractBinaryAttachments() []BinaryAttachment

ExtractBinaryAttachments returns the files embedded in the document: the base's, which scans AdditionalDocumentReference, plus any embedded under ContractDocumentReference, where OIOUBL's own samples attach the contract.

Directories

Path Synopsis
Package addon provides extensions and validations for the Danish OIOUBL 2.1 standard used on the NemHandel e-invoicing network.
Package addon provides extensions and validations for the Danish OIOUBL 2.1 standard used on the NemHandel e-invoicing network.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址