Class

money

Money

Related Doc: package money

Permalink

case class Money(amount: BigDecimal, currency: Currency)(implicit converter: Converter) extends Ordered[Money] with Product with Serializable

This is the main class of the lib. A Money is represented by its amount and currency.

amount

the amount of this money

currency

the currency for this money

Since

2014-10-27

Linear Supertypes
Serializable, Serializable, Product, Equals, Ordered[Money], Comparable[Money], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Money
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. Ordered
  7. Comparable
  8. AnyRef
  9. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Money(amount: BigDecimal, currency: Currency)(implicit converter: Converter)

    Permalink

    amount

    the amount of this money

    currency

    the currency for this money

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. def !==(that: Money): Boolean

    Permalink

    Converts that money to this currency and then compares the resulting amounts.

    Converts that money to this currency and then compares the resulting amounts.

    IMPORTANT NOTE: It's consistency is the one explained in the compare method.

    that

    the other Money object

    returns

    true if this !== that, false otherwise

  3. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  4. def *(thatAmount: BigDecimal): Money

    Permalink

    Multiplies amount by this money.

    Multiplies amount by this money.

    thatAmount

    the amount to multiply by this money

    returns

    a new object which is the result of multiplying amount to this money

  5. def +(that: BigDecimal): Money

    Permalink

    Adds amount to this money.

    Adds amount to this money.

    that

    the amount to sum to this money

    returns

    a new object which is the result of summing amount to this money

  6. def +(that: Money): Money

    Permalink

    Adds this money to that.

    Adds this money to that. The result is expressed in terms of this money's currency.

    that

    the money to sum to this money

    returns

    a new object which is the result of summing this money to that after converting that to this money's currency

  7. def -(that: BigDecimal): Money

    Permalink

    Subtracts amount from this money.

    Subtracts amount from this money.

    that

    the amount to sum to this money

    returns

    a new object which is the result of summing amount to this money

  8. def -(that: Money): Money

    Permalink

    Subtracts that from this money.

    Subtracts that from this money. The result is expressed in terms of this money's currency.

    that

    the money to subtract from this money

    returns

    a new object which is the result of subtracting that from this money after converting that to this money's currency

  9. def /(thatAmount: BigDecimal): Money

    Permalink

    Divides amount by this money.

    Divides amount by this money.

    thatAmount

    the amount to multiply by this money

    returns

    a new object which is the result of multiplying amount to this money

  10. def <(that: Money): Boolean

    Permalink
    Definition Classes
    Ordered
  11. def <=(that: Money): Boolean

    Permalink
    Definition Classes
    Ordered
  12. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  13. def ===(that: Money): Boolean

    Permalink

    Converts that money to this currency and then compares the resulting amounts.

    Converts that money to this currency and then compares the resulting amounts.

    IMPORTANT NOTE: It's consistency is the one explained in the compare method.

    that

    the other Money object

    returns

    true if this === that, false otherwise

  14. def >(that: Money): Boolean

    Permalink
    Definition Classes
    Ordered
  15. def >=(that: Money): Boolean

    Permalink
    Definition Classes
    Ordered
  16. val amount: BigDecimal

    Permalink

    the amount of this money

  17. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  18. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. def compare(that: Money): Int

    Permalink

    Converts that money to this currency and then compares the amounts.

    Converts that money to this currency and then compares the amounts.

    IMPORTANT NOTE: Be careful when using compare since it might seem inconsistent because if the conversion rate from, say, EUR to USD is 1.13 it's not guaranteed that the one from USD to EUR is exactly 1 / 1.13 (i.e. the inverse). For this reason, for example, you could have: 100(EUR).compare(113(USD)) > 0 == true // (1) // but 113(USD).compare(100(EUR)) < 0 == false // (2)

    This is because that is first converted to this currency and then the resulting amounts are compared. The rule is as simple as the outer left currency is the base one into which all other currencies are converted within an expression. In the previous example (1) 113 USD is converted to EUR and then compared to 100 EUR. In example (2) it's 100 EUR that is converted to USD and then compared. Since the conversion rates are not one the inverse of the other you get apparently inconsistent results even if, for the provided conversions, they are consistent.

    that

    the other Money object

    returns

    an Int that is:

    • < 0 if this < that
    • > 0 if this > that
    • 0 if they are equal (after currency conversion, of course)
    Definition Classes
    Money → Ordered
  20. def compareTo(that: Money): Int

    Permalink
    Definition Classes
    Ordered → Comparable
  21. val currency: Currency

    Permalink

    the currency for this money

  22. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  23. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  24. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  25. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  26. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  27. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  28. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  29. def round(decimalDigits: Int, roundingMode: RoundingMode = RoundingMode.HALF_DOWN): Money

    Permalink

    Rounds this Money to the given number of decimalDigits using the provided roundingMode

    Rounds this Money to the given number of decimalDigits using the provided roundingMode

    decimalDigits

    the number of decimal digits to keep

    returns

    a new Money object whose number of decimal digits is decimalDigits

  30. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  31. def to(thatCurrency: Currency): Money

    Permalink

    Converts this money to another money represented using otherCurrency

    Converts this money to another money represented using otherCurrency

    thatCurrency

    the currency to convert this money to

    returns

    a new object where its currency is expressed in terms of otherCurrency

  32. def toFormattedString(decimalDigits: Int = 5): String

    Permalink

    Formats this money object using a number of decimal digits equals to the decimalDigits param, which defaults to 5.

    Formats this money object using a number of decimal digits equals to the decimalDigits param, which defaults to 5.

    decimalDigits

    the number of decimal digits to include

    returns

    a formatted string representing this money object

  33. def toString(): String

    Permalink

    returns

    the string representation of this money which has, at most, 5 decimal digits. If you need to customize the number of decimal digits use toFormattedString instead

    Definition Classes
    Money → AnyRef → Any
  34. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  36. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from Ordered[Money]

Inherited from Comparable[Money]

Inherited from AnyRef

Inherited from Any

Ungrouped