taxcode

package
v1.0.0-beta.228 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AnnotationKeyManagedBy indicates what created/owns this tax code.
	AnnotationKeyManagedBy = "managed_by"

	// AnnotationValueManagedBySystem is set when the tax code was auto-created
	// by the system (e.g. via GetOrCreateByAppMapping).
	AnnotationValueManagedBySystem = "system"
)
View Source
const ErrCodeAppTypesMustBeUnique models.ErrorCode = "app_types_must_be_unique"
View Source
const ErrCodeOrganizationDefaultTaxCodesNotFound models.ErrorCode = "organization_default_tax_codes_not_found"
View Source
const ErrCodeResourceIDEmpty models.ErrorCode = "resource_id_empty"
View Source
const ErrCodeResourceKeyEmpty models.ErrorCode = "resource_key_empty"
View Source
const ErrCodeResourceNameEmpty models.ErrorCode = "resource_name_empty"
View Source
const ErrCodeResourceNamespaceEmpty models.ErrorCode = "resource_namespace_empty"
View Source
const ErrCodeTaxCodeEmpty models.ErrorCode = "tax_code_empty"
View Source
const ErrCodeTaxCodeManagedBySystem models.ErrorCode = "tax_code_managed_by_system"
View Source
const ErrCodeTaxCodeNotFound models.ErrorCode = "tax_code_not_found"
View Source
const ErrCodeTaxCodeStripeInvalid models.ErrorCode = "tax_code_stripe_invalid"

Variables

View Source
var ErrOrganizationDefaultTaxCodesNotFound = models.NewValidationIssue(
	ErrCodeOrganizationDefaultTaxCodesNotFound,
	"organization default tax codes not found",
	models.WithCriticalSeverity(),
	commonhttp.WithHTTPStatusCodeAttribute(http.StatusNotFound),
)
View Source
var ErrTaxCodeManagedBySystem = models.NewValidationIssue(
	ErrCodeTaxCodeManagedBySystem,
	"tax code is managed by the system and cannot be modified or deleted",
	models.WithCriticalSeverity(),
	commonhttp.WithHTTPStatusCodeAttribute(http.StatusConflict),
)
View Source
var ErrTaxCodeStripeInvalid = models.NewValidationIssue(
	ErrCodeTaxCodeStripeInvalid,
	"stripe tax code must be in the format of txcd_12345678",
	models.WithFieldString("app_mappings"),
	models.WithCriticalSeverity(),
	commonhttp.WithHTTPStatusCodeAttribute(http.StatusBadRequest),
)
View Source
var OrganizationDefaultTaxCodesExpandAll = OrganizationDefaultTaxCodesExpand{
	InvoicingTaxCode:   true,
	CreditGrantTaxCode: true,
}

OrganizationDefaultTaxCodesExpandAll loads all related objects.

View Source
var TaxCodeStripeRegexp = regexp.MustCompile(`^txcd_\d{8}$`)

Functions

func IsOrganizationDefaultTaxCodesNotFoundError

func IsOrganizationDefaultTaxCodesNotFoundError(err error) bool

func IsTaxCodeNotFoundError

func IsTaxCodeNotFoundError(err error) bool

func NewOrganizationDefaultTaxCodesNotFoundError

func NewOrganizationDefaultTaxCodesNotFoundError(namespace string) error

func NewTaxCodeByAppMappingNotFoundError

func NewTaxCodeByAppMappingNotFoundError(appType, taxCode string) error

func NewTaxCodeNotFoundError

func NewTaxCodeNotFoundError(id string) error

Types

type CreateTaxCodeInput

type CreateTaxCodeInput struct {
	Namespace   string
	Key         string
	Name        string
	Description *string
	AppMappings TaxCodeAppMappings
	Metadata    models.Metadata
	Annotations models.Annotations
}

func (CreateTaxCodeInput) Validate

func (i CreateTaxCodeInput) Validate() error

type DeleteTaxCodeInput

type DeleteTaxCodeInput struct {
	models.NamespacedID
	// contains filtered or unexported fields
}

func (DeleteTaxCodeInput) Validate

func (i DeleteTaxCodeInput) Validate() error

type GetOrCreateByAppMappingInput

type GetOrCreateByAppMappingInput struct {
	Namespace string
	AppType   app.AppType
	TaxCode   string
}

func (GetOrCreateByAppMappingInput) Validate

func (i GetOrCreateByAppMappingInput) Validate() error

type GetOrganizationDefaultTaxCodesInput

type GetOrganizationDefaultTaxCodesInput struct {
	Namespace string
	Expand    OrganizationDefaultTaxCodesExpand
}

func (GetOrganizationDefaultTaxCodesInput) Validate

type GetTaxCodeByAppMappingInput

type GetTaxCodeByAppMappingInput struct {
	Namespace string
	AppType   app.AppType
	TaxCode   string
}

func (GetTaxCodeByAppMappingInput) Validate

func (i GetTaxCodeByAppMappingInput) Validate() error

type GetTaxCodeInput

type GetTaxCodeInput struct {
	models.NamespacedID
}

func (GetTaxCodeInput) Validate

func (i GetTaxCodeInput) Validate() error

type ListTaxCodesInput

type ListTaxCodesInput struct {
	Namespace string
	pagination.Page

	IncludeDeleted bool
}

func (ListTaxCodesInput) Validate

func (i ListTaxCodesInput) Validate() error

type OrganizationDefaultTaxCodes

type OrganizationDefaultTaxCodes struct {
	models.NamespacedID
	models.ManagedModel

	InvoicingTaxCodeID string   `json:"invoicing_tax_code_id"`
	InvoicingTaxCode   *TaxCode `json:"invoicing_tax_code,omitempty"`

	CreditGrantTaxCodeID string   `json:"credit_grant_tax_code_id"`
	CreditGrantTaxCode   *TaxCode `json:"credit_grant_tax_code,omitempty"`
}

OrganizationDefaultTaxCodes stores the per-namespace default tax code references.

func (OrganizationDefaultTaxCodes) Validate

func (o OrganizationDefaultTaxCodes) Validate() error

type OrganizationDefaultTaxCodesExpand

type OrganizationDefaultTaxCodesExpand struct {
	InvoicingTaxCode   bool
	CreditGrantTaxCode bool
}

OrganizationDefaultTaxCodesExpand controls which related objects are loaded.

type OrganizationDefaultTaxCodesService

type OrganizationDefaultTaxCodesService interface {
	GetOrganizationDefaultTaxCodes(ctx context.Context, input GetOrganizationDefaultTaxCodesInput) (OrganizationDefaultTaxCodes, error)
	UpsertOrganizationDefaultTaxCodes(ctx context.Context, input UpsertOrganizationDefaultTaxCodesInput) (OrganizationDefaultTaxCodes, error)
}

type Repository

type Repository interface {
	entutils.TxCreator

	CreateTaxCode(ctx context.Context, input CreateTaxCodeInput) (TaxCode, error)
	UpdateTaxCode(ctx context.Context, input UpdateTaxCodeInput) (TaxCode, error)
	ListTaxCodes(ctx context.Context, input ListTaxCodesInput) (pagination.Result[TaxCode], error)
	GetTaxCode(ctx context.Context, input GetTaxCodeInput) (TaxCode, error)
	GetTaxCodeByAppMapping(ctx context.Context, input GetTaxCodeByAppMappingInput) (TaxCode, error)
	DeleteTaxCode(ctx context.Context, input DeleteTaxCodeInput) error

	GetOrganizationDefaultTaxCodes(ctx context.Context, input GetOrganizationDefaultTaxCodesInput) (OrganizationDefaultTaxCodes, error)
	UpsertOrganizationDefaultTaxCodes(ctx context.Context, input UpsertOrganizationDefaultTaxCodesInput) (OrganizationDefaultTaxCodes, error)
}

type TaxCode

type TaxCode struct {
	models.NamespacedID
	models.ManagedModel

	// Key is the unique key for TaxCode.
	Key string `json:"key"`

	// Name is the display name for TaxCode.
	Name string `json:"name"`

	// Description is the description for TaxCode.
	Description *string `json:"description,omitempty"`

	// AppMappings is the mapping of app types to tax codes.
	AppMappings TaxCodeAppMappings `json:"app_mappings"`

	// Metadata
	Metadata models.Metadata `json:"metadata,omitempty"`

	// Annotations are system-managed key/value pairs stored alongside the tax code.
	Annotations models.Annotations `json:"annotations,omitempty"`
}

TaxCode represents a tax code with mappings to app types.

func (TaxCode) GetAppMapping

func (t TaxCode) GetAppMapping(appType app.AppType) (TaxCodeAppMapping, bool)

GetAppMapping returns the app mapping for the given app type, if it exists.

func (TaxCode) IsManagedBySystem

func (t TaxCode) IsManagedBySystem() bool

IsManagedBySystem returns true when this tax code was auto-created by the system.

func (TaxCode) Validate

func (t TaxCode) Validate() error

type TaxCodeAppMapping

type TaxCodeAppMapping struct {
	AppType app.AppType `json:"app_type"`
	TaxCode string      `json:"tax_code"`
}

TaxCodeAppMapping represents a mapping of an app type to a tax code.

func (TaxCodeAppMapping) Validate

func (t TaxCodeAppMapping) Validate() error

type TaxCodeAppMappings

type TaxCodeAppMappings []TaxCodeAppMapping

TaxCodeAppMappings is a list of TaxCodeAppMapping.

func (TaxCodeAppMappings) Validate

func (t TaxCodeAppMappings) Validate() error

type TaxCodeService

type TaxCodeService interface {
	CreateTaxCode(ctx context.Context, input CreateTaxCodeInput) (TaxCode, error)
	UpdateTaxCode(ctx context.Context, input UpdateTaxCodeInput) (TaxCode, error)
	ListTaxCodes(ctx context.Context, input ListTaxCodesInput) (pagination.Result[TaxCode], error)
	GetTaxCode(ctx context.Context, input GetTaxCodeInput) (TaxCode, error)
	GetTaxCodeByAppMapping(ctx context.Context, input GetTaxCodeByAppMappingInput) (TaxCode, error)
	GetOrCreateByAppMapping(ctx context.Context, input GetOrCreateByAppMappingInput) (TaxCode, error)
	DeleteTaxCode(ctx context.Context, input DeleteTaxCodeInput) error
}

type UpdateTaxCodeInput

type UpdateTaxCodeInput struct {
	models.NamespacedID

	Name        string
	Description *string
	AppMappings TaxCodeAppMappings
	Metadata    models.Metadata
	Annotations models.Annotations
	// contains filtered or unexported fields
}

func (UpdateTaxCodeInput) Validate

func (i UpdateTaxCodeInput) Validate() error

type UpsertOrganizationDefaultTaxCodesInput

type UpsertOrganizationDefaultTaxCodesInput struct {
	Namespace            string
	InvoicingTaxCodeID   string
	CreditGrantTaxCodeID string
	Expand               OrganizationDefaultTaxCodesExpand
}

func (UpsertOrganizationDefaultTaxCodesInput) Validate

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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