finvoice

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 29 Imported by: ? 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 ⬅️➡️ Finnish Finvoice 3.0

Finnish Finvoice 3.0 support for GOBL: the fi-finvoice-v3 addon plus converters to and from the XML format used on the Finnish e-invoicing network.

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 (fi-finvoice-v3) in the addon package, with the Finvoice rules and the e-invoice operator extension, and a converter in both directions in the root package:

  • Convert(env, opts...) writes Finvoice 3.0 from a GOBL invoice or credit note, as any like the sibling converters; ConvertInvoice returns the *Invoice itself.
  • Parse(data) reads Finvoice of any version into GOBL.

Usage

Import the addon for its side effects to register it, then declare the fi-finvoice-v3 addon on a GOBL document:

import _ "github.com/invopop/gobl.fi.finvoice/addon"
$schema: "https://gobl.org/draft-0/bill/invoice"
$regime: "FI"
$addons:
  - "fi-finvoice-v3"
supplier:
  name: "Myyjä Oy"
  tax_id:
    country: "FI"
    code: "76543212"
  endpoints:
    - uri: "iso6523-actorid-upis::0216:003776543212"
customer:
  name: "Ostaja Oy"
  tax_id:
    country: "FI"
    code: "45678907"
  endpoints:
    - uri: "iso6523-actorid-upis::0216:003745678907"
  ext:
    fi-finvoice-operator: "003700020002"
payment:
  instructions:
    key: "credit-transfer+sepa"
    ref: "RF18539007547034"
    credit_transfer:
      - iban: "FI21 1234 5600 0007 85" # normalized to FI2112345600000785
        bic: "NDEAFIHH"
  terms:
    due_dates:
      - date: "2026-08-31"
        percent: "100%"

Convert and parse:

import finvoice "github.com/invopop/gobl.fi.finvoice"

doc, err := finvoice.Convert(env,
	finvoice.WithSenderOperator("003700010001"),
	finvoice.WithInvoiceURL("PDF", "file://invoice.pdf"),
)
data, err := finvoice.Bytes(doc)

parsed, err := finvoice.Parse(data)

The documents under examples/ are converted and validated against the Finvoice 3.0 schema in schemas/ by the test suite, and the Finvoice files under test/data/parse/ are read back into GOBL. Run go test . -update to regenerate the golden files after a change.

The addon

Finvoice conforms to EN 16931, so the addon Requires the EN 16931 addon and only layers the Finvoice-specific tightening on top, principally the data needed to build the EpiDetails payment block, which is mandatory on every Finvoice invoice, credit notes included:

  • Customer: must be present and named (BuyerOrganisationName).
  • E-invoice addresses: supplier and customer each need one, an ISO 6523 endpoint (iso6523-actorid-upis::0216:003745678907 for an OVT code) or, failing that, a coded inbox. The receiver's routes the document and the sender's is where the operator delivers replies; a document missing either is accepted by the operator and then never delivered.
  • Operators: fi-finvoice-operator takes two to thirty-five letters and digits, the shape of an OVT code or a BIC.
  • Identifiers: values Finvoice cannot hold whole are refused, since a cut identifier points at nothing. The invoice number with its series and each preceding document number take up to 20 characters, ordering references and item references up to 70, a legal identity code and the payment reference up to 35, an e-invoice address code 2 to 35, and the address's scheme up to 10. Each kind of ordering reference takes one document, as each Finvoice element holds one identifier, and an invoice cites one preceding document.
  • Currency: at most two decimals, since the payment order's EpiInstructedAmount takes exactly two and would otherwise be rounded.
  • VAT rates: at most three decimals, the most RowVatRatePercent and VatRatePercent hold.
  • Payment details: required unconditionally, not only when an amount is due as in EN 16931 (BR-CO-25).
  • Credit transfer: payment instructions must use the credit-transfer key (extensions such as credit-transfer+sepa are accepted) and the first credit transfer entry must carry an IBAN (EpiAccountID), validated with the ISO 7064 mod 97-10 checksum.
  • Payment reference: required (EpiReference).
  • Due date: payment terms must include exactly one dated entry, for the whole amount (EpiDateOptionDate); the payment order takes one date, and this module does not write instalments.
  • Exemption reasons: one code and one note per VAT category, across lines, discounts and charges, since the breakdown gives one VatExemptionReasonCode and one VatFreeText per category.
  • Attachments: refused. Finvoice carries attachments as separate attachment messages through the forwarding service (guidelines §16), which this module does not produce; a sender's own link in the invoice may only point at generic material (§15.1).
  • Delivery period: both dates are required, as DeliveryPeriodDetails takes both.
  • Delivery receiver: needs a name and an address with a town and post code, which DeliveryPartyDetails requires.
  • BIC (EpiBfiIdentifier, SellerBic): recommended on the payment order's account but not required, matching the schema and current SEPA practice; required on any further account, which Finvoice lists with its BIC. A further account may be a BBAN.

