Documentation
¶
Index ¶
- Constants
- Variables
- func IsOrganizationDefaultTaxCodesNotFoundError(err error) bool
- func IsTaxCodeNotFoundError(err error) bool
- func NewOrganizationDefaultTaxCodesNotFoundError(namespace string) error
- func NewTaxCodeByAppMappingNotFoundError(appType, taxCode string) error
- func NewTaxCodeNotFoundError(id string) error
- type CreateTaxCodeInput
- type DeleteTaxCodeInput
- type GetOrCreateByAppMappingInput
- type GetOrganizationDefaultTaxCodesInput
- type GetTaxCodeByAppMappingInput
- type GetTaxCodeInput
- type ListTaxCodesInput
- type OrganizationDefaultTaxCodes
- type OrganizationDefaultTaxCodesExpand
- type OrganizationDefaultTaxCodesService
- type Repository
- type Service
- type TaxCode
- type TaxCodeAppMapping
- type TaxCodeAppMappings
- type TaxCodeService
- type UpdateTaxCodeInput
- type UpsertOrganizationDefaultTaxCodesInput
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 ErrAppTypesMustBeUnique = models.NewValidationIssue( ErrCodeAppTypesMustBeUnique, "app types must be unique", models.WithFieldString("app_mappings"), models.WithCriticalSeverity(), commonhttp.WithHTTPStatusCodeAttribute(http.StatusBadRequest), )
View Source
var ErrOrganizationDefaultTaxCodesNotFound = models.NewValidationIssue( ErrCodeOrganizationDefaultTaxCodesNotFound, "organization default tax codes not found", models.WithCriticalSeverity(), commonhttp.WithHTTPStatusCodeAttribute(http.StatusNotFound), )
View Source
var ErrResourceIDEmpty = models.NewValidationIssue( ErrCodeResourceIDEmpty, "id must not be empty", models.WithCriticalSeverity(), commonhttp.WithHTTPStatusCodeAttribute(http.StatusBadRequest), )
View Source
var ErrResourceKeyEmpty = models.NewValidationIssue( ErrCodeResourceKeyEmpty, "key must not be empty", models.WithFieldString("key"), models.WithCriticalSeverity(), commonhttp.WithHTTPStatusCodeAttribute(http.StatusBadRequest), )
View Source
var ErrResourceNameEmpty = models.NewValidationIssue( ErrCodeResourceNameEmpty, "name must not be empty", models.WithFieldString("name"), models.WithCriticalSeverity(), commonhttp.WithHTTPStatusCodeAttribute(http.StatusBadRequest), )
View Source
var ErrResourceNamespaceEmpty = models.NewValidationIssue( ErrCodeResourceNamespaceEmpty, "namespace must not be empty", models.WithFieldString("namespace"), models.WithCriticalSeverity(), commonhttp.WithHTTPStatusCodeAttribute(http.StatusBadRequest), )
View Source
var ErrTaxCodeEmpty = models.NewValidationIssue( ErrCodeTaxCodeEmpty, "tax code cannot be empty", models.WithFieldString("app_mappings"), models.WithCriticalSeverity(), commonhttp.WithHTTPStatusCodeAttribute(http.StatusBadRequest), )
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 ErrTaxCodeNotFound = models.NewValidationIssue( ErrCodeTaxCodeNotFound, "tax code not found", models.WithCriticalSeverity(), commonhttp.WithHTTPStatusCodeAttribute(http.StatusNotFound), )
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 IsTaxCodeNotFoundError ¶
func NewTaxCodeNotFoundError ¶
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 ¶
func (GetOrCreateByAppMappingInput) Validate ¶
func (i GetOrCreateByAppMappingInput) Validate() error
type GetOrganizationDefaultTaxCodesInput ¶
type GetOrganizationDefaultTaxCodesInput struct {
Namespace string
Expand OrganizationDefaultTaxCodesExpand
}
func (GetOrganizationDefaultTaxCodesInput) Validate ¶
func (i GetOrganizationDefaultTaxCodesInput) Validate() error
type GetTaxCodeByAppMappingInput ¶
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 ¶
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 Service ¶
type Service interface {
TaxCodeService
OrganizationDefaultTaxCodesService
}
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 ¶
IsManagedBySystem returns true when this tax code was auto-created by the system.
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 ¶
func (i UpsertOrganizationDefaultTaxCodesInput) Validate() error
Click to show internal directories.
Click to hide internal directories.