Documentation
¶
Index ¶
- type Amount
- type Currency
- type Formatter
- type Money
- func (m *Money) Absolute() *Money
- func (m *Money) Add(om *Money) (*Money, error)
- func (m *Money) Allocate(rs ...int) ([]*Money, error)
- func (m *Money) Amount() int64
- func (m *Money) Currency() *Currency
- func (m *Money) Display() string
- func (m *Money) Divide(div int64) *Money
- func (m *Money) Equals(om *Money) (bool, error)
- func (m *Money) GreaterThan(om *Money) (bool, error)
- func (m *Money) GreaterThanOrEqual(om *Money) (bool, error)
- func (m *Money) IsNegative() bool
- func (m *Money) IsPositive() bool
- func (m *Money) IsZero() bool
- func (m *Money) LessThan(om *Money) (bool, error)
- func (m *Money) LessThanOrEqual(om *Money) (bool, error)
- func (m *Money) Multiply(mul int64) *Money
- func (m *Money) Negative() *Money
- func (m *Money) Round() *Money
- func (m *Money) SameCurrency(om *Money) bool
- func (m *Money) Split(n int) ([]*Money, error)
- func (m *Money) Subtract(om *Money) (*Money, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Amount ¶
type Amount struct {
// contains filtered or unexported fields
}
Amount is a datastructure that stores the amount being used for calculations.
type Currency ¶
type Currency struct {
Code string
Fraction int
Grapheme string
Template string
Decimal string
Thousand string
}
Currency represents money currency information required for formatting.
func AddCurrency ¶ added in v0.2.0
AddCurrency lets you insert or update currency in currencies list.
func GetCurrency ¶ added in v0.3.5
GetCurrency returns the currency given the code.
type Formatter ¶
type Formatter struct {
Fraction int
Decimal string
Thousand string
Grapheme string
Template string
}
Formatter stores Money formatting information.
func NewFormatter ¶
NewFormatter creates new Formatter instance.
type Money ¶
type Money struct {
// contains filtered or unexported fields
}
Money represents monetary value information, stores currency and amount value.
func (*Money) Absolute ¶
Absolute returns new Money struct from given Money using absolute monetary value.
func (*Money) Add ¶
Add returns new Money struct with value representing sum of Self and Other Money.
func (*Money) Allocate ¶
Allocate returns slice of Money structs with split Self value in given ratios. It lets split money by given ratios without losing pennies and as Split operations distributes leftover pennies amongst the parties with round-robin principle.
func (*Money) Display ¶ added in v0.1.0
Display lets represent Money struct as string in given Currency value.
func (*Money) Divide ¶
Divide returns new Money struct with value representing Self division value by given divider.
func (*Money) GreaterThan ¶
GreaterThan checks whether the value of Money is greater than the other.
func (*Money) GreaterThanOrEqual ¶
GreaterThanOrEqual checks whether the value of Money is greater or equal than the other.
func (*Money) IsNegative ¶
IsNegative returns boolean of whether the value of Money is negative.
func (*Money) IsPositive ¶
IsPositive returns boolean of whether the value of Money is positive.
func (*Money) LessThanOrEqual ¶
LessThanOrEqual checks whether the value of Money is less or equal than the other.
func (*Money) Multiply ¶
Multiply returns new Money struct with value representing Self multiplied value by multiplier.
func (*Money) Negative ¶
Negative returns new Money struct from given Money using negative monetary value.
func (*Money) SameCurrency ¶
SameCurrency check if given Money is equals by currency.