IBANs and payment references are normalized to their machine form: grouping spaces are removed and IBANs are upper-cased.

An invoice gives each party one electronic address, and on a Finnish invoice that is the OVT (iso6523-actorid-upis::0216:<OVT>). When a supplier, customer or other party carries an OVT endpoint, the addon keeps the first one and drops the party's other iso6523-actorid-upis endpoints, so a party record that also holds a Business ID or GLN address still builds (EN 16931 ORG-PARTY-04). Endpoints with other schemes and inboxes are left alone, and parties without an OVT are not changed.

The addon declares one extension, fi-finvoice-operator: the identifier of the e-invoice operator (intermediator) that serves a party's e-invoice address, quoted alongside that address. That is an operator's OVT code such as 003700010001, or a bank's BIC such as NDEAFIHH. A Finnish address may be registered with several operators, and the operator decides where an invoice is delivered, so set it on the party that receives the message: the customer, or the supplier of a self-billed invoice.

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

Writing Finvoice

Convert adds the addon to an invoice that does not declare it, validates the invoice, rounds it to the currency, and writes a Finvoice 3.0 document. E-invoice addresses come from the parties' ISO 6523 endpoints, or their coded inboxes, as the addon requires; the Y-tunnus and VAT number from the tax identity, and the payment order from the payment instructions the addon requires.

  • Transmission details. The supplier sends an invoice to the customer, and the customer sends a self-billed invoice to the supplier, as GOBL's own FromEndpoint and ToEndpoint read it. MessageTransmissionDetails is written when the receiving party has fi-finvoice-operator. The sender's endpoint becomes FromIdentifier and the receiver's ToIdentifier, and the receiver's operator ToIntermediator. FromIntermediator is the operator the message is sent through, given with WithSenderOperator; without it the conversion fails. Option values the format cannot hold, an operator that is not 2 to 35 letters and digits, a message identifier outside 2 to 48 characters or a URL over 512, are refused before writing. A receiver with no operator gets no transmission details, and routing is left to the receiving operator's own address tables. Either way the e-invoice addresses are also written as SellerOrganisationUnitNumber and BuyerOrganisationUnitNumber, where operators put them on delivery.
  • Message identity. MessageIdentifier is the invoice UUID and MessageTimeStamp the time of conversion; WithMessageID and WithMessageTime override them, and a resend of the same invoice should have a fresh identifier.
  • Payment reference. EpiRemittanceInfoIdentifier is written with scheme SPY for a Finnish reference number and ISO for an RF creditor reference, only when its check digits hold; any other reference is in EpiReference alone.
  • Links. WithInvoiceURL(name, url) adds an InvoiceUrlNameText and InvoiceUrlText pair, such as the reference to the invoice's PDF image an operator's intake expects alongside the XML.
  • Credit notes are written as INV02 with negative amounts, the sign convention of the format; the parser flips them back whenever the total is zero or negative, as the guidelines require of a credit note.
  • Preceding document. Its number is written as OriginalInvoiceNumber, without its date. OriginalInvoiceDate and OriginalInvoiceReference are optional in the schema, and some Finvoice 3.0 intakes refuse a message carrying them, so neither is written. Without OriginalInvoiceReference there is room for one preceding document only, so the addon allows one. The parser reads both elements.
  • Invoice type. InvoiceTypeCode is INV01, INV02, INV06 or INV07 from the GOBL type and tags, and InvoiceTypeCodeUN the UNTDID 1001 code the EN 16931 addon records.
  • Texts are fitted, identifiers are not. The addon refuses identifiers too long for their element before conversion. Names and notes are spread over as many elements as they need; a note longer than one element comes back as several. Streets, VAT notes and payment terms take the three, three and two lines the schema allows, and are cut beyond them. An email or web address too long for its element, and a postal address whose town or post code is missing or a single character, are left out, as is any optional text of one character, since Finvoice's text elements take two or more; party names of one character are refused by the addon for the same reason. So is a discount or charge percentage finer than the three decimals Finvoice takes, with its base; the amount beside it is written as usual, so the totals stay exact.
  • Prices. A unit price finer than the five decimals Finvoice takes is written per a base quantity (UnitPriceBaseQuantity) of ten, a hundred or more, so it stays exact. A line with several discounts writes them all as RowProgressiveDiscountDetails, as the Finvoice correlation table does.
  • Row VAT amounts are not written. GOBL works the tax out per rate, so per-row VAT amounts would not add up to the breakdown; the optional RowVatAmount and RowAmount are left to it.

Reading Finvoice

Parse reads any Finvoice version, since the schema is backwards compatible and operators deliver whatever the sender produced, often 1.3. The forwarding service's SOAP frame in front of the document is read for its routing when the document has no MessageTransmissionDetails, and the charset the XML declaration names (UTF-8, ISO-8859-15, ISO-8859-1, Windows-1252) is honoured. A file holding more than one Finvoice message is refused.

