ubl

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: MIT Imports: 8 Imported by: 0

README

A Go package to create a UBL (UBL.BE) invoice for Peppol.
This is a minimal implementation for the features we need. Feel free to send a patch if you are missing something.

You can do a manual validation here: https://www.ubl.be/validator/

Example:

inv := ubl.Invoice{
    ID:           "INV-12345",
    SupplierName: "ABC Supplies Ltd",
    SupplierVat:  "BE0123456789",
    SupplierAddress: ubl.Address{
        StreetName:  "123 Supplier Street",
        CityName:    "Supplier City",
        PostalZone:  "12345",
        CountryCode: "BE",
    },
    CustomerName: "XYZ Corp",
    CustomerVat:  "BE9876543210",
    CustomerAddress: ubl.Address{
        StreetName:  "789 Customer Avenue",
        CityName:    "Customer Town",
        PostalZone:  "67890",
        CountryCode: "BE",
    },
    Iban: "9999999999",
    Bic:  "GEBABEBB",
    Note: "You get a free sticker when you pay fast",
}

inv.Lines = []ubl.InvoiceLine{
    ubl.InvoiceLine{
        Quantity:      10,
        Price:         100,
        Name:          "Product A",
        Description:   "High-quality item",
        TaxPercentage: 21.0,
    },
}

xmlBytes, err := inv.Generate()

v, err := validate.New()
defer v.Free()

err = v.ValidateBytes(xmlBytes)

os.WriteFile("invoice.xml", xmlBytes, 0644)

Build: go build -v ./...
Test: go test -v ./...

Documentation

Overview

Package ubl is a basic implementation to create a UBL Invoice.

This is needed for Peppol: https://docs.peppol.eu/poacc/billing/3.0/ Specification: https://docs.peppol.eu/poacc/billing/3.0/syntax/ubl-invoice/tree/ The result can be validated with the validate package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	StreetName  string
	CityName    string
	PostalZone  string
	CountryCode string
}

type Invoice

type Invoice struct {
	ID                 string
	SupplierName       string
	SupplierVat        string
	SupplierAddress    Address
	CustomerName       string
	CustomerVat        string
	CustomerAddress    Address
	Iban               string
	Bic                string
	Note               string
	Lines              []InvoiceLine
	PdfInvoiceFilename string
	// contains filtered or unexported fields
}

func (*Invoice) Generate

func (inv *Invoice) Generate() ([]byte, error)

type InvoiceLine

type InvoiceLine struct {
	Quantity      float64
	Price         float64
	TaxPercentage float64
	Name          string
	Description   string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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