taxes

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2017 License: Unlicense Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseCurrencyPayment

type BaseCurrencyPayment struct {
	// Payment holds original payment details.
	Payment Payment `yaml:"payment"`
	// Rate holds payment currency to base currency exchange rate on payment date.
	Rate float64 `yaml:"rate"`
	// Amount holds payment currency, converted to company base currency.
	Amount float64 `yaml:"amount"`
}

BaseCurrencyPayment holds payment details, converted to company base currency.

func CalcBaseCurrencyPayment

func CalcBaseCurrencyPayment(rates CurrencyRates, baseCurrency string, p Payment) (*BaseCurrencyPayment, error)

CalcBaseCurrencyPayment calculates payment amount in specified base currency.

type Calc

type Calc struct {
	// contains filtered or unexported fields
}

Calc is a tax calculator.

func NewCalc

func NewCalc(rates CurrencyRates) *Calc

NewCalc constructs new quarterly tax calculator.

func (*Calc) Calc

func (c *Calc) Calc(company Company, payments []Payment) ([]Tax, error)

Calc calculates company taxes.

type Company

type Company struct {
	// BaseCurrency holds company base (tax) currency, ISO 4217 (e.g., UAH).
	BaseCurrency string `yaml:"base_currency"`
	// TaxRate holds company tax rate (e.g., %5 - 0.05).
	TaxRate float64 `yaml:"tax_rate"`
}

Company holds company details.

type CurrencyRates

type CurrencyRates interface {
	Rate(from, to string, date time.Time) (float64, error)
}

CurrencyRates defines currency rates lookup.

type Payment

type Payment struct {
	// Date holds payment date.
	Date time.Time `yaml:"date"`
	// Currency holds payment currency, ISO 4217 (e.g., UAH).
	Currency string `yaml:"currency"`
	// Amount holds payment amount (in payment's currency).
	Amount float64 `yaml:"amount"`
}

Payment holds bank payment data.

type Quarter

type Quarter struct {
	// Year holds quarter's year.
	Year int `yaml:"year"`
	// Quarter holds quarter's number (1-based).
	Quarter int `yaml:"quarter"`
}

Quarter holds financial year quarter.

func QuarterOf

func QuarterOf(t time.Time) Quarter

QuarterOf returns quarted of a given time.

type Tax

type Tax struct {
	// Quarters holds financial year quarter.
	Quarter Quarter `yaml:"quarter"`
	// Payments holds quarterly company bank payments.
	Payments []BaseCurrencyPayment `yaml:"payments"`
	// Income holds quarterly company income.
	Income float64 `yaml:"income"`
	// Tax holds quarterly tax amount.
	Tax float64 `yaml:"tax"`
}

Tax holds tax details.

Jump to

Keyboard shortcuts

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