Parse maps the document faithfully. It refuses only what it cannot map at all: an unknown document type, currency or VAT code, a malformed value, or an amount it reads in another currency. Where Finvoice leaves the truth to the sender, it takes the sender's figure, the row total and the roundoff, and records any difference as rounding. Everything else, including whether the document agrees with itself, is left to GOBL's validation of the result. The result declares fi-finvoice-v3:

  • E-invoice addresses come from the transmission details or the SOAP frame when there are any, else from the organisation unit numbers. An address given without a scheme is read as an OVT code, an IBAN or a Y-tunnus by its shape, each only when its check digits hold, and any other shape is kept as an inbox code. Operators are set on fi-finvoice-operator of each party.
  • VAT numbers are kept, spaced or hyphenated ones too, and validation reports a wrong one.
  • Only invoices are read: INV01, INV02, INV06 and INV07. Quotations, orders, reminders and the other messages of the code list, and copies and cancellations of an invoice, are refused with ErrUnsupportedDocumentType.
  • The GOBL type comes from InvoiceTypeCodeUN when given and mapped, else from InvoiceTypeCode; the schema allows any UNTDID 1001 code there, and one with no GOBL type leaves the Finvoice code to decide. A party identifier that repeats the Y-tunnus in the VAT number is folded into it unless it carries another scheme. Amounts are turned positive only for a credit note with a negative total, so INV02 with 380 reads as an invoice with a negative total, as an EN 16931 invoice may have.
  • A row made of sub-rows (SubInvoiceRow) is a subtotal for display, which the guidelines keep out of the totals, so it is left out. So is SpecificationDetails, the sector-specific itemisation shown with the invoice (§12). Consumer e-invoices and direct payment (§4, §5) are bank flows outside this module's scope; their documents still parse as invoices.
  • Links (InvoiceUrlText and its name) are left out. In a delivery they name the PDF image that arrives beside the XML; otherwise they point at a sender's generic material or a bank's display service (§15). None of them is invoice data.
  • A row that states its quantity in several units is read at the one in the unit price's unit, or the first when the price names none.
  • The row total is the authority for a line, as the guidelines add the totals up from it: the unit price is read per its base quantity, and when the quantity times that price still misses the row total, the price the row total implies is used, with the fewest decimals that give it. A discount or charge percentage is kept only when it gives the amount stated beside it; otherwise the amount is kept alone.
  • VAT categories come from RowVatCode, or from the VAT breakdown line with the same rate; a breakdown with two categories at one rate, or two exemption reason codes in one category, cannot be told apart and is refused, as is a code the breakdown gives that GOBL does not know. A zero rate that nothing names is read as zero-rated, and a positive one as standard. Exemption reason codes become cef-vatex codes and reason texts become tax notes, a text the breakdown repeats becoming one note. A row's free text stands in as the reason only when the breakdown gives neither a code nor a text, since row texts are free comments.
  • The currency comes from the total's currency identifier and must be one GOBL knows. A GOBL invoice has one currency, so an amount labelled with another is refused.
  • The stated total is kept: the roundoff amount is read, and a remaining difference with the calculated total of up to a subunit per row, plus one for the totals, is recorded as rounding. A larger difference means the rows were misread and is refused. GOBL works the VAT out per rate, so its VAT total can differ from the document's by that rounding.
  • The due date is the payment order's. Payment terms that repeat with different dates are instalments, which the payment order has no room for, so they are refused.
  • The payment means code sets the payment key; codes GOBL has no key for are read as the credit transfer a Finvoice payment order describes.
  • Units are read from the UN/ECE code when GOBL knows it, else from the free-text unit when it is a GOBL unit key or a Finnish word for one (kpl, h, pv, kk); anything else becomes the generic unit, as does t, which is an hour or a tonne.
  • Rows with nothing to price, such as headings, subtotal texts and rows with only a quantity, become notes on the invoice.

A document converted to Finvoice and parsed back yields the same GOBL content, except for what the format cannot hold the way GOBL does. Series and code become one invoice number, a street number part of the street, a street continued on a second line a street extra, and a missing street the town or PO box that stood in for it. An advance loses its description, notes their key, VAT rates become their percentage, and charges and discounts their UNTDID codes, not GOBL keys. The preceding document comes back without its date. Without transmission details, addresses lose their scheme and are read back by shape. The sending party gains the operator it was sent through, and the parsed document uses currency rounding.

Sources

Documentation

Overview

Package finvoice converts GOBL invoices and credit notes to Finvoice 3.0 and back. The fi-finvoice-v3 addon in the addon subpackage holds the validation rules and the e-invoice operator extension the converter reads.

Index

Constants

View Source
const Version = "3.0"

Version is the Finvoice version written.

Variables

