org

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2022 License: Apache-2.0 Imports: 10 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

UNTDID4451NoteCodeMap used to convert note codes into their official representation.

Functions

func DateAfter added in v0.16.0

func DateAfter(date Date) validation.Rule

DateAfter returns a validation rule which checks to ensure the date is *after* the provided date.

func DateBefore added in v0.16.0

func DateBefore(date Date) validation.Rule

DateBefore is used during validation to ensure the date is before the value passed in.

func DateNotZero added in v0.16.0

func DateNotZero() validation.Rule

DateNotZero ensures the date is not a zero value.

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.Country `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 Date

type Date struct {
	civil.Date
}

Date represents a simple date without time used most frequently with business documents.

func MakeDate

func MakeDate(year int, month time.Month, day int) Date

MakeDate provides a new date instance.

func NewDate

func NewDate(year int, month time.Month, day int) *Date

NewDate provides a pointer to a new date instance.

func (Date) JSONSchema added in v0.17.0

func (Date) JSONSchema() *jsonschema.Schema

JSONSchema returns a custom json schema for the date.

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.

func (*Email) Validate

func (e *Email) Validate() error

Validate ensures email address looks valid.

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 string `json:"unit,omitempty" jsonschema:"title=Unit,description=Code for unit of the item being sold"`
	//	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.Country `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 {
	Type  string `json:"typ,omitempty" jsonschema:"title=Type"`
	Value string `json:"val" jsonschema:"title=Value"`
}

ItemCode contains a value and optional type property that means additional codes can be added to an item.

type Meta

type Meta map[string]string

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.

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 {
	// Code specifying subject of the text
	Code NoteCode `json:"code,omitempty" jsonschema:"title=Code"`
	// 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.

func (*Note) Validate added in v0.13.0

func (n *Note) Validate() error

Validate checks that the note looks okay.

type NoteCode added in v0.13.0

type NoteCode string

NoteCode contains a code for the type of note.

const (
	GoodsNoteCode          NoteCode = "goods"           // Goods Description
	PaymentNoteCode        NoteCode = "payment"         // Terms of Payment
	LegalNoteCode          NoteCode = "legal"           // Legal or regulatory information
	DangerousGoodsNoteCode NoteCode = "dangerous-goods" // Dangerous goods additional information
	AckNoteCode            NoteCode = "ack"             // Acknowledgement Description
	RateNoteCode           NoteCode = "rate"            // Rate additional information
	ReasonNoteCode         NoteCode = "reason"          // Reason
	DisputeNoteCode        NoteCode = "dispute"         // Dispute
	CustomerNoteCode       NoteCode = "customer"        // Customer remarks
	GlossaryNoteCode       NoteCode = "glossary"        // Glossary
	CustomsNoteCode        NoteCode = "customs"         // Customs declaration information
	GeneralNoteCode        NoteCode = "general"         // General information
	HandlingNoteCode       NoteCode = "handling"        // Handling instructions
	PackagingNoteCode      NoteCode = "packaging"       // Packaging information
	LoadingNoteCode        NoteCode = "loading"         // Loading instructions
	PriceNoteCode          NoteCode = "price"           // Price conditions
	PriorityNoteCode       NoteCode = "priority"        // Priority information
	RegulatoryNoteCode     NoteCode = "regulatory"      // Regulatory information
	SafetyNoteCode         NoteCode = "safety"          // Safety Instructions
	ShipLineNoteCode       NoteCode = "ship-line"       // Ship Line
	SupplierNoteCode       NoteCode = "supplier"        // Supplier remarks
	TransportNoteCode      NoteCode = "transport"       // Transportation information
)

Predefined list of supported note code types 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 (NoteCode) UNTDID4451 added in v0.13.0

func (c NoteCode) UNTDID4451() string

UNTDID4451 returns the official type code, or "NA" if none is set.

func (NoteCode) Validate added in v0.13.0

func (c NoteCode) Validate() error

Validate checks to ensure the note code is part of the list of accepted values.

type Notes added in v0.13.0

type Notes []*Note

Notes holds an array of Note objects

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        *TaxID        `` /* 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.

func (*Party) Validate

func (p *Party) Validate() error

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

type Period

type Period struct {
	Start Date `json:"start"`
	End   Date `json:"end"`
}

Period represents two dates with a start and finish.

func (*Period) Validate added in v0.16.0

func (p *Period) Validate() error

Validate checks to ensure the period looks correct.

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 TaxID

type TaxID 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.Country `json:"country" jsonschema:"title=Country Code"`
	// Identity Code
	Code string `json:"code" jsonschema:"title=Code"`
	// Additional details.
	Meta Meta `json:"meta,omitempty" jsonschema:"title=Meta"`
}

TaxID represents a party's tax identify number for a given country.

func (*TaxID) Validate

func (tid *TaxID) 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 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.

func (*Telephone) Validate

func (t *Telephone) 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