org

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: Apache-2.0 Imports: 11 Imported by: 14

Documentation

Overview

Package org contains structures related to organization.

Index

Constants

This section is empty.

Variables

View Source
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"},

	{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

This section is empty.

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.

func (*Address) Validate added in v0.20.0

func (a *Address) Validate() error

Validate checks that an address looks okay.

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"`
	// Text coordinates compose of three words.
	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.

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.

func (*Email) Validate

func (e *Email) Validate() error

Validate ensures email address looks valid.

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.
	Type cbc.Code `json:"type,omitempty" jsonschema:"title=Type"`
	// The actual value of the identity code.
	Code cbc.Code `json:"code" jsonschema:"title=Code"`
}

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

func (*Identity) Validate added in v0.37.0

func (i *Identity) Validate() error

Validate ensures the identity looks valid.

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.

func (*Image) Validate added in v0.35.0

func (i *Image) Validate() error

Validate ensures the details on the image look okay.

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.

func (*Inbox) Validate added in v0.26.0

func (i *Inbox) Validate() error

Validate ensures the inbox's fields look good.

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 string `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"`
	// 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) Validate added in v0.20.0

func (i *Item) Validate() error

Validate checks that an address looks okay.

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"`
	// 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"`
	// 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"`
	// 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"`
	// 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.

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.

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.

func (*Telephone) Validate

func (t *Telephone) Validate() error

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

type Unit added in v0.20.0

type Unit cbc.Key

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`

	// 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.

func (Unit) UNECE added in v0.29.0

func (u Unit) UNECE() cbc.Code

UNECE provides the unit's UN/ECE equivalent value. If not available, returns CodeEmpty.

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

func (*Website) Validate added in v0.35.0

func (w *Website) Validate() error

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

Jump to

Keyboard shortcuts

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