View Source
var (
	// ErrUnsupportedDocumentType is returned when the envelope holds anything
	// other than an invoice, or a Finvoice message that is not one.
	ErrUnsupportedDocumentType = errors.New("unsupported document type")
	// ErrSenderOperatorRequired is returned when the receiving party names
	// its operator but the conversion was given no sender operator to route
	// from.
	ErrSenderOperatorRequired = errors.New("sender operator is required to route to the receiver's operator")
)

Functions

func Bytes

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

Bytes returns the XML of a document returned by Convert.

func Convert

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

Convert turns a GOBL envelope into a Finvoice document, an *Invoice for an invoice or credit note. The fi-finvoice-v3 addon is added when the invoice does not declare it, and the invoice must validate under it.

func Parse

func Parse(data []byte) (*gobl.Envelope, error)

Parse reads a Finvoice document of any version into a GOBL envelope declaring the fi-finvoice-v3 addon. A transport frame in front of the document is read for its routing and the charset the declaration names is honoured.

Types

type Account

type Account struct {
	Value  string `xml:",chardata"`
	Scheme string `xml:"IdentificationSchemeName,attr,omitempty"`
}

Account is a bank account or bank identifier with its scheme (IBAN, BBAN, BIC, SPY, ISO).

type Amount

type Amount struct {
	Value    string `xml:",chardata"`
	Currency string `xml:"AmountCurrencyIdentifier,attr"`
}

Amount is a monetary value with its currency.

type BuyerCommunicationDetails

type BuyerCommunicationDetails struct {
	Phone string `xml:"BuyerPhoneNumberIdentifier,omitempty"`
	Email string `xml:"BuyerEmailaddressIdentifier,omitempty"`
}

BuyerCommunicationDetails holds the buyer contact's phone and email.

type BuyerPartyDetails

type BuyerPartyDetails struct {
	Identifier  *Identifier                `xml:"BuyerPartyIdentifier,omitempty"`
	Name        []string                   `xml:"BuyerOrganisationName"`
	TradingName string                     `xml:"BuyerOrganisationTradingName,omitempty"`
	TaxCode     string                     `xml:"BuyerOrganisationTaxCode,omitempty"`
	Address     *BuyerPostalAddressDetails `xml:"BuyerPostalAddressDetails,omitempty"`
}

BuyerPartyDetails identifies the buyer.

type BuyerPostalAddressDetails

type BuyerPostalAddressDetails struct {
	StreetName    []string `xml:"BuyerStreetName"`
	TownName      string   `xml:"BuyerTownName"`
	PostCode      string   `xml:"BuyerPostCodeIdentifier"`
	Subdivision   string   `xml:"BuyerCountrySubdivision,omitempty"`
	CountryCode   string   `xml:"CountryCode,omitempty"`
	PostOfficeBox string   `xml:"BuyerPostOfficeBoxIdentifier,omitempty"`
}

BuyerPostalAddressDetails is the buyer's postal address.

type ChargeDetails

type ChargeDetails struct {
	ReasonText      string  `xml:"ReasonText,omitempty"`
	ReasonCode      string  `xml:"ReasonCode,omitempty"`
	Percent         string  `xml:"Percent,omitempty"`
	Amount          *Amount `xml:"Amount,omitempty"`
	BaseAmount      *Amount `xml:"BaseAmount,omitempty"`
	VatCategoryCode string  `xml:"VatCategoryCode,omitempty"`
	VatRatePercent  string  `xml:"VatRatePercent,omitempty"`
}

ChargeDetails is a document-level charge.

type Date

type Date struct {
	Value  string `xml:",chardata"`
	Format string `xml:"Format,attr"`
}

Date is a calendar date in CCYYMMDD form.

type DeliveryDetails

type DeliveryDetails struct {
	Date   *Date                  `xml:"DeliveryDate,omitempty"`
	Period *DeliveryPeriodDetails `xml:"DeliveryPeriodDetails,omitempty"`
}

DeliveryDetails holds when the goods were delivered.

type DeliveryPartyDetails

type DeliveryPartyDetails struct {
	Identifier *Identifier                   `xml:"DeliveryPartyIdentifier,omitempty"`
	Name       []string                      `xml:"DeliveryOrganisationName"`
	TaxCode    string                        `xml:"DeliveryOrganisationTaxCode,omitempty"`
	Address    *DeliveryPostalAddressDetails `xml:"DeliveryPostalAddressDetails"`
}

DeliveryPartyDetails identifies who receives the goods.

type DeliveryPeriodDetails

type DeliveryPeriodDetails struct {
	StartDate *Date `xml:"StartDate"`
	EndDate   *Date `xml:"EndDate"`
}

DeliveryPeriodDetails is the delivery period.

type DeliveryPostalAddressDetails

