Table of Contents

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

int

RateScale

Decimal places kept for exchange rates (DB: numeric(28,12)).

public const int RateScale = 12

Field Value

int

Methods

IsValid(string?)

True when code is shaped like an ISO 4217 code (three upper-case letters).

public static bool IsValid(string? code)

Parameters

code string

Returns

bool

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

currency string

Returns

int

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

code string

Returns

string

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

amount decimal
currency string

Returns

decimal

RoundAmount(decimal)

Rounds an intermediate amount to AmountScale places (storage precision).

public static decimal RoundAmount(decimal amount)

Parameters

amount decimal

Returns

decimal

RoundRate(decimal)

Rounds an exchange rate to RateScale places (storage precision).

public static decimal RoundRate(decimal rate)

Parameters

rate decimal

Returns

decimal