Documentation
¶
Overview ¶
Package org contains structures related to organization.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var RegexpPatternW3W = "" /* 370-byte string literal not displayed */
RegexpPatternW3W is a regular expression that matches a what3words address.
var UnitDefinitions = []DefUnit{ {UnitGram, "Metric grams", "GRM"}, {UnitKilogram, "Metric kilograms", "KGM"}, {UnitMetricTon, "Metric tons", "TNE"}, {UnitMillimetre, "Milimetres", "MMT"}, {UnitCentimetre, "Centimetres", "CMT"}, {UnitMetre, "Metres", "MTR"}, {UnitKilometre, "Kilometers", "KMT"}, {UnitInch, "Inches", "INH"}, {UnitFoot, "Feet", "FOT"}, {UnitSquareMetre, "Square metres", "MTK"}, {UnitCubicMetre, "Cubic metres", "MTQ"}, {UnitCentilitre, "Centilitres", "CLT"}, {UnitLitre, "Litres", "LTR"}, {UnitWatt, "Watts", "WTT"}, {UnitKilowatt, "Kilowatts", "KWT"}, {UnitKilowattHour, "Kilowatt Hours", "KWH"}, {UnitDay, "Days", "DAY"}, {UnitSecond, "Seconds", "SEC"}, {UnitHour, "Hours", "HUR"}, {UnitMinute, "Minutes", "MIN"}, {UnitPiece, "Pieces", "H87"}, {UnitItem, "Items", "EA"}, {UnitService, "Service Units", "E48"}, {UnitActivity, "Activity", "ACT"}, {UnitBag, "Bags", "XBG"}, {UnitBox, "Boxes", "XBX"}, {UnitBin, "Bins", "XBI"}, {UnitCan, "Cans", "XCA"}, {UnitTub, "Tubs", "XTB"}, {UnitCase, "Cases", "XCS"}, {UnitTray, "Trays", "XDS"}, {UnitPortion, "Portions", ""}, {UnitDozen, "Dozens", ""}, {UnitRoll, "Rolls", "XRO"}, {UnitCarton, "Cartons", "XCT"}, {UnitCylinder, "Cylinders", "XCY"}, {UnitBarrel, "Barrels", "XBA"}, {UnitJerrican, "Jerricans", "XJY"}, {UnitCarboy, "Carboys", "XCO"}, {UnitDemijohn, "Demijohn", "XDJ"}, {UnitBottle, "Bottles", "XBO"}, {UnitSixPack, "Six Packs", ""}, {UnitCanister, "Canisters", "XCI"}, {UnitPackage, "Packages", "XPK"}, {UnitBunch, "Bunches", "XBH"}, {UnitTetraBrik, "Tetra-Briks", ""}, {UnitPallet, "Pallets", "XPX"}, {UnitReel, "Reels", "XRL"}, {UnitSack, "Sacks", "XSA"}, {UnitSheet, "Sheets", "XST"}, {UnitEnvelope, "Envelopes", "XEN"}, }
UnitDefinitions describes each of the unit constants. Order is important.
Functions ¶
func HasIdentityType ¶ added in v0.55.0
func HasIdentityType(typ cbc.Code) validation.Rule
HasIdentityType provides a validation rule that will determine if at least one of the identities defined includes one with the defined type.
Types ¶
type Address ¶
type Address struct {
// Internal ID used to identify the party inside a document.
UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"`
// Useful identifier, such as home, work, etc.
Label string `json:"label,omitempty" jsonschema:"title=Label"`
// Box number or code for the post office box located at the address.
PostOfficeBox string `json:"po_box,omitempty" jsonschema:"title=Post Office Box"`
// House or building number in the street.
Number string `json:"num,omitempty" jsonschema:"title=Number"`
// Floor number within the building.
Floor string `json:"floor,omitempty" jsonschema:"title=Floor"`
// Block number within the building.
Block string `json:"block,omitempty" jsonschema:"title=Block"`
// Door number within the building.
Door string `json:"door,omitempty" jsonschema:"title=Door"`
// First line of street.
Street string `json:"street,omitempty" jsonschema:"title=Street"`
// Additional street address details.
StreetExtra string `json:"street_extra,omitempty" jsonschema:"title=Extended Street"`
// Village, town, district, or city, typically inside a region.
Locality string `json:"locality" jsonschema:"title=Locality"`
// Province, county, or state, inside a country.
Region string `json:"region,omitempty" jsonschema:"title=Region"`
// Post or ZIP code.
Code string `json:"code,omitempty" jsonschema:"title=Code"`
// ISO country code.
Country l10n.CountryCode `json:"country,omitempty" jsonschema:"title=Country"`
// When the postal address is not sufficient, coordinates help locate the address more precisely.
Coordinates *Coordinates `json:"coords,omitempty" jsonschema:"title=Coordinates"`
// Any additional semi-structure details about the address.
Meta cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`
}
Address defines a globally acceptable set of attributes that describes a postal or fiscal address. Attribute names loosely based on the xCard file format.
type Coordinates ¶
type Coordinates struct {
// Decimal latitude coordinate.
Latitude *float64 `json:"lat,omitempty" jsonschema:"title=Latitude"`
// Decimal longitude coordinate.
Longitude *float64 `json:"lon,omitempty" jsonschema:"title=Longitude"`
// What 3 Words text coordinates.
W3W string `json:"w3w,omitempty" jsonschema:"title=What 3 Words"`
// Single string coordinate based on geohash standard.
Geohash string `json:"geohash,omitempty" jsonschema:"title=Geohash"`
}
Coordinates describes an exact geographical location in the world. We provide support for a set of different options beyond regular latitude and longitude.
func (*Coordinates) LatLon ¶ added in v0.51.2
func (c *Coordinates) LatLon() (float64, float64)
LatLon provides the Latitude and Longitude values as a pair, or 0, 0 if the coordinates are not set.
func (*Coordinates) Validate ¶ added in v0.51.2
func (c *Coordinates) Validate() error
Validate checks that coordinates look okay.
func (*Coordinates) ValidateWithContext ¶ added in v0.51.2
func (c *Coordinates) ValidateWithContext(ctx context.Context) error
ValidateWithContext checks that coordinates look okay in the given context.
type DefUnit ¶ added in v0.29.0
type DefUnit struct {
// Key for the Unit
Unit Unit `json:"unit" jsonschema:"title=Unit"`
// Description of the unit
Description string `json:"description" jsonschema:"title=Description"`
// Standard UN/ECE code
UNECE cbc.Code `json:"unece" jsonschema:"title=UN/ECE Unit Code"`
}
DefUnit serves to define unit keys.
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 cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`
}
Email describes the electronic mailing details.
type Identity ¶ added in v0.37.0
type Identity struct {
// Unique identity for this identity object.
UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"`
// Optional label useful for non-standard identities to give a bit more context.
Label string `json:"label,omitempty" jsonschema:"title=Label"`
// The type of Code being represented and usually specific for
// a particular context, country, or tax regime, and cannot be used
// alongside the key.
Type cbc.Code `json:"type,omitempty" jsonschema:"title=Type"`
// The actual value of the identity code.
Code cbc.Code `json:"code" jsonschema:"title=Code"`
// Description adds details about what the code could mean or imply
Description string `json:"description,omitempty" jsonschema:"title=Description"`
// Key was previously available, but has now been migrated to extensions.
// This should not appear in schemas.
// Deprecated: Since 2023-08-25, use extensions (ext) instead.
Key cbc.Key `json:"-"`
}
Identity is used to define a code for a specific context.
func AddIdentity ¶ added in v0.54.0
AddIdentity makes it easier to add a new identity to a list and replace an existing value with a matching type.
func IdentityForType ¶ added in v0.55.0
IdentityForType helps return the identity with a matching type code.
func (*Identity) UnmarshalJSON ¶ added in v0.55.0
UnmarshalJSON overrides the default to help extract the key value which is no longer used.
type Image ¶ added in v0.35.0
type Image struct {
// Unique ID of the image
UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"`
// Label to help identify the image.
Label string `json:"label,omitempty" jsonschema:"title=Label"`
// URL of the image
URL string `json:"url,omitempty" jsonschema:"title=URL"`
// As an alternative to the URL and only when the source data is small,
// like an SVG, the raw data may be provided using Base64 encoding.
Data []byte `json:"data,omitempty" jsonschema:"title=Data"`
// Format of the image.
MIME string `json:"mime,omitempty" jsonschema:"title=MIME"`
// Details of what the image represents.
Description string `json:"description,omitempty" jsonschema:"title=Description"`
// Alternative text if the image cannot be shown.
Alt string `json:"alt,omitempty" jsonschema:"title=Alt"`
// Height of the image in pixels.
Height int32 `json:"height,omitempty" jsonschema:"title=Height"`
// Width of the image in pixels.
Width int32 `json:"width,omitempty" jsonschema:"title=Width"`
// Digest can be used to ensure the image contained at the URL
// is the same one as originally intended.
Digest *dsig.Digest `json:"digest,omitempty" jsonschema:"title=Digest"`
}
Image describes a logo or photo that represents an entity. Most details except the URL are optional, but are potentially useful for validation if that's a requirement for the use case.
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 cbc.Key `json:"key" jsonschema:"title=Key"`
// Role assigned to this inbox that may be relevant for the consumer.
Role cbc.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 identity of this item
UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"`
// Primary reference code that identifies this item.
// Additional codes can be provided in the 'identities' property.
Ref string `json:"ref,omitempty" jsonschema:"title=Ref"`
// Special key used to classify the item sometimes required by some regimes.
Key cbc.Key `json:"key,omitempty" jsonschema:"title=Key"`
// Brief name of the item
Name string `json:"name"`
// List of additional codes, IDs, or SKUs which can be used to identify the item. They should be agreed upon between supplier and customer.
Identities []*Identity `json:"identities,omitempty" jsonschema:"title=Identities"`
// Detailed description
Description string `json:"desc,omitempty"`
// Currency used for the item's price.
Currency currency.Code `json:"currency,omitempty" jsonschema:"title=Currency"`
// Base price of a single unit to be sold.
Price num.Amount `json:"price" jsonschema:"title=Price"`
// Unit of measure.
Unit Unit `json:"unit,omitempty" jsonschema:"title=Unit"`
// Country code of where this item was from originally.
Origin l10n.CountryCode `json:"origin,omitempty" jsonschema:"title=Country of Origin"`
// Extension code map for any additional regime specific codes that may be required.
Ext cbc.CodeMap `json:"ext,omitempty" jsonschema:"title=Ext"`
// Additional meta information that may be useful
Meta cbc.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 `identities` property. Each `Identity` can be defined with an optional type agreed upon between the supplier and customer. For general purpose use, the Item's `Ref` property is easier to use.
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 cbc.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 Party ¶
type Party struct {
// Unique identity code
UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"`
// 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"`
// 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 *tax.Identity `json:"tax_id,omitempty" jsonschema:"title=Tax Identity"`
// Set of codes used to identify the party in other systems.
Identities []*Identity `json:"identities,omitempty" jsonschema:"title=Identities"`
// 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"`
// Public websites that provide further information about the party.
Websites []*Website `json:"websites,omitempty" jsonschema:"title=Websites"`
// 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"`
// Images that can be used to identify the party visually.
Logos []*Image `json:"logos,omitempty" jsonschema:"title=Logos"`
// Extension code map for any additional regime specific codes that may be required.
Ext cbc.CodeMap `json:"ext,omitempty" jsonschema:"title=Ext"`
// Any additional semi-structured information that does not fit into the rest of the party.
Meta cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`
}
Party represents a person or business entity.
func (*Party) Calculate ¶ added in v0.29.1
Calculate performs any calculations required on the Party or it's properties, like the tax identity.
type Person ¶
type Person struct {
// 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"`
// Avatars provider links to images or photos or the person.
Avatars []*Image `json:"avatars,omitempty" jsonschema:"title=Avatars"`
// Data about the data.
Meta cbc.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"`
Capital *num.Amount `json:"capital,omitempty" jsonschema:"title=Capital"`
Currency currency.Code `json:"currency,omitempty" jsonschema:"title=Currency"`
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.
func (*Registration) Validate ¶ added in v0.51.2
func (r *Registration) Validate() error
Validate ensures the registration looks valid.
func (*Registration) ValidateWithContext ¶ added in v0.51.2
func (r *Registration) ValidateWithContext(ctx context.Context) error
ValidateWithContext ensures the registration looks valid inside the provided context.
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
Unit is used to represent standard unit types.
const ( UnitEmpty Unit = `` // No unit defined // Measurement units UnitGram Unit = `g` UnitKilogram Unit = `kg` UnitMetricTon Unit = `t` UnitMillimetre Unit = `mm` UnitCentimetre Unit = `cm` UnitMetre Unit = `m` UnitKilometre Unit = `km` UnitInch Unit = `in` UnitFoot Unit = `ft` UnitSquareMetre Unit = `m2` UnitCubicMetre Unit = `m3` UnitCentilitre 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` UnitPiece Unit = `piece` UnitItem Unit = `item` UnitActivity Unit = `activity` UnitService Unit = `service` // 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.
func (Unit) JSONSchema ¶ added in v0.29.0
func (u Unit) JSONSchema() *jsonschema.Schema
JSONSchema provides a representation of the struct for usage in Schema.
type Website ¶ added in v0.35.0
type Website 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"`
// Title of the website to help distinguish between this and other links.
Title string `json:"title,omitempty" jsonschema:"title=Title"`
// URL for the website.
URL string `json:"url" jsonschema:"title=URL,format=uri"`
}
Website describes what is expected for a web address.