type DeliveryPostalAddressDetails struct {
	StreetName    []string `xml:"DeliveryStreetName"`
	TownName      string   `xml:"DeliveryTownName"`
	PostCode      string   `xml:"DeliveryPostCodeIdentifier"`
	Subdivision   string   `xml:"DeliveryCountrySubdivision,omitempty"`
	CountryCode   string   `xml:"CountryCode,omitempty"`
	PostOfficeBox string   `xml:"DeliveryPostofficeBoxIdentifier,omitempty"`
}

DeliveryPostalAddressDetails is the delivery address.

type DiscountDetails

type DiscountDetails struct {
	FreeText        string  `xml:"FreeText,omitempty"`
	ReasonCode      string  `xml:"ReasonCode,omitempty"`
	Percent         string  `xml:"Percent,omitempty"`
	Amount          *Amount `xml:"Amount,omitempty"`
	BaseAmount      *Amount `xml:"BaseAmount,omitempty"`
	VatCategoryCode string  `xml:"VatCategoryCode,omitempty"`
	VatRatePercent  string  `xml:"VatRatePercent,omitempty"`
}

DiscountDetails is a document-level allowance.

type EpiBeneficiaryPartyDetails

type EpiBeneficiaryPartyDetails struct {
	NameAddress string  `xml:"EpiNameAddressDetails,omitempty"`
	AccountID   Account `xml:"EpiAccountID"`
}

EpiBeneficiaryPartyDetails identifies the payee and its account.

type EpiBfiPartyDetails

type EpiBfiPartyDetails struct {
	Identifier *Account `xml:"EpiBfiIdentifier,omitempty"`
	Name       string   `xml:"EpiBfiName,omitempty"`
}

EpiBfiPartyDetails identifies the beneficiary's bank.

type EpiCharge

type EpiCharge struct {
	Value  string `xml:",chardata"`
	Option string `xml:"ChargeOption,attr"`
}

EpiCharge says who bears the bank charges.

type EpiDetails

type EpiDetails struct {
	Identification     EpiIdentificationDetails     `xml:"EpiIdentificationDetails"`
	Party              EpiPartyDetails              `xml:"EpiPartyDetails"`
	PaymentInstruction EpiPaymentInstructionDetails `xml:"EpiPaymentInstructionDetails"`
}

EpiDetails is the payment order: reference, beneficiary account and the amount and date to pay.

type EpiIdentificationDetails

type EpiIdentificationDetails struct {
	Date      *Date  `xml:"EpiDate"`
	Reference string `xml:"EpiReference"`
}

EpiIdentificationDetails dates and references the payment order.

type EpiPartyDetails

type EpiPartyDetails struct {
	BFI         EpiBfiPartyDetails         `xml:"EpiBfiPartyDetails"`
	Beneficiary EpiBeneficiaryPartyDetails `xml:"EpiBeneficiaryPartyDetails"`
}

EpiPartyDetails names the beneficiary's bank and account.

type EpiPaymentInstructionDetails

type EpiPaymentInstructionDetails struct {
	InstructionCode          string               `xml:"EpiInstructionCode,omitempty"`
	RemittanceInfoIdentifier *RemittanceReference `xml:"EpiRemittanceInfoIdentifier,omitempty"`
	InstructedAmount         Amount               `xml:"EpiInstructedAmount"`
	Charge                   EpiCharge            `xml:"EpiCharge"`
	DateOptionDate           *Date                `xml:"EpiDateOptionDate"`
	PaymentMeansCode         string               `xml:"EpiPaymentMeansCode,omitempty"`
	PaymentMeansText         string               `xml:"EpiPaymentMeansText,omitempty"`
}

EpiPaymentInstructionDetails says what to pay, by when, and under which reference.

type Identifier

type Identifier struct {
	Value    string `xml:",chardata"`
	SchemeID string `xml:"SchemeID,attr,omitempty"`
}

Identifier is a party, address or item identifier with an optional ISO 6523 scheme.

type Invoice

type Invoice struct {
	XMLName xml.Name `xml:"Finvoice"`
	Version string   `xml:"Version,attr"`

	Transmission *MessageTransmissionDetails `xml:"MessageTransmissionDetails,omitempty"`

	Seller                       *SellerPartyDetails         `xml:"SellerPartyDetails"`
	SellerOrganisationUnitNumber string                      `xml:"SellerOrganisationUnitNumber,omitempty"`
	SellerContactPersonName      string                      `xml:"SellerContactPersonName,omitempty"`
	SellerCommunication          *SellerCommunicationDetails `xml:"SellerCommunicationDetails,omitempty"`
	SellerInformation            *SellerInformationDetails   `xml:"SellerInformationDetails,omitempty"`

	Buyer                       *BuyerPartyDetails         `xml:"BuyerPartyDetails"`
	BuyerOrganisationUnitNumber string                     `xml:"BuyerOrganisationUnitNumber,omitempty"`
	BuyerContactPersonName      string                     `xml:"BuyerContactPersonName,omitempty"`
	BuyerCommunication          *BuyerCommunicationDetails `xml:"BuyerCommunicationDetails,omitempty"`

	DeliveryParty   *DeliveryPartyDetails `xml:"DeliveryPartyDetails,omitempty"`
	DeliveryDetails *DeliveryDetails      `xml:"DeliveryDetails,omitempty"`

	InvoiceDetails *InvoiceDetails `xml:"InvoiceDetails"`
	Rows           []*InvoiceRow   `xml:"InvoiceRow"`
	Epi            *EpiDetails     `xml:"EpiDetails"`

	InvoiceURLNames []string `xml:"InvoiceUrlNameText,omitempty"`
	InvoiceURLs     []string `xml:"InvoiceUrlText,omitempty"`
}

