Show / Hide Table of Contents

Class CurrencyConversionHelper

Currency conversions, the one-stop-shop. Methods and properties for determining whether currency is enabled, and for doing currency conversions.

Inheritance
object
CurrencyConversionHelper
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.CRM.Rows.Util
Assembly: SoDataBase.dll
Syntax
public static class CurrencyConversionHelper

Properties

HomeCountryCurrency

Currency conversions, the one-stop-shop. Methods and properties for determining whether currency is enabled, and for doing currency conversions.

Declaration
public static CurrencyRecordData HomeCountryCurrency { get; }
Property Value
Type Description
CurrencyRecordData

HomeCountryCurrencyId

Currency conversions, the one-stop-shop. Methods and properties for determining whether currency is enabled, and for doing currency conversions.

Declaration
public static int HomeCountryCurrencyId { get; }
Property Value
Type Description
int

Methods

BaseCurrency()

Retrieve the Currency row of the base currency; if it does not exist or currency is disabled, null is returned

Declaration
public static CurrencyRecordData BaseCurrency()
Returns
Type Description
CurrencyRecordData

BaseCurrencyAsync(CancellationToken)

Retrieve the Currency row of the base currency; if it does not exist or currency is disabled, null is returned

Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public static Task<CurrencyRecordData> BaseCurrencyAsync(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken
Returns
Type Description
Task<CurrencyRecordData>

BaseCurrencyId()

Retrieve the ID of the 'base' currency (preference)

Declaration
public static int BaseCurrencyId()
Returns
Type Description
int

BaseCurrencyIdAsync(CancellationToken)

Retrieve the ID of the 'base' currency (preference)

Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public static Task<int> BaseCurrencyIdAsync(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken
Returns
Type Description
Task<int>

ConvertAmount(double, CurrencyRecordData, CurrencyRecordData)

Convert an amount from one currency to another, based on currency rows of the currencies involved. This method is silently fail-safe and will return the original amount unconverted if any errors occur (like missing currencies, rate=0 or other nasty things that can happen).

Declaration
public static double ConvertAmount(double amount, CurrencyRecordData from, CurrencyRecordData to)
Parameters
Type Name Description
double amount

Amount to convert

CurrencyRecordData from

Currency record to convert from

CurrencyRecordData to

Currency record to convert to

Returns
Type Description
double

Converted amount, or original if anything went wrong (silent failure)

ConvertAmount(double, double, double, double, double)

Convert an amount from one currency to another, based on the rates and units of the currencies involved. This method is silently fail-safe and will return the original amount unconverted if any errors occur (like missing currencies, rate=0 or other nasty things that can happen).

Declaration
public static double ConvertAmount(double amount, double fromRate, double fromUnits, double toRate, double toUnits)
Parameters
Type Name Description
double amount

Amount to convert

double fromRate

Currency rate of original currency

double fromUnits

Units of rate of original currency

double toRate

Currency rate of target currency

double toUnits

Units of rate of target currency

Returns
Type Description
double

Converted amount, or original if anything went wrong (silent failure)

ConvertAmount(double, int, int)

Convert an amount from one currency to another, based on the ID's of the currencies involved. This method is silently fail-safe and will return the original amount unconverted if any errors occur (like missing currencies, rate=0 or other nasty things that can happen).

Declaration
public static double ConvertAmount(double amount, int fromCurrencyId, int toCurrencyId)
Parameters
Type Name Description
double amount

Amount to convert

int fromCurrencyId

ID of currency to convert from

int toCurrencyId

ID of currency to convert to

Returns
Type Description
double

Converted amount, or original if anything went wrong (silent failure)

ConvertAmountToBase(double, int)

Convert an amount from a currency to base corrency for the database, based on the ID's of the currencies involved. This method is silently fail-safe and will return the original amount unconverted if any errors occur (like missing currencies, rate=0 or other nasty things that can happen).

Declaration
public static double ConvertAmountToBase(double amount, int fromCurrencyId)
Parameters
Type Name Description
double amount

Amount to convert

int fromCurrencyId

ID of currency to convert from

Returns
Type Description
double

Converted amount, or original if anything went wrong (silent failure)

ConvertAmountToBaseAsync(double, int, CancellationToken)

Convert an amount from a currency to base corrency for the database, based on the ID's of the currencies involved. This method is silently fail-safe and will return the original amount unconverted if any errors occur (like missing currencies, rate=0 or other nasty things that can happen).

Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public static Task<double> ConvertAmountToBaseAsync(double amount, int fromCurrencyId, CancellationToken cancellationToken = default)
Parameters
Type Name Description
double amount

Amount to convert

int fromCurrencyId

ID of currency to convert from

CancellationToken cancellationToken
Returns
Type Description
Task<double>

Converted amount, or original if anything went wrong (silent failure)

ConvertAmountToOur(double, int)

Convert an amount from a currency to own corrency set as a preference, based on the ID's of the currencies involved. This method is silently fail-safe and will return the original amount unconverted if any errors occur (like missing currencies, rate=0 or other nasty things that can happen).

Declaration
public static double ConvertAmountToOur(double amount, int fromCurrencyId)
Parameters
Type Name Description
double amount

Amount to convert

int fromCurrencyId

ID of currency to convert from

Returns
Type Description
double

Converted amount, or original if anything went wrong (silent failure)

ConvertAmountToOurAsync(double, int, CancellationToken)

Convert an amount from a currency to own corrency set as a preference, based on the ID's of the currencies involved. This method is silently fail-safe and will return the original amount unconverted if any errors occur (like missing currencies, rate=0 or other nasty things that can happen).

Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public static Task<double> ConvertAmountToOurAsync(double amount, int fromCurrencyId, CancellationToken cancellationToken = default)
Parameters
Type Name Description
double amount

Amount to convert

int fromCurrencyId

ID of currency to convert from

CancellationToken cancellationToken
Returns
Type Description
Task<double>

Converted amount, or original if anything went wrong (silent failure)

GetOurCurrencyId()

Calculates the currency id for the current user

Declaration
public static int GetOurCurrencyId()
Returns
Type Description
int

GetOurCurrencyIdAsync(CancellationToken)

Calculates the currency id for the current user

Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public static Task<int> GetOurCurrencyIdAsync(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken
Returns
Type Description
Task<int>

GetOwnerCompanysCurrencyIdAsync(CancellationToken)

Currency conversions, the one-stop-shop. Methods and properties for determining whether currency is enabled, and for doing currency conversions.

Declaration
public static Task<int> GetOwnerCompanysCurrencyIdAsync(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken
Returns
Type Description
Task<int>

IsCurrencyEnabled()

Is the use of currency enabled (preference)?

Declaration
public static bool IsCurrencyEnabled()
Returns
Type Description
bool

IsCurrencyEnabledAsync(CancellationToken)

Is the use of currency enabled (preference)?

Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public static Task<bool> IsCurrencyEnabledAsync(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken
Returns
Type Description
Task<bool>

OurCurrencyAsync(CancellationToken)

Retrieve the Currency row of our currency; if it does not exist or currency is disabled, null is returned

Declaration
public static Task<CurrencyRecordData> OurCurrencyAsync(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken
Returns
Type Description
Task<CurrencyRecordData>

OurCurrencyId()

Retrieve the ID of 'our' currency (preference). BaseCurrencyId will be returned if our currency is not defined.

Declaration
public static int OurCurrencyId()
Returns
Type Description
int

OurCurrencyIdAsync(CancellationToken)

Retrieve the ID of 'our' currency (preference). BaseCurrencyId will be returned if our currency is not defined.

Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public static Task<int> OurCurrencyIdAsync(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken
Returns
Type Description
Task<int>
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top