currencyutil

package
v0.8.13 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatMoney

func FormatMoney(symbol string, amount float64, precision int) string

Types

type Amount

type Amount struct {
	Value decimal.Decimal
	Unit  string
}

func MustNewAmountInt

func MustNewAmountInt(u string, v int64, exp int32) Amount

func NewAmountFloat

func NewAmountFloat(u string, v float64) (Amount, error)

func NewAmountInt

func NewAmountInt(u string, v int64, exp int32) (Amount, error)

func ParseAmount

func ParseAmount(value string) (Amount, error)

func (*Amount) Add

func (amt *Amount) Add(a Amount) error

func (*Amount) Equal

func (amt *Amount) Equal(a Amount) bool

func (Amount) MustStringFixed

func (amt Amount) MustStringFixed(places int32, defaultUnit string) string

type Amounts

type Amounts []Amount

func (Amounts) Sum

func (amts Amounts) Sum() (Amount, error)

type Formatter

type Formatter struct {
	Accounting           accounting.Accounting
	SymbolPrefix         string
	DefaultISOCode       string
	PrefixCodeDefault    bool
	PrefixCodeNonDefault bool
}

func NewFormatter

func NewFormatter(symbol string) Formatter

func (*Formatter) FormatMoney

func (f *Formatter) FormatMoney(symbol string, amount float64) string

func (*Formatter) FormatMoneyString

func (f *Formatter) FormatMoneyString(symbol string, amountString string) (string, error)

Jump to

Keyboard shortcuts

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