Click or drag to resize

Amount Class

Represents immutable amount with currency. Allows currency-safe amount calculcations.
Inheritance Hierarchy
SystemObject
  Aloe.EnterpriseOne.ModelAmount

Namespace:  Aloe.EnterpriseOne.Model
Assembly:  Aloe.EnterpriseOne.Model (in Aloe.EnterpriseOne.Model.dll) Version: 20.1.3.5
Syntax
public class Amount : IComparable, IComparable<Amount>, 
	IEquatable<Amount>, IValueWithMeasure<Currency>

The Amount type exposes the following members.

Constructors
  NameDescription
Public methodAmount
Initializes a new instance of the Amount class.
Top
Properties
  NameDescription
Public propertyCurrency
Gets the currency of the amount.
Public propertyValue
Gets the value of the amount.
Public propertyStatic memberZero
Gets the zero amount, with no currency.
Top
Methods
  NameDescription
Public methodStatic memberAdd
Returns the sum of the specified amounts. The amounts must have the same currency.
Public methodStatic memberAreCompatible
Returns true if the two amounts are compatible (e.g. have the same currency).
Public methodStatic memberCompare
Compares the amounts. The amounts must have the same currency.
Public methodCompareTo(Object)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Public methodCompareTo(Amount)
Compares the current object with another object of the same type.
Public methodStatic memberDivide(Amount, Amount)
Divides the dividend by the divisor.
Public methodStatic memberDivide(Amount, Decimal)
Divides the specified amount.
Public methodEquals(Object)
Determines whether the specified Object, is equal to this instance.
(Overrides ObjectEquals(Object).)
Public methodEquals(Amount)
Indicates whether the current object is equal to another object of the same type.
Public methodGetHashCode
Returns a hash code for this instance.
(Overrides ObjectGetHashCode.)
Public methodStatic memberMultiply
Multiplies the amount with the specified multiplier.
Public methodRound
Returns new Amount, which is rounded, according to the rules of the currency.
Public methodStatic memberSubtract
Subtracts the second amount from the first. The amounts must have the same currency.
Public methodToString
Returns a String that represents this instance.
(Overrides ObjectToString.)
Top
Operators
  NameDescription
Public operatorStatic memberAddition
Returns the sum of the specified amounts. The amounts must have the same currency.
Public operatorStatic memberDivision(Amount, Amount)
Implements the operator /.
Public operatorStatic memberDivision(Amount, Decimal)
Implements the operator /.
Public operatorStatic memberEquality
Implements the operator ==.
Public operatorStatic memberGreaterThan
Compares first and second.
Public operatorStatic memberGreaterThanOrEqual
Implements the operator >=.
Public operatorStatic memberInequality
Implements the operator !=.
Public operatorStatic memberLessThan
Implements the operator <.
Public operatorStatic memberLessThanOrEqual
Implements the operator <=.
Public operatorStatic memberMultiply(Decimal, Amount)
Implements the operator *.
Public operatorStatic memberMultiply(Amount, Decimal)
Implements the operator *.
Public operatorStatic memberSubtraction
Subtracts the second amount from the first. The amounts must have the same currency.
Top
Remarks

Amount supports basic amount arithmetic, which is currency-safe. For example, adding two amounts is currency-safe, because the two amounts are added successfully only if their currencies are the same (or one of the amounts is zero). This helps avoid errors of inadvertently doing amount arithmetic with incompatible currencies.

The following basic rules are true for Amount:

  • Amount(15, USD) + Amount(10, USD) == Amount(25, USD)
  • Amount(15, USD) + Amount(10, EUR) => Exception!
  • Amount(15, USD) + Amount(10, null) => Exception!
  • Amount(15, USD) + Amount(0, null) == Amount(15, USD)
  • Amount(15, USD) + Amount(0, EUR) == Amount(15, USD)
  • Amount(15, USD) + null == Amount(15, USD)
  • Amount(15, USD) * 3 == Amount(45, USD)
  • Amount(15, USD) > Amount(10, USD) == true
  • Amount(15, USD) > Amount(0, EUR) == true
  • Amount(15, USD) > Amount(10, EUR) => Exception!
  • Amount(15, USD) > null == true

See Also