org

package
v0.74.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 15 Imported by: 14

Documentation

Overview

Package org contains structures related to organization.

Index

Constants

View Source
const (
	// UnitPatternUNECE is a regular expression for UN/ECE unit codes when a unit is not covered by GOBL.
	UnitPatternUNECE = `^[A-Z0-9]{2,3}$`
	// UnitUNECEMutuallyDefined is the UN/ECE code for mutually defined units.
	UnitUNECEMutuallyDefined cbc.Code = `ZZ`
)

Variables

View Source
var RegexpPatternW3W = "" /* 370-byte string literal not displayed */

RegexpPatternW3W is a regular expression that matches a what3words address.

View Source
var UnitDefinitions = []DefUnit{

	{UnitMilligram, "Milligrams", "", "MGM"},
	{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"},
	{UnitMillilitre, "Millilitres", "", "MLT"},
	{UnitCentilitre, "Centilitres", "", "CLT"},
	{UnitLitre, "Litres", "", "LTR"},
	{UnitWatt, "Watts", "", "WTT"},
	{UnitKilowatt, "Kilowatts", "", "KWT"},
	{UnitKilowattHour, "Kilowatt Hours", "", "KWH"},
	{UnitRate, "Rate", "A unit of quantity expressed as a rate for usage of a facility or service.", "A9"},
	{UnitMonth, "Months", "Unit of time equal to 1/12 of a year of 365,25 days.", "MON"},
	{UnitDay, "Days", "", "DAY"},
	{UnitSecond, "Seconds", "", "SEC"},
	{UnitHour, "Hours", "", "HUR"},
	{UnitMinute, "Minutes", "", "MIN"},
	{UnitPiece, "Pieces", "A unit of count defining the number of pieces (piece: a single item, article or exemplar).", "H87"},
	{UnitItem, "Items", " A unit of count defining the number of items regarded as separate units.", "EA"},
	{UnitPair, "Pairs", "A unit of count defining the number of pairs (pair: item described by two's).", "PR"},
	{UnitDozen, "Dozens", "A unit of count defining the number of units in multiples of 12.", "DZN"},
	{UnitAssortment, "Assortments", "A unit of count defining the number of assortments (assortment: a collection of items or components of a single product packaged together).", "AS"},
	{UnitService, "Service Units", "A unit of count defining the number of service units (service unit: defined period / property / facility / utility of supply).", "E48"},
	{UnitJob, "Jobs", "A unit of count defining the number of jobs.", "E51"},
	{UnitActivity, "Activities", "A unit of count defining the number of activities (activity: a unit of work or action).", "ACT"},
	{UnitTrip, "Trips", "A unit of count defining the number of trips (trip: a journey to a place and back again).", "E54"},
	{UnitGroup, "Groups", "A unit of count defining the number of groups (group: set of items classified together).", "10"},
	{UnitOutfit, "Outfits", "A unit of count defining the number of outfits (outfit: a complete set of equipment / materials / objects used for a specific purpose).", "11"},
	{UnitKit, "Kits", "A unit of count defining the number of kits (kit: tub, barrel or pail).", "KT"},
	{UnitBaseBox, "Base Boxes", "A unit of area of 112 sheets of tin mil products (tin plate, tin free steel or black plate) 14 by 20 inches, or 31,360 square inches.", "BB"},
	{UnitBulkPack, "Bulk Packs", "A unit of count defining the number of items per bulk pack.", "AB"},

	{UnitBag, "Bags", "", "XBG"},
	{UnitBox, "Boxes", "", "XBX"},
	{UnitBin, "Bins", "", "XBI"},
	{UnitCan, "Cans", "", "XCA"},
	{UnitTub, "Tubs", "", "XTB"},
	{UnitCase, "Cases", "", "XCS"},
	{UnitTray, "Trays", "", "XDS"},
	{UnitPortion, "Portions", "", ""},
	{UnitSet, "Sets", "A unit of count defining the number of sets (set: a number of objects grouped together).", "SET"},
	{UnitRoll, "Rolls", "", "XRO"},
	{UnitCarton, "Cartons", "", "XCT"},
	{UnitCylinder, "Cylinders", "", "XCY"},
	{UnitBarrel, "Barrels", "", "XBA"},
	{UnitJerrican, "Jerricans", "Jerrican, cylindrical", "XJY"},
	{UnitCarboy, "Carboys", "", "XCO"},
	{UnitDemijohn, "Demijohn", "", "XDJ"},
	{UnitBottle, "Bottles", "", "XBO"},
	{UnitSixPack, "Six Packs", "", ""},
	{UnitCanister, "Canisters", "", "XCI"},
	{UnitPackage, "Packages", "Standard packaging unit.", "XPK"},
	{UnitBunch, "Bunches", "", "XBH"},
	{UnitTetraBrik, "Tetra-Briks", "", ""},
	{UnitPallet, "Pallets", "", "XPX"},
	{UnitReel, "Reels", "", "XRL"},
	{UnitSack, "Sacks", "", "XSA"},
	{UnitSheet, "Sheets", "", "XST"},
	{UnitEnvelope, "Envelopes", "", "XEN"},
	{UnitLot, "Lot", "", "XLT"},
	{UnitUnit, "Unit", "A type of package composed of a single item or object, not otherwise specified as a unit of transport equipment.", "XUN"},
}

UnitDefinitions describes each of the unit constants. Order is important.

Functions

func HasIdentityKey added in v0.54.0

func HasIdentityKey(key cbc.Key) validation.Rule

HasIdentityKey provides a validation rule that will determine if at least one of the identities defined includes one with the defined key.

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 {
	uuid.Identify
	// 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.

func (*Address) Validate added in v0.20.0

func (a *Address) Validate() error

Validate checks that an address looks okay.

func (*Address) ValidateWithContext added in v0.51.2

func (a *Address) ValidateWithContext(ctx context.Context) error

ValidateWithContext checks that an address looks okay in the given context.

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"`
	// Name of the Unit
	Name string `json:"name" jsonschema:"title=Name"`
	// 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 {
	uuid.Identify
	// 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.

func (*Email) Validate

func (e *Email) Validate() error

Validate ensures email address looks valid.

func (*Email) ValidateWithContext added in v0.51.2

func (e *Email) ValidateWithContext(ctx context.Context) error

ValidateWithContext ensures email address looks valid inside the provided context.

type Identity added in v0.37.0

type Identity struct {
	uuid.Identify
	// Optional label useful for non-standard identities to give a bit more context.
	Label string `json:"label,omitempty" jsonschema:"title=Label"`
	// Uniquely classify this identity using a key instead of a code.
	Key cbc.Key `json:"key,omitempty" jsonschema:"title=Key"`
	// 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"`
}

Identity is used to define a code for a specific context.

func AddIdentity added in v0.54.0

func AddIdentity(in []*Identity, i *Identity) []*Identity

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

func IdentityForType(in []*Identity, typ cbc.Code) *Identity

IdentityForType helps return the identity with a matching type code.

func (*Identity) Validate added in v0.37.0

func (i *Identity) Validate() error

Validate ensures the identity looks valid.

func (*Identity) ValidateWithContext added in v0.51.2

func (i *Identity) ValidateWithContext(ctx context.Context) error

ValidateWithContext ensures the identity looks valid inside the provided context.

type Image added in v0.35.0

type Image struct {
	uuid.Identify
	// 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"`
	// Meta contains additional information about the image.
	Meta *cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`
}

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.

func (*Image) Validate added in v0.35.0

func (i *Image) Validate() error

Validate ensures the details on the image look okay.

func (*Image) ValidateWithContext added in v0.51.2

func (i *Image) ValidateWithContext(ctx context.Context) error

ValidateWithContext ensures the details on the image look okay inside the provided context.

type Inbox added in v0.26.0

type Inbox struct {
	uuid.Identify
	// 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.

func (*Inbox) Validate added in v0.26.0

func (i *Inbox) Validate() error

Validate ensures the inbox's fields look good.

func (*Inbox) ValidateWithContext added in v0.51.2

func (i *Inbox) ValidateWithContext(ctx context.Context) error

ValidateWithContext ensures the inbox's fields look good inside the provided context.

type Item

type Item struct {
	uuid.Identify
	// 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" jsonschema:"title=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 of the item.
	Description string `json:"description,omitempty" jsonschema:"title=Description"`
	// 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 tax.Extensions `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.

func (*Item) Calculate added in v0.67.10

func (i *Item) Calculate() error

Calculate performs any required calculations on the Item.

func (*Item) Validate added in v0.20.0

func (i *Item) Validate() error

Validate checks that the Item looks okay.

func (*Item) ValidateWithContext added in v0.51.2

func (i *Item) ValidateWithContext(ctx context.Context) error

ValidateWithContext checks that the Item looks okay inside the provided context.

type Name

type Name struct {
	uuid.Identify
	// 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

func (*Name) Validate added in v0.51.2

func (n *Name) Validate() error

Validate ensures the name looks valid.

func (*Name) ValidateWithContext added in v0.51.2

func (n *Name) ValidateWithContext(ctx context.Context) error

ValidateWithContext ensures the name looks valid inside the provided context.

type Party

type Party struct {
	uuid.Identify
	// 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 tax.Extensions `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

func (p *Party) Calculate() error

Calculate performs any calculations required on the Party or it's properties, like the tax identity.

func (*Party) Validate

func (p *Party) Validate() error

Validate is used to check the party's data meets minimum expectations.

func (*Party) ValidateWithContext added in v0.51.2

func (p *Party) ValidateWithContext(ctx context.Context) error

ValidateWithContext is used to check the party's data meets minimum expectations.

type Person

type Person struct {
	uuid.Identify
	// 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.

func (*Person) Validate added in v0.51.2

func (p *Person) Validate() error

Validate validates the person.

func (*Person) ValidateWithContext added in v0.51.2

func (p *Person) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates the person with the given context.

type Registration added in v0.1.0

type Registration struct {
	uuid.Identify
	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 {
	uuid.Identify
	// 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.

func (*Telephone) Validate

func (t *Telephone) Validate() error

Validate checks the telephone objects number to ensure it looks correct.

func (*Telephone) ValidateWithContext added in v0.51.2

func (t *Telephone) ValidateWithContext(ctx context.Context) error

ValidateWithContext checks the telephone objects number to ensure it looks correct inside the provided context.

type Unit added in v0.20.0

type Unit string

Unit represents either a unit key defined by GOBL *or* a two to three letter code defined by the UN/ECE.

const (
	UnitEmpty Unit = `` // No unit defined

	// Measurement units
	UnitMilligram    Unit = `mg`
	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`
	UnitMillilitre   Unit = "ml"
	UnitCentilitre   Unit = `cl`
	UnitLitre        Unit = `l`
	UnitWatt         Unit = `w`
	UnitKilowatt     Unit = `kw`
	UnitKilowattHour Unit = `kwh`
	UnitMonth        Unit = `mon`
	UnitDay          Unit = `day`
	UnitSecond       Unit = `s`
	UnitHour         Unit = `h`
	UnitMinute       Unit = `min`
	UnitRate         Unit = `rate`
	UnitPiece        Unit = `piece`
	UnitItem         Unit = `item`
	UnitActivity     Unit = `activity`
	UnitService      Unit = `service`
	UnitGroup        Unit = `group`
	UnitSet          Unit = `set`
	UnitTrip         Unit = `trip`
	UnitJob          Unit = `job`
	UnitAssortment   Unit = `assortment`
	UnitOutfit       Unit = `outfit`
	UnitKit          Unit = `kit`
	UnitBaseBox      Unit = `basebox`
	UnitBulkPack     Unit = `pk`

	// 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`
	UnitPair      Unit = `pair`
	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`
	UnitUnit      Unit = `unit`
	UnitLot       Unit = `lot`
)

Set of common units based on UN/ECE recommendation 20 and 21 extensions. Some local formats may define additional non-standard codes which may be added.

The UN/ECE defines a very large set of units which would be impractical to support here in GOBL, so the Unit type will also accept any UN/ECE unit code instead of one of the keys defined here.

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.

func (Unit) UNECE added in v0.29.0

func (u Unit) UNECE() cbc.Code

UNECE provides the unit's UN/ECE equivalent value.

func (Unit) Validate added in v0.20.0

func (u Unit) Validate() error

Validate ensures the unit looks correct

type Website added in v0.35.0

type Website struct {
	uuid.Identify
	// 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.

func (*Website) Validate added in v0.35.0

func (w *Website) Validate() error

Validate checks the website objects URL to ensure it looks correct.

func (*Website) ValidateWithContext added in v0.51.2

func (w *Website) ValidateWithContext(ctx context.Context) error

ValidateWithContext checks the website objects URL to ensure it looks correct inside the provided context.

Jump to

Keyboard shortcuts

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