Documentation
¶
Index ¶
- type Formatter
- type Money
- func (m *Money) Absolute() *Money
- func (m *Money) Add(om *Money) *Money
- func (m *Money) Allocate(rs []int) ([]*Money, error)
- func (m *Money) Display() (string, error)
- func (m *Money) Divide(div int) *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 int) *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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 stores money information
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