f0f1f2.studio Template reference
English
Open application
Method

GetSumInAdditionalCurrency

Definition

Namespace
Resto.Front.PrintTemplates.Cheques.Razor

Converts an amount into an additional currency and rounds it down to that currency precision.

decimal TemplateBase<T>.GetSumInAdditionalCurrency(IAdditionalCurrency currency, decimal additionalCurrencyRate, decimal currentCurrencySum)
Returns
decimal
Nullability
Not null
Declared in
Resto.Front.PrintTemplates.Cheques.Razor.TemplateBase<T>
Model purpose
Base class for Legacy Razor print templates. Model contains the document data of type T. Provides formatting and markup output methods.

Parameters

IAdditionalCurrency currency
Additional currency whose IsoName selects the fractional precision; must not be null.
decimal additionalCurrencyRate
Units of current currency per one unit of additional currency; must be nonzero.
decimal currentCurrencySum
Amount in the current currency.

Return value

currentCurrencySum / additionalCurrencyRate, floored to the additional currency fractional precision.

Remarks

Reads only currency.IsoName. Uses a new currency descriptor with zero minimum denomination. Floor means toward negative infinity, including for negative amounts. The supplied rate is used directly; no exchange-rate lookup or positivity check is performed.

Exceptions

System.NullReferenceException
currency is null (the wrapper dereferences it without a guard).
System.ArgumentNullException
currency.IsoName is null.
System.Collections.Generic.KeyNotFoundException
The ISO code is absent from the engine currency catalog.
System.DivideByZeroException
additionalCurrencyRate is zero.
System.OverflowException
The quotient or rounding calculation exceeds the Decimal range.

Example

// additionalCurrency.IsoName == "USD" (2 fractional digits)
GetSumInAdditionalCurrency(additionalCurrency, 3m, 10m); // 3.33m
GetSumInAdditionalCurrency(additionalCurrency, 3m, -10m); // -3.34m