Invoice is the Finvoice message of an invoice or credit note.

func ConvertInvoice

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

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

func (*Invoice) Bytes

func (d *Invoice) Bytes() ([]byte, error)

Bytes renders the message as indented UTF-8 XML.

type InvoiceDetails

type InvoiceDetails struct {
	TypeCode   InvoiceTypeCode `xml:"InvoiceTypeCode"`
	TypeCodeUN string          `xml:"InvoiceTypeCodeUN,omitempty"`
	TypeText   string          `xml:"InvoiceTypeText"`
	OriginCode string          `xml:"OriginCode"`

	InvoiceNumber            string                      `xml:"InvoiceNumber"`
	InvoiceDate              *Date                       `xml:"InvoiceDate"`
	OriginalInvoiceNumber    string                      `xml:"OriginalInvoiceNumber,omitempty"`
	OriginalInvoiceDate      *Date                       `xml:"OriginalInvoiceDate,omitempty"`
	OriginalInvoiceReference []*OriginalInvoiceReference `xml:"OriginalInvoiceReference,omitempty"`
	PeriodStartDate          *Date                       `xml:"InvoicingPeriodStartDate,omitempty"`
	PeriodEndDate            *Date                       `xml:"InvoicingPeriodEndDate,omitempty"`

	SellerReference     string `xml:"SellerReferenceIdentifier,omitempty"`
	OrderIdentifier     string `xml:"OrderIdentifier,omitempty"`
	OrderDate           *Date  `xml:"OrderDate,omitempty"`
	AgreementIdentifier string `xml:"AgreementIdentifier,omitempty"`
	AgreementDate       *Date  `xml:"AgreementDate,omitempty"`
	BuyerReference      string `xml:"BuyerReferenceIdentifier,omitempty"`
	ProjectReference    string `xml:"ProjectReferenceIdentifier,omitempty"`

	RowsTotalVatExcludedAmount      *Amount `xml:"RowsTotalVatExcludedAmount,omitempty"`
	DiscountsTotalVatExcludedAmount *Amount `xml:"DiscountsTotalVatExcludedAmount,omitempty"`
	ChargesTotalVatExcludedAmount   *Amount `xml:"ChargesTotalVatExcludedAmount,omitempty"`
	TotalVatExcludedAmount          *Amount `xml:"InvoiceTotalVatExcludedAmount,omitempty"`
	TotalVatAmount                  *Amount `xml:"InvoiceTotalVatAmount,omitempty"`
	TotalVatIncludedAmount          *Amount `xml:"InvoiceTotalVatIncludedAmount"`
	TotalRoundoffAmount             *Amount `xml:"InvoiceTotalRoundoffAmount,omitempty"`
	PaidAmount                      *Amount `xml:"InvoicePaidAmount,omitempty"`

	VatSpecifications []*VatSpecificationDetails `xml:"VatSpecificationDetails,omitempty"`
	FreeText          []string                   `xml:"InvoiceFreeText,omitempty"`
	PaymentTerms      []*PaymentTermsDetails     `xml:"PaymentTermsDetails,omitempty"`
	Discounts         []*DiscountDetails         `xml:"DiscountDetails,omitempty"`
	Charges           []*ChargeDetails           `xml:"ChargeDetails,omitempty"`
	TenderReference   string                     `xml:"TenderReference,omitempty"`
}

InvoiceDetails holds the document header: type, numbers, dates, references, totals, VAT breakdown, terms, and document-level discounts and charges.

type InvoiceRow

