vat

package
v0.0.0-...-f3f6071 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// IDMinLength is the minium length of a VAT ID
	IDMinLength = 4

	// IDMaxLength is the maximum length of a VAT ID
	IDMaxLength = 14 + 2 // allow 2 spaces
)
View Source
const MOSSSchemaVATCountryCode = "EU"

MOSSSchemaVATCountryCode or the VAT Mini One Stop Shop (MOSS) is an optional scheme that allows you to account for VAT - normally due in multiple EU countries – in just one EU country. Check out: https://europa.eu/youreurope/business/taxation/vat/vat-digital-services-moss-scheme/index_en.htm

Variables

View Source
var IDFinder idFinder

Functions

func BytesAreVATID

func BytesAreVATID(str []byte) bool

BytesAreVATID returns if a byte string is a valid VAT ID

func StringIsVATID

func StringIsVATID(str string) bool

StringIsVATID returns if a string can be parsed as VATID.

Types

type ID

type ID string

ID is a european VAT ID. ID implements the database/sql.Scanner and database/sql/driver.Valuer interfaces, returning errors when the ID is not valid and can't be normalized. Use NullableID to read and write SQL NULL values.

func NormalizeVATID

func NormalizeVATID(str string) (ID, error)

NormalizeVATID returns str as normalized VAT ID or an error.

func (ID) CountryCode

func (id ID) CountryCode() country.Code

CountryCode returns the country.Code of the VAT ID, or country.Invalid if the id is not valid. For a VAT Mini One Stop Shop (MOSS) ID that begins with "EU" the EU's capital Brussels' country Belgum's code country.BE will be returned. See also ID.IsMOSS.

func (ID) IsMOSS

func (id ID) IsMOSS() bool

IsMOSS returns true if the ID follows the VAT Mini One Stop Shop (MOSS) schema beginning with "EU".

func (ID) Normalized

func (id ID) Normalized() (ID, error)

Normalized returns the id in normalized form, or an error if the VAT ID is not valid.

func (ID) NormalizedOrNull

func (id ID) NormalizedOrNull() NullableID

NormalizedOrNull returns the id in normalized form or Null if the VAT ID is not valid.

func (ID) Nullable

func (id ID) Nullable() NullableID

Nullable returns the id as NullableID

func (ID) Number

func (id ID) Number() string

Number returns the number part after the country code of the VAT ID, or and empty string if the id is not valid.

func (*ID) Scan

func (id *ID) Scan(value any) error

Scan implements the database/sql.Scanner interface.

func (*ID) ScanString

func (id *ID) ScanString(source string, validate bool) error

ScanString tries to parse and assign the passed source string as value of the implementing type.

If validate is true, the source string is checked for validity before it is assigned to the type.

If validate is false and the source string can still be assigned in some non-normalized way it will be assigned without returning an error.

func (ID) String

func (id ID) String() string

String returns the normalized ID if possible, else it will be returned unchanged as string. String implements the fmt.Stringer interface.

func (ID) Valid

func (id ID) Valid() bool

Valid returns if id is a valid VAT ID, ignoring normalization.

func (ID) ValidAndNormalized

func (id ID) ValidAndNormalized() bool

ValidAndNormalized returns if id is a valid and normalized VAT ID.

func (ID) Validate

func (id ID) Validate() error

Validate returns an error if id is not a valid VAT ID, ignoring normalization.

func (ID) ValidateIsNormalized

func (id ID) ValidateIsNormalized() error

ValidateIsNormalized returns an error if id is not a valid and normalized VAT ID.

func (ID) Value

func (id ID) Value() (driver.Value, error)

Value implements the driver database/sql/driver.Valuer interface.

type IDParser

type IDParser struct{}

IDParser implements the strfmt.Parser interface for VAT IDs.

func (IDParser) Parse

func (IDParser) Parse(str string, langHints ...language.Code) (normalized string, err error)

type NullableID

type NullableID string

NullableID is identical to ID, except that the Null value (empty string) is considered valid by the Valid() and Validate() methods.

var Null NullableID

Null is an empty string and will be treatet as SQL NULL.

func (NullableID) CountryCode

