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 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 DocumentCode ¶ added in v0.20.0
type DocumentCode string
DocumentCode is used to identify the source of the tax identification document.
const ( CompanyDocumentCode DocumentCode = "" // Tax Authority PassportDocumentCode DocumentCode = "passport" // A passport document NationalDocumentCode DocumentCode = "national" // National ID Card or similar PermitDocumentCode DocumentCode = "permit" // Residential permit OtherDocumentCode DocumentCode = "other" // Something else )
Main DocumentCode definitions.
type Email ¶
type Email struct { UUID *uuid.UUID `json:"uuid,omitempty"` Label string `json:"label,omitempty" jsonschema:"title=Label,description=Identifier for the email."` Address string `json:"addr" jsonschema:"title=Address,description=Electronic mailing address."` Meta Meta `json:"meta,omitempty" jsonschema:"title=Meta,description=Additional fields."` }
Email describes the electronic mailing details.
type Item ¶
type Item struct { // Unique identify of this item independent of the Supplier IDs UUID string `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 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 { UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID,description=Unique identity code"` Alias string `json:"alias,omitempty" jsonschema:"title=Alias,description=What the person would like to be called"` Prefix string `json:"prefix,omitempty" jsonschema:"title=Prefix"` Given string `json:"given" jsonschema:"title=Given,description=The person's given name"` Middle string `json:"middle,omitempty" jsonschema:"title=Middle,description=Middle names or initials"` Surname string `json:"surname" jsonschema:"title=Surname"` Surname2 string `json:"surname2,omitempty" jsonschema:"title=Second Surname"` Suffix string `json:"suffix,omitempty" jsonschema:"title=Suffix"` 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 { ID string `json:"id,omitempty" jsonschema:"title=ID,description=Internal ID used to identify the party inside a document."` UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID,description=Unique identity code."` TaxID *TaxIdentity `` /* 205-byte string literal not displayed */ Name string `json:"name" jsonschema:"title=Name,description=Legal name or representation of the organization."` Alias string `json:"alias,omitempty" jsonschema:"title=Alias,description=Alternate short name."` People []*Person `json:"people,omitempty" jsonschema:"title=People,description=Details of physical people who represent the party."` Addresses []*Address `` /* 145-byte string literal not displayed */ Emails []*Email `json:"emails,omitempty" jsonschema:"title=Email Addresses"` Telephones []*Telephone `json:"telephones,omitempty" jsonschema:"title=Telephone Numbers"` Registration *Registration `` /* 167-byte string literal not displayed */ Meta Meta `` /* 146-byte string literal not displayed */ }
Party represents a person or business entity.
type Person ¶
type Person struct { ID string `json:"id,omitempty" jsonschema:"title=ID,description=Internal ID used to identify the person inside a document."` UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID,description=Unique identity code"` Name Name `json:"name" jsonschema:"title=Name,description=Complete details on the name of the person"` Role string `json:"role,omitempty" jsonschema:"title=Role,description=What they do within an organization"` Emails []*Email `json:"emails,omitempty" jsonschema:"title=Email Addresses,description=Electronic mail addresses that belong to the person."` Telephones []*Telephone `json:"telephones,omitempty" jsonschema:"title=Telephone Numbers"` Meta Meta `json:"meta,omitempty" jsonschema:"title=Meta,description=Data about the data."` }
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,description=Office where the company is registered."` 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 DocumentCode `json:"document,omitempty" jsonschema:"title=Document Code"` // 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 { UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"` Label string `json:"label,omitempty" jsonschema:"title=Label,description=Identifier for this number."` Number string `json:"num" jsonschema:"title=Number,description=The number to be dialed in ITU E.164 international format."` }
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.