type InvoiceRow struct {
	ArticleIdentifier  string      `xml:"ArticleIdentifier,omitempty"`
	ArticleName        string      `xml:"ArticleName,omitempty"`
	ArticleDescription string      `xml:"ArticleDescription,omitempty"`
	EANCode            *Identifier `xml:"EanCode,omitempty"`

	DeliveredQuantity []*Quantity `xml:"DeliveredQuantity,omitempty"`
	OrderedQuantity   *Quantity   `xml:"OrderedQuantity,omitempty"`
	InvoicedQuantity  []*Quantity `xml:"InvoicedQuantity,omitempty"`
	StartDate         *Date       `xml:"StartDate,omitempty"`
	EndDate           *Date       `xml:"EndDate,omitempty"`

	UnitPriceAmount       *UnitAmount `xml:"UnitPriceAmount,omitempty"`
	UnitPriceNetAmount    *UnitAmount `xml:"UnitPriceNetAmount,omitempty"`
	UnitPriceBaseQuantity *Quantity   `xml:"UnitPriceBaseQuantity,omitempty"`

	RowPositionIdentifier string `xml:"RowPositionIdentifier,omitempty"`
	OriginalInvoiceNumber string `xml:"OriginalInvoiceNumber,omitempty"`

	FreeText []string `xml:"RowFreeText,omitempty"`

	DiscountPercent     string                           `xml:"RowDiscountPercent,omitempty"`
	DiscountAmount      *Amount                          `xml:"RowDiscountAmount,omitempty"`
	DiscountBaseAmount  *Amount                          `xml:"RowDiscountBaseAmount,omitempty"`
	DiscountTypeCode    string                           `xml:"RowDiscountTypeCode,omitempty"`
	DiscountTypeText    string                           `xml:"RowDiscountTypeText,omitempty"`
	ProgressiveDiscount []*RowProgressiveDiscountDetails `xml:"RowProgressiveDiscountDetails,omitempty"`
	Charges             []*RowChargeDetails              `xml:"RowChargeDetails,omitempty"`

	VatRatePercent    string  `xml:"RowVatRatePercent,omitempty"`
	VatCode           string  `xml:"RowVatCode,omitempty"`
	VatAmount         *Amount `xml:"RowVatAmount,omitempty"`
	VatExcludedAmount *Amount `xml:"RowVatExcludedAmount,omitempty"`
	Amount            *Amount `xml:"RowAmount,omitempty"`

	// SubRows marks a subtotal row, which is read only to be left out.
	SubRows []struct{} `xml:"SubInvoiceRow,omitempty"`
}

InvoiceRow is one invoice line.

type InvoiceTypeCode

type InvoiceTypeCode struct {
	Value    string `xml:",chardata"`
	CodeList string `xml:"CodeListAgencyIdentifier,attr,omitempty"`
}

InvoiceTypeCode is the Finvoice invoice type code with its code list.

type MessageDetails

type MessageDetails struct {
	Identifier              string `xml:"MessageIdentifier"`
	Timestamp               string `xml:"MessageTimeStamp"`
	RefToMessageIdentifier  string `xml:"RefToMessageIdentifier,omitempty"`
	SpecificationIdentifier string `xml:"SpecificationIdentifier,omitempty"`
}

MessageDetails identifies the message itself.

type MessageReceiverDetails

type MessageReceiverDetails struct {
	Identifier    Identifier `xml:"ToIdentifier"`
	Intermediator string     `xml:"ToIntermediator"`
}

MessageReceiverDetails holds the receiver's e-invoice address and operator.

type MessageSenderDetails

type MessageSenderDetails struct {
	Identifier    Identifier `xml:"FromIdentifier"`
	Intermediator string     `xml:"FromIntermediator"`
}

MessageSenderDetails holds the sender's e-invoice address and operator.

type MessageTransmissionDetails

type MessageTransmissionDetails struct {
	Sender   MessageSenderDetails   `xml:"MessageSenderDetails"`
	Receiver MessageReceiverDetails `xml:"MessageReceiverDetails"`
	Message  MessageDetails         `xml:"MessageDetails"`
}

MessageTransmissionDetails routes the message: who sends it, who receives it, and through which operators.

type Option

type Option func(*options)

Option configures a conversion.

func WithInvoiceURL

func WithInvoiceURL(name, url string) Option

WithInvoiceURL adds a named link to the document, such as the reference to the invoice's PDF image that an operator's intake expects.

func WithMessageID

func WithMessageID(id string) Option

WithMessageID sets the message identifier in the transmission details, which the invoice's UUID otherwise provides; the schema takes 2 to 48 characters.

func WithMessageTime

func WithMessageTime(t time.Time) Option

WithMessageTime sets the timestamp in the transmission details, which is otherwise the time of conversion.

func WithSenderOperator

func WithSenderOperator(id string) Option

WithSenderOperator names the e-invoice operator the message is sent through, written as the sender's intermediator in the transmission details; the schema takes 2 to 35 characters.

type OriginalInvoiceReference

type OriginalInvoiceReference struct {
	InvoiceNumber string `xml:"InvoiceNumber,omitempty"`
	InvoiceDate   *Date  `xml:"InvoiceDate,omitempty"`
}

OriginalInvoiceReference points at a further preceding document.

type PaymentTermsDetails

type PaymentTermsDetails struct {
	FreeText []string `xml:"PaymentTermsFreeText,omitempty"`
	DueDate  *Date    `xml:"InvoiceDueDate,omitempty"`
}

PaymentTermsDetails describes when the invoice is due.

type Quantity