func (n NullableID) CountryCode() country.NullableCode

CountryCode returns the country.NullableCode of the VAT ID, or ccountry.Null if the id is null or not valid. For a VAT Mini One Stop Shop (MOSS) ID that begins with "EU" the EU's capital Brussels' country Belgum's code country.BE will be returned. See also NullableID.IsMOSS.

func (NullableID) Get

func (n NullableID) Get() ID

Get returns the non nullable ID value or panics if the NullableID is null. Note: check with IsNull before using Get!

func (NullableID) GetOr

func (n NullableID) GetOr(defaultID ID) ID

GetOr returns the non nullable ID value or the passed defaultID if the NullableID is null.

func (NullableID) IsMOSS

func (n NullableID) IsMOSS() bool

IsMOSS returns true if the ID follows the VAT Mini One Stop Shop (MOSS) schema beginning with "EU".

func (NullableID) IsNotNull

func (n NullableID) IsNotNull() bool

IsNotNull returns true if the NullableID is not null.

func (NullableID) IsNull

func (n NullableID) IsNull() bool

IsNull returns true if the NullableID is null. IsNull implements the nullable.Nullable interface.

func (NullableID) MarshalJSON

func (n NullableID) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler by returning the JSON null value for an empty (null) string.

func (NullableID) Normalized

func (n NullableID) Normalized() (NullableID, error)

Normalized returns the id in normalized form, or an error if the VAT ID is not Null and not valid.

func (NullableID) NormalizedNotNull

func (n NullableID) NormalizedNotNull() (ID, error)

NormalizedNotNull returns the id in normalized form, or an error if the VAT ID is not valid or Null.

func (NullableID) NormalizedOrNull

func (n NullableID) NormalizedOrNull() NullableID

NormalizedOrNull returns n in normalized form or Null if id is not valid.

func (NullableID) Number

func (n NullableID) Number() string

Number returns the number part after the country code of the VAT ID, or and empty string if the id is not valid.

func (*NullableID) Scan

func (n *NullableID) Scan(value any) error

Scan implements the database/sql.Scanner interface.

func (*NullableID) ScanString

func (n *NullableID) ScanString(source string, validate bool) error

ScanString tries to parse and assign the passed source string as value of the implementing type.

If validate is true, the source string is checked for validity before it is assigned to the type.

If validate is false and the source string can still be assigned in some non-normalized way it will be assigned without returning an error.

func (*NullableID) Set

func (n *NullableID) Set(id ID)

Set sets an ID for this NullableID

func (*NullableID) SetNull

func (n *NullableID) SetNull()

SetNull sets the NullableID to null

func (NullableID) String

func (n NullableID) String() string

String returns the normalized ID if possible, else it will be returned unchanged as string. String implements the fmt.Stringer interface.

func (NullableID) StringOr

func (n NullableID) StringOr(nullString string) string

StringOr returns the NullableID as string or the passed nullString if the NullableID is null.

func (NullableID) Valid

func (n NullableID) Valid() bool

Valid returns if id is a valid VAT ID or Null, ignoring normalization.

func (NullableID) ValidAndNormalized

func (n NullableID) ValidAndNormalized() bool

ValidAndNormalized returns if id is Null or a valid and normalized VAT ID.

func (NullableID) ValidAndNotNull

func (n NullableID) ValidAndNotNull() bool

ValidAndNotNull returns if this is a valid not Null VAIT ID.

func (NullableID) Validate

func (n NullableID) Validate() error

Validate returns an error if id is not a valid VAT ID or Null, ignoring normalization.

func (NullableID) ValidateIsNormalized

func (n NullableID) ValidateIsNormalized() error

ValidateIsNormalized returns an error if id is not Null or a valid and normalized VAT ID.

func (NullableID) ValidateIsNormalizedAndNotNull

func (n NullableID) ValidateIsNormalizedAndNotNull() error

ValidateIsNormalizedAndNotNull returns an error if id is not a valid and normalized VAT ID.

func (NullableID) Value

func (n NullableID) Value() (driver.Value, error)

Value implements the driver database/sql/driver.Valuer interface.

Jump to

Keyboard shortcuts

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