Class Currencies
- Namespace
- Integrations.Domain.Common
- Assembly
- Integrations.Domain.dll
Currency helpers. Amounts are carried at full precision internally and rounded only at the edges (API responses, events) using Round(decimal, string).
public static class Currencies
- Inheritance
-
Currencies
- Inherited Members
Fields
AmountScale
Decimal places kept for intermediate amounts (DB: numeric(19,6)).
public const int AmountScale = 6
Field Value
RateScale
Decimal places kept for exchange rates (DB: numeric(28,12)).
public const int RateScale = 12
Field Value
Methods
IsValid(string?)
True when code is shaped like an ISO 4217 code (three upper-case letters).
public static bool IsValid(string? code)
Parameters
codestring
Returns
MinorUnits(string)
Decimal places the currency is posted in (2 unless ISO 4217 says otherwise, e.g. JPY 0, KWD 3).
public static int MinorUnits(string currency)
Parameters
currencystring
Returns
Normalize(string)
Trims and upper-cases a currency code; throws ArgumentException when it is not ISO 4217-shaped.
public static string Normalize(string code)
Parameters
codestring
Returns
Round(decimal, string)
Rounds for display/posting in the currency's minor units (half away from zero, the usual tax convention).
public static decimal Round(decimal amount, string currency)
Parameters
Returns
RoundAmount(decimal)
Rounds an intermediate amount to AmountScale places (storage precision).
public static decimal RoundAmount(decimal amount)
Parameters
amountdecimal
Returns
RoundRate(decimal)
Rounds an exchange rate to RateScale places (storage precision).
public static decimal RoundRate(decimal rate)
Parameters
ratedecimal