Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var UNECEUnitMap = map[Unit]string{ UnitPiece: "H87", UnitGram: "GRM", UnitKilogram: "KGM", UnitMetricTon: "TNE", UnitMetre: "MTR", UnitCentimetre: "CMT", UnitMillimetre: "MMT", UnitCentilitres: "CLT", UnitLitre: "LTR", UnitSquareMetre: "MTK", UnitCubicMetre: "MTQ", UnitKilometre: "KMT", UnitWatt: "WTT", UnitKilowatt: "KWT", UnitKilowattHour: "KWH", UnitDay: "DAY", UnitHour: "HUR", UnitMinute: "MIN", UnitSecond: "SEC", UnitBag: "XBG", UnitBox: "XBX", UnitBin: "XBI", UnitCase: "XCS", UnitTub: "XTB", UnitRoll: "XRO", UnitCan: `XCA`, UnitTray: "XDS", UnitCarton: "XCT", UnitCylinder: "XCY", UnitBarrel: "XBA", UnitJerrican: "XJY", UnitBottle: "XBO", UnitCarboy: "XCO", UnitDemijohn: "XDJ", UnitCanister: "XCI", UnitPackage: "XPK", UnitBunch: "XBH", UnitPallet: "XPX", UnitReel: "XRL", UnitSack: "XSA", UnitSheet: "XST", UnitEnvelope: "XEN", }
UNECEUnitMap defines the conversion of GOBL Unit Codes into UN/ECE recommended units.
var UNTDID4451NoteKeyMap = map[NoteKey]string{ NoteKeyGoods: "AAA", NoteKeyDangerousGoods: "AAC", NoteKeyAck: "AAE", NoteKeyRate: "AAF", NoteKeyLegal: "ABY", NoteKeyReason: "ACD", NoteKeyDispute: "ACE", NoteKeyCustomer: "CUR", NoteKeyCustoms: "CUS", NoteKeyGlossary: "ACZ", NoteKeyGeneral: "AAI", NoteKeyHandling: "HAN", NoteKeyPrice: "AAK", NoteKeyLoading: "LOI", NoteKeyPackaging: "PKG", NoteKeyPayment: "PMT", NoteKeyPriority: "PRI", NoteKeyRegulatory: "REG", NoteKeySafety: "SAF", NoteKeyShipLine: "SLR", NoteKeySupplier: "SUR", NoteKeyTransport: "TRA", NoteKeyDelivery: "DEL", NoteKeyQuarantine: "QIN", NoteKeyTax: "TXD", }
UNTDID4451NoteKeyMap used to convert note codes into their official representation.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct { UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"` Label string `json:"label,omitempty" jsonschema:"title=Label,description=Useful identifier, such as home, work, etc."` PostOfficeBox string `` /* 137-byte string literal not displayed */ Number string `json:"num,omitempty" jsonschema:"title=Number,description=House or building number in the street."` Floor string `json:"floor,omitempty" jsonschema:"title=Floor,description=Floor number within the building."` Block string `json:"block,omitempty" jsonschema:"title=Block,description=Block number within the building."` Door string `json:"door,omitempty" jsonschema:"title=Door,description=Door number within the building."` Street string `json:"street,omitempty" jsonschema:"title=Street,description=Fist line of street."` StreetExtra string `json:"street_extra,omitempty" jsonschema:"title=Extended Street,description=Additional street address details."` Locality string `json:"locality" jsonschema:"title=Locality,description=The village, town, district, or city."` Region string `json:"region" jsonschema:"title=Region,description=Province, County, or State."` Code string `json:"code,omitempty" jsonschema:"title=Code,description=Post or ZIP code."` Country l10n.Code `json:"country,omitempty" jsonschema:"title=Country,description=ISO country code."` Coordinates *Coordinates `` /* 165-byte string literal not displayed */ Meta Meta `json:"meta,omitempty" jsonschema:"title=Meta"` }
Address defines a globally acceptable set of attributes that describes a postal or fiscal address. Attribute names loosly based on the xCard file format.
type Code ¶ added in v0.27.0
type Code string
Code represents a string used to uniquely identify the data we're looking at. We use "code" instead of "id", to reenforce the fact that codes should be more easily set and used by humans within definitions than IDs or UUIDs. Codes are standardised so that when validated they must contain between 2 and 6 inclusive upper-case letters or numbers.
func (Code) In ¶ added in v0.27.0
In returns true if the code's value matches one of those in the provided array.
func (Code) JSONSchema ¶ added in v0.27.0
func (Code) JSONSchema() *jsonschema.Schema
JSONSchema provides a representation of the struct for usage in Schema.
type Coordinates ¶
type Coordinates struct { Latitude float64 `json:"lat,omitempty" jsonschema:"title=Latitude,description=Decimal latitude coordinate."` Longitude float64 `json:"lon,omitempty" jsonschema:"title=Longitude,description=Decimal longitude coordinate."` W3W string `json:"w3w,omitempty" jsonschema:"title=What 3 Words,description=Text coordinates compose of three words."` Geohash string `json:"geohash,omitempty" jsonschema:"title=Geohash,description=Single string coordinate based on geohash standard."` }
Coordinates describes an exact geographical location in the world. We provide support for a set of different options beyond regular latitude and longitude.
type Email ¶
type Email struct { // Unique identity code UUID *uuid.UUID `json:"uuid,omitempty"` // Identifier for the email. Label string `json:"label,omitempty" jsonschema:"title=Label"` // Electronic mailing address. Address string `json:"addr" jsonschema:"title=Address"` // Additional fields. Meta Meta `json:"meta,omitempty" jsonschema:"title=Meta"` }
Email describes the electronic mailing details.
type Inbox ¶ added in v0.26.0
type Inbox struct { // Unique ID. Useful if inbox is stored in a database. UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"` // Type of inbox being defined. Key Key `json:"key" jsonschema:"title=Key"` // Role assigned to this inbox that may be relevant for the consumer. Role Key `json:"role,omitempty" jsonschema:"title=Role"` // Human name for the inbox. Name string `json:"name,omitempty" jsonschema:"title=Name"` // Actual Code or ID that identifies the Inbox. Code string `json:"code"` }
Inbox is used to store data about a connection with a service that is responsible for potentially receiving copies of GOBL envelopes or other document formats defined locally.
type Item ¶
type Item struct { // Unique identify of this item independent of the Supplier IDs UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"` // Primary reference code that identifies this item. Additional codes can be provided in the 'codes' field. Ref string `json:"ref,omitempty" jsonschema:"title=Ref"` // Brief name of the item Name string `json:"name"` // Detailed description Description string `json:"desc,omitempty"` // Currency used for the item's price. Currency string `json:"currency,omitempty" jsonschema:"title=Currency"` // Base price of a single unit to be sold. Price num.Amount `json:"price" jsonschema:"title=Price"` // Free-text unit of measure. Unit Unit `json:"unit,omitempty" jsonschema:"title=Unit"` // List of additional codes, IDs, or SKUs which can be used to identify the item. The should be agreed upon between supplier and customer. Codes []*ItemCode `json:"codes,omitempty" jsonschema:"title=Codes"` // Country code of where this item was from originally. Origin l10n.Code `json:"origin,omitempty" jsonschema:"title=Country of Origin"` // Additional meta information that may be useful Meta Meta `json:"meta,omitempty" jsonschema:"title=Meta"` }
Item is used to describe a single product or service. Minimal usage implies just adding a name and price, more complete usage consists of adding descriptions, supplier IDs, SKUs, dimensions, etc.
A set of additional code, ID, or SKU can be included in the `codes` property. Each `ItemCode` can be defined with an optional type agreed upon between the supplier and customer. For general purpose use, the Item's `Ref` property is much easier to use.
We recommend setting prices with the item's "net" value, without tax, unless the document you're building supports the `price_includes_tax` option included in the `bill.Invoice` definition for example.
type ItemCode ¶ added in v0.1.0
type ItemCode struct { // Local or human reference for the type of code the value // represents. Label string `json:"label,omitempty" jsonschema:"title=Label"` // The item code's value. Value string `json:"value" jsonschema:"title=Value"` }
ItemCode contains a value and optional label property that means additional codes can be added to an item.
type Key ¶ added in v0.27.0
type Key string
Key is used to define an ID or code that more closely represents a human name. The objective is to make it easier to define constants that can be re-used more easily.
const ( DocumentKeyCompany Key = "" // Tax Authority DocumentKeyPassport Key = "passport" // A passport document DocumentKeyNational Key = "national" // National ID Card or similar DocumentKeyPermit Key = "permit" // Residential permit DocumentKeyOther Key = "other" // Something else )
Main DocumentCode definitions.
const KeyEmpty Key = ""
KeyEmpty is used when no key is available.
func (Key) JSONSchema ¶ added in v0.27.0
func (Key) JSONSchema() *jsonschema.Schema
JSONSchema provides a representation of the struct for usage in Schema.
type Meta ¶
Meta defines a structure for data about the data being defined. Typically would be used for adding additional IDs or specifications not already defined or required by the base structure.
GOBL is focussed on ensuring the recipient has everything they need, as such, meta should only be used for data that may be used by intermediary conversion processes that should not be needed by the end-user.
We need to always use strings for values so that meta-data is easy to convert into other formats, such as protobuf which has strict type requirements.
type Name ¶
type Name struct { // Unique identity code UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"` // What the person would like to be called Alias string `json:"alias,omitempty" jsonschema:"title=Alias"` // Additional prefix to add to name, like Mrs. or Mr. Prefix string `json:"prefix,omitempty" jsonschema:"title=Prefix"` // Person's given or first name Given string `json:"given" jsonschema:"title=Given"` // Middle names or initials Middle string `json:"middle,omitempty" jsonschema:"title=Middle"` // Second or Family name. Surname string `json:"surname" jsonschema:"title=Surname"` // Additional second of family name. Surname2 string `json:"surname2,omitempty" jsonschema:"title=Second Surname"` // Titles to include after the name. Suffix string `json:"suffix,omitempty" jsonschema:"title=Suffix"` // Any additional useful data. Meta Meta `json:"meta,omitempty" jsonschema:"title=Meta"` }
Name represents what a human is called. This is a complex subject, see this w3 article for some insights: https://www.w3.org/International/questions/qa-personal-names
type Note ¶ added in v0.13.0
type Note struct { // Key specifying subject of the text Key NoteKey `json:"key,omitempty" jsonschema:"title=Key"` // Code used for additional data that may be required to identify the note. Code string `json:"code,omitempty" jsonschema:"title=Code"` // Source of this note, especially useful when auto-generated. Src string `json:"src,omitempty" jsonschema:"title=Source"` // The contents of the note Text string `json:"text" jsonschema:"title=Text"` }
Note represents a free text of additional information that may be added to a document.
type NoteKey ¶ added in v0.20.0
type NoteKey string
NoteKey contains a code for the type of note.
const ( NoteKeyGoods NoteKey = "goods" // Goods Description NoteKeyPayment NoteKey = "payment" // Terms of Payment NoteKeyLegal NoteKey = "legal" // Legal or regulatory information NoteKeyDangerousGoods NoteKey = "dangerous-goods" // Dangerous goods additional information NoteKeyAck NoteKey = "ack" // Acknowledgement Description NoteKeyRate NoteKey = "rate" // Rate additional information NoteKeyReason NoteKey = "reason" // Reason NoteKeyDispute NoteKey = "dispute" // Dispute NoteKeyCustomer NoteKey = "customer" // Customer remarks NoteKeyGlossary NoteKey = "glossary" // Glossary NoteKeyCustoms NoteKey = "customs" // Customs declaration information NoteKeyGeneral NoteKey = "general" // General information NoteKeyHandling NoteKey = "handling" // Handling instructions NoteKeyPackaging NoteKey = "packaging" // Packaging information NoteKeyLoading NoteKey = "loading" // Loading instructions NoteKeyPrice NoteKey = "price" // Price conditions NoteKeyPriority NoteKey = "priority" // Priority information NoteKeyRegulatory NoteKey = "regulatory" // Regulatory information NoteKeySafety NoteKey = "safety" // Safety Instructions NoteKeyShipLine NoteKey = "ship-line" // Ship Line NoteKeySupplier NoteKey = "supplier" // Supplier remarks NoteKeyTransport NoteKey = "transport" // Transportation information NoteKeyDelivery NoteKey = "delivery" // Delivery Information NoteKeyQuarantine NoteKey = "quarantine" // Quarantine Information NoteKeyTax NoteKey = "tax" // Tax declaration )
Predefined list of supported note keys based on the UNTDID 4451 list of text subject qualifiers. We've picked the ones which we think are most useful, but if you require an additional code, please send a pull request.
func (NoteKey) UNTDID4451 ¶ added in v0.20.0
UNTDID4451 returns the official type code, or "NA" if none is set.
type Party ¶
type Party struct { // Internal ID used to identify the party inside a document. ID string `json:"id,omitempty" jsonschema:"title=ID"` // Unique identity code UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"` // The entity's legal ID code used for tax purposes. They may have other numbers, but we're only interested in those valid for tax purposes. TaxID *TaxIdentity `json:"tax_id,omitempty" jsonschema:"title=Tax Identity"` // Legal name or representation of the organization. Name string `json:"name" jsonschema:"title=Name"` // Alternate short name. Alias string `json:"alias,omitempty" jsonschema:"title=Alias"` // Details of physical people who represent the party. People []*Person `json:"people,omitempty" jsonschema:"title=People"` // Digital inboxes used for forwarding electronic versions of documents Inboxes []*Inbox `json:"inboxes,omitempty" jsonschema:"title=Inboxes"` // Regular post addresses for where information should be sent if needed. Addresses []*Address `json:"addresses,omitempty" jsonschema:"title=Postal Addresses"` // Electronic mail addresses Emails []*Email `json:"emails,omitempty" jsonschema:"title=Email Addresses"` // Regular telephone numbers Telephones []*Telephone `json:"telephones,omitempty" jsonschema:"title=Telephone Numbers"` // Additional registration details about the company that may need to be included in a document. Registration *Registration `json:"registration,omitempty" jsonschema:"title=Registration"` // Any additional semi-structured information that does not fit into the rest of the party. Meta Meta `json:"meta,omitempty" jsonschema:"title=Meta"` }
Party represents a person or business entity.
type Person ¶
type Person struct { // Internal ID used to identify the person inside a document. ID string `json:"id,omitempty" jsonschema:"title=ID"` // Unique identity code UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"` // Complete details on the name of the person Name Name `json:"name" jsonschema:"title=Name"` // What they do within an organization Role string `json:"role,omitempty" jsonschema:"title=Role"` // Electronic mail addresses that belong to the person. Emails []*Email `json:"emails,omitempty" jsonschema:"title=Email Addresses"` // Regular phone or mobile numbers Telephones []*Telephone `json:"telephones,omitempty" jsonschema:"title=Telephone Numbers"` // Data about the data. Meta Meta `json:"meta,omitempty" jsonschema:"title=Meta"` }
Person represents a human, and how to contact them electronically.
type Registration ¶ added in v0.1.0
type Registration struct { UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"` Office string `json:"office,omitempty" jsonschema:"title=Office"` Book string `json:"book,omitempty" jsonschema:"title=Book"` Volume string `json:"volume,omitempty" jsonschema:"title=Volume"` Sheet string `json:"sheet,omitempty" jsonschema:"title=Sheet"` Section string `json:"section,omitempty" jsonschema:"title=Section"` Page string `json:"page,omitempty" jsonschema:"title=Page"` Entry string `json:"entry,omitempty" jsonschema:"title=Entry"` }
Registration is used in countries that require additional information to be associated with a company usually related to a specific registration office. The definition found here is based on the details required for spain. If your country requires additional fields, please let us know.
type TaxIdentity ¶ added in v0.20.0
type TaxIdentity struct { // Unique universal identity code. UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"` // ISO country code for Where the tax identity was issued. Country l10n.Code `json:"country" jsonschema:"title=Country Code"` // Where inside a country the Tax ID was issued, if required. Locality l10n.Code `json:"locality,omitempty" jsonschema:"title=Locality Code"` // What is the source document of this tax identity. Document Key `json:"document,omitempty" jsonschema:"title=Document Type Key"` // Tax identity Code Code string `json:"code,omitempty" jsonschema:"title=Code"` // Additional details that may be required. Meta Meta `json:"meta,omitempty" jsonschema:"title=Meta"` }
TaxIdentity stores the details required to identify an entity for tax purposes.
func (*TaxIdentity) Validate ¶ added in v0.20.0
func (id *TaxIdentity) Validate() error
Validate checks to ensure the tax ID contains all the required fields. The check the value itself is in the expected format according to the country, you'll need to use the region packages directly. See also the region `ValidateTaxID` method.
type Telephone ¶
type Telephone struct { // Unique identity code UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"` // Identifier for this number. Label string `json:"label,omitempty" jsonschema:"title=Label"` // The number to be dialed in ITU E.164 international format. Number string `json:"num" jsonschema:"title=Number"` }
Telephone describes what is expected for a telephone number.
type Unit ¶ added in v0.20.0
type Unit string
Unit is used to represent standard unit types.
const ( // Default empty value is a "piece" UnitPiece Unit = `` // Measurement units UnitGram Unit = `g` UnitKilogram Unit = `kg` UnitMetricTon Unit = `t` UnitMetre Unit = `m` UnitCentimetre Unit = `cm` UnitMillimetre Unit = `mm` UnitKilometre Unit = `km` UnitInch Unit = `in` UnitSquareMetre Unit = `m2` UnitCubicMetre Unit = `m3` UnitCentilitres Unit = `cl` UnitLitre Unit = `l` UnitWatt Unit = `w` UnitKilowatt Unit = `kw` UnitKilowattHour Unit = `kwh` UnitDay Unit = `day` UnitSecond Unit = `s` UnitHour Unit = `h` UnitMinute Unit = `min` // Presentation Unit Codes UnitBag Unit = `bag` UnitBox Unit = `box` UnitBin Unit = `bin` UnitCan Unit = `can` UnitTub Unit = `tub` UnitCase Unit = `case` UnitTray Unit = `tray` UnitPortion Unit = `portion` // non-standard (src: ES) UnitDozen Unit = `dozen` // non-standard (src: ES) UnitRoll Unit = `roll` UnitCarton Unit = `carton` UnitCylinder Unit = `cylinder` UnitBarrel Unit = `barrel` UnitJerrican Unit = `jerrican` UnitCarboy Unit = `carboy` UnitDemijohn Unit = `demijohn` UnitBottle Unit = `bottle` UnitSixPack Unit = `6pack` // non-standard (src: ES) UnitCanister Unit = `canister` UnitPackage Unit = `pkg` UnitBunch Unit = `bunch` UnitTetraBrik Unit = `tetrabrik` // non-standard (src: ES) UnitPallet Unit = `pallet` UnitReel Unit = `reel` UnitSack Unit = `sack` UnitSheet Unit = `sheet` UnitEnvelope Unit = `envelope` )
Set of common units based on UN/ECE recommendation 20 and 21. Some local formats may define additional non-standard codes which may be added. There are so many different unit codes in the world, that it's impractical to try and define them all, this is thus a selection of which we think are the most useful.