type Quantity struct {
	Value      string `xml:",chardata"`
	UnitCode   string `xml:"QuantityUnitCode,attr,omitempty"`
	UnitCodeUN string `xml:"QuantityUnitCodeUN,attr,omitempty"`
}

Quantity is a number of units, with the unit as free text and, when known, as its UN/ECE code.

type RemittanceReference

type RemittanceReference struct {
	Value  string `xml:",chardata"`
	Scheme string `xml:"IdentificationSchemeName,attr"`
}

RemittanceReference is the payment reference with its scheme, SPY or ISO.

type RowChargeDetails

type RowChargeDetails struct {
	ReasonText string  `xml:"ReasonText,omitempty"`
	ReasonCode string  `xml:"ReasonCode,omitempty"`
	Percent    string  `xml:"Percent,omitempty"`
	Amount     *Amount `xml:"Amount,omitempty"`
	BaseAmount *Amount `xml:"BaseAmount,omitempty"`
}

RowChargeDetails is a charge on a line.

type RowProgressiveDiscountDetails

type RowProgressiveDiscountDetails struct {
	Percent    string  `xml:"RowDiscountPercent,omitempty"`
	Amount     *Amount `xml:"RowDiscountAmount,omitempty"`
	BaseAmount *Amount `xml:"RowDiscountBaseAmount,omitempty"`
	TypeCode   string  `xml:"RowDiscountTypeCode,omitempty"`
	TypeText   string  `xml:"RowDiscountTypeText,omitempty"`
}

RowProgressiveDiscountDetails is one of several discounts on a line.

type SellerAccountDetails

type SellerAccountDetails struct {
	AccountID Account `xml:"SellerAccountID"`
	BIC       Account `xml:"SellerBic"`
	Name      string  `xml:"SellerAccountName,omitempty"`
}

SellerAccountDetails is one of the seller's bank accounts.

type SellerCommunicationDetails

type SellerCommunicationDetails struct {
	Phone string `xml:"SellerPhoneNumberIdentifier,omitempty"`
	Email string `xml:"SellerEmailaddressIdentifier,omitempty"`
}

SellerCommunicationDetails holds the seller contact's phone and email.

type SellerInformationDetails

type SellerInformationDetails struct {
	Email    string                  `xml:"SellerCommonEmailaddressIdentifier,omitempty"`
	Website  string                  `xml:"SellerWebaddressIdentifier,omitempty"`
	Accounts []*SellerAccountDetails `xml:"SellerAccountDetails,omitempty"`
}

SellerInformationDetails holds the seller's general details and bank accounts.

type SellerPartyDetails

type SellerPartyDetails struct {
	Identifier  *Identifier                 `xml:"SellerPartyIdentifier,omitempty"`
	Name        []string                    `xml:"SellerOrganisationName"`
	TradingName string                      `xml:"SellerOrganisationTradingName,omitempty"`
	TaxCode     string                      `xml:"SellerOrganisationTaxCode,omitempty"`
	Address     *SellerPostalAddressDetails `xml:"SellerPostalAddressDetails,omitempty"`
}

SellerPartyDetails identifies the seller.

type SellerPostalAddressDetails

type SellerPostalAddressDetails struct {
	StreetName    []string `xml:"SellerStreetName"`
	TownName      string   `xml:"SellerTownName"`
	PostCode      string   `xml:"SellerPostCodeIdentifier"`
	Subdivision   string   `xml:"SellerCountrySubdivision,omitempty"`
	CountryCode   string   `xml:"CountryCode,omitempty"`
	PostOfficeBox string   `xml:"SellerPostOfficeBoxIdentifier,omitempty"`
}

SellerPostalAddressDetails is the seller's postal address.

type UnitAmount

type UnitAmount struct {
	Value      string `xml:",chardata"`
	Currency   string `xml:"AmountCurrencyIdentifier,attr"`
	UnitCode   string `xml:"UnitPriceUnitCode,attr,omitempty"`
	UnitCodeUN string `xml:"QuantityUnitCodeUN,attr,omitempty"`
}

UnitAmount is a unit price with its currency and optional unit.

type VatSpecificationDetails

type VatSpecificationDetails struct {
	BaseAmount          *Amount  `xml:"VatBaseAmount,omitempty"`
	RatePercent         string   `xml:"VatRatePercent,omitempty"`
	Code                string   `xml:"VatCode,omitempty"`
	RateAmount          *Amount  `xml:"VatRateAmount,omitempty"`
	FreeText            []string `xml:"VatFreeText,omitempty"`
	ExemptionReasonCode string   `xml:"VatExemptionReasonCode,omitempty"`
}

VatSpecificationDetails is one line of the VAT breakdown.

Directories

Path Synopsis
Package addon provides extensions and validations for the Finnish Finvoice 3.0 format.
Package addon provides extensions and validations for the Finnish Finvoice 3.0 format.

Jump to

Keyboard shortcuts

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