func (m *Money) IsZero() bool {
	return m.amount.val == 0
}
IsZero returns boolean of whether the value of Money is equals to zero.
package money
import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
)
var (
	UnmarshalJSON = defaultUnmarshalJSON
	MarshalJSON = defaultMarshalJSON
	ErrCurrencyMismatch = errors.New("currencies don't match")
)
func defaultUnmarshalJSON(m *Money, b []byte) error {
	data := make(map[string]interface{})
	err := json.Unmarshal(b, &data)
	if err != nil {
		return err
	}
	ref := New(int64(data["amount"].(float64)), data["currency"].(string))
	*m = *ref
	return nil
}
func defaultMarshalJSON(m Money) ([]byte, error) {
	buff := bytes.NewBufferString(fmt.Sprintf(`{"amount": %d, "currency": "%s"}`, m.Amount(), m.Currency().Code))
	return buff.Bytes(), nil
}
type Amount struct {
	val int64
}
type Money struct {
	amount   *Amount
	currency *Currency
}
func New(amount int64, code string) *Money {
	return &Money{
		amount:   &Amount{val: amount},
		currency: newCurrency(code).get(),
	}
}
func (m *Money) Currency() *Currency {
	return m.currency
}
func (m *Money) Amount() int64 {
	return m.amount.val
}
func (m *Money) SameCurrency(om *Money) bool {
	return m.currency.equals(om.currency)
}
func (m *Money) assertSameCurrency(om *Money) error {
	if !m.SameCurrency(om) {
		return ErrCurrencyMismatch
	}
	return nil
}
func (m *Money) compare(om *Money) int {
	switch {
	case m.amount.val > om.amount.val:
		return 1
	case m.amount.val < om.amount.val:
		return -1
	}
	return 0
}
func (m *Money) Equals(om *Money) (bool, error) {
	if err := m.assertSameCurrency(om); err != nil {
		return false, err
	}
	return m.compare(om) == 0, nil
}
func (m *Money) GreaterThan(om *Money) (bool, error) {
	if err := m.assertSameCurrency(om); err != nil {
		return false, err
	}
	return m.compare(om) == 1, nil
}
func (m *Money) GreaterThanOrEqual(om *Money) (bool, error) {
	if err := m.assertSameCurrency(om); err != nil {
		return false, err
	}
	return m.compare(om) >= 0, nil
}
func (m *Money) LessThan(om *Money) (bool, error) {
	if err := m.assertSameCurrency(om); err != nil {
		return false, err
	}
	return m.compare(om) == -1, nil
}
func (m *Money) LessThanOrEqual(om *Money) (bool, error) {
	if err := m.assertSameCurrency(om); err != nil {
		return false, err
	}
	return m.compare(om) <= 0, nil
}