internal

package
v0.100.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package internal is used for internal option configuration.

Index

Constants

View Source
const DateTimeSeparator = " · "

DateTimeSeparator is used to join the formatted date and time when rendering a cal.DateTime value.

Variables

View Source
var CalFormatterISO = CalFormatter{
	Date:     "2006-01-02",
	Time:     "15:04",
	Location: time.UTC,
}

CalFormatterISO is the default formatter for dates and times based on the recommended ISO 8601 formatting.

Functions

func WithOptions

func WithOptions(ctx context.Context, opts *Opts) context.Context

WithOptions prepares the context with the options to use.

Types

type CalFormatter

type CalFormatter struct {
	Date     string // Golang date format for dates, e.g. `02/01/2006`
	Time     string // Golang time format for times, e.g. `15:04`
	Location *time.Location
}

CalFormatter defines a simple date and time formatter. Date and time formats are configured independently; date-time values are rendered by composing the two with a separator.

type Document added in v0.68.0

type Document interface {
	Extract() any
	GetType() cbc.Key
	GetSupplier() *org.Party
	GetCustomer() *org.Party
	GetIssueDate() cal.Date
	GetSeries() cbc.Code
	GetCode() cbc.Code
	GetRegime() tax.Regime
	GetCurrency() currency.Code
	GetExt() tax.Extensions
	GetPreceding() []*org.DocumentRef
}

Document is the interface to handle GOBL documents generically.

func DocumentFor added in v0.68.0

func DocumentFor(doc any) Document

DocumentFor returns a Document interface for the given document.

func ExtractDocumentFrom added in v0.68.0

func ExtractDocumentFrom(env *gobl.Envelope) Document

ExtractDocumentFrom returns a Document interface for the given envelope.

type Opts

type Opts struct {
	// Locale is the language code to use for rendering.
	Locale i18n.Code
	Logo *org.Image
	// Notes to add to the document footer instead of the notes included
	// in the envelope.
	Notes string
	// NumFormatter is used to format numbers.
	NumFormatter *num.Formatter

	// CurrencyTemplate is used to format currency amounts with their units,
	// and overrides those from the number formatter.
	CurrencyTemplate string
	// ThousandsSeparator overrides the thousands separator from the number formatter.
	ThousandsSeparator string
	// DecimalMark overrides the decimal mark from the number formatter.
	DecimalMark string
	// NegativeTemplate overrides the negative template from the number formatter.
	NegativeTemplate string

	// CalFormatter is used to format calendar dates and times.
	CalFormatter *CalFormatter
	// EmbedAssets when try ensures that all the stylesheet or script files
	// are contained inside the HTML output. This is useful for PDF output
	// or to avoid additional requests.
	EmbedAssets bool
	// Layout indicates the Layout used in te document
	Layout layout.Code
	// Void indicates if the document should be rendered as void
	Void bool
	// Sandbox indicates if the document should be rendered in sandbox mode
	Sandbox bool
	// Watermark indicates the watermark to use in the document
	Watermark string
	// Label indicates the label to use in the document
	Label string
	// AdjustmentMode indicates that invoice types credit-note and debit-note
	// or similar should be rendered as adjustments to the original invoice, as
	// required in certain jurisdictions.
	AdjustmentMode bool
}

Opts defines configuration options used internally with the current document. Putting this amount of information inside a context is normally an anti-pattern in Go, but saves a huge amount of effort when writing components.

func Options

func Options(ctx context.Context) *Opts

Options provides the current options in the context.

Directories

Path Synopsis
Package gallery builds examples/index.html: scan examples/*.json, locale hints, embed catalog.html.
Package gallery builds examples/index.html: scan examples/*.json, locale hints, embed catalog.html.

Jump to

Keyboard shortcuts

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