taxes

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package taxes provides functionality for calculating taxes.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTaxRateNotFound returned when no tax rate found in taxrates.
	ErrTaxRateNotFound = errors.New("tax rate not found")
	// ErrTaxTypeNotSupported returned when TaxType has invalid value.
	ErrTaxTypeNotSupported = errors.New("tax type not supported")
)
View Source
var ErrInvalidTaxType = errors.New("invalid tax type")

ErrInvalidTaxType returned when tax type is invalid.

Functions

This section is empty.

Types

type Response

type Response struct {
	Money models.Money
	Rate  TaxRate
}

Response represents result of Calc.

func Calc

func Calc(income models.Money, taxType TaxType) (Response, error)

Calc returns sum of tax for income according to TaxType.

type TaxRate

type TaxRate struct {
	Type TaxType
	Rate float64
}

TaxRate represents tuple TaxType - rate.

func AllTaxRates

func AllTaxRates() ([]TaxRate, error)

AllTaxRates returns all supported TaxRate.

func (TaxRate) String

func (t TaxRate) String() string

type TaxType

type TaxType uint

TaxType represents tax type for calculation.

const (

	// TaxTypeIndividualEntrepreneur is Individual Entrepreneur tax type.
	TaxTypeIndividualEntrepreneur TaxType // Individual Entrepreneur
	// TaxTypeSmallBusiness is Small Business tax type.
	TaxTypeSmallBusiness // Small Business
	// TaxTypeEmployment is Employment tax type.
	TaxTypeEmployment // Employment

)

func AllTaxTypes

func AllTaxTypes() []TaxType

AllTaxTypes returns all supported TaxType.

func ParseTaxType

func ParseTaxType(raw string) (TaxType, error)

ParseTaxType parses TaxType from string.

func (TaxType) Rate

func (i TaxType) Rate() (TaxRate, error)

Rate convert TaxType to TaxRate.

func (TaxType) String

func (i TaxType) String() string

func (TaxType) Valid

func (i TaxType) Valid() bool

Valid checks if value of TaxType is in valid borders.

Jump to

Keyboard shortcuts

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