/// <summary>
        /// Converts <paramref name="amountToConvert">amountToConvert</paramref> to the base currency.
        /// </summary>
        /// <param name="amountToConvert">Amount to convert accounted in <paramref name="currency" />.</param>
        /// <param name="currency">ISO 4217 code for the currency that the <paramref name="amountToConvert" /> is accounted in.</param>
        /// <param name="currencyRate">Currency rate with respect to the <paramref name="baseCurrency" />
        /// for the currency that the <paramref name="amountToConvert" /> is accounted in.</param>
        /// <param name="baseCurrency">Base currency identified by ISO 4217 code.</param>
        /// <param name="amountSignificantDigits">Round order applied to the result.</param>
        /// <param name="currencyRateSignificantDigits">Round order applied to <paramref name="currencyRate" />.</param>
        /// <exception cref="ArgumentException">Parameters currencyRate, amountSignificantDigits
        /// and currencyRateSignificantDigits cannot be negative.</exception>
        /// <remarks>amountToConvert value in baseCurrency units</remarks>
        public static double ToBaseCurrency(this double amountToConvert, string currency,
                                            double currencyRate, string baseCurrency, int amountSignificantDigits = DefaultAmountSignificantDigits,
                                            int currencyRateSignificantDigits = DefaultCurrencyRateSignificantDigits)
        {
            if ((0.0).GreaterThan(currencyRate))
            {
                throw new ArgumentException(string.Format(Apskaita5.Common.Properties.Resources.ParameterCannotBeNegative,
                                                          nameof(currencyRate)), nameof(currencyRate));
            }
            if (amountSignificantDigits < 0)
            {
                throw new ArgumentException(string.Format(Apskaita5.Common.Properties.Resources.ParameterCannotBeNegative,
                                                          nameof(amountSignificantDigits)), nameof(amountSignificantDigits));
            }
            if (currencyRateSignificantDigits < 0)
            {
                throw new ArgumentException(string.Format(Apskaita5.Common.Properties.Resources.ParameterCannotBeNegative,
                                                          nameof(currencyRateSignificantDigits)), nameof(currencyRateSignificantDigits));
            }

            if (currency.IsBaseCurrency(baseCurrency))
            {
                return(amountToConvert.AccountingRound(amountSignificantDigits));
            }

            double validatedCurrencyRate = currencyRate.AccountingRound(currencyRateSignificantDigits);
            double validatedAmount       = amountToConvert.AccountingRound(amountSignificantDigits);

            return((validatedAmount * validatedCurrencyRate).AccountingRound(amountSignificantDigits));
        }
        /// <summary>
        /// Converts <paramref name="amountToConvert" /> accounted in currency <paramref name="originalCurrency" />
        /// with conversion rate <paramref name="originalCurrencyRate" /> with respect to <paramref name="baseCurrency" />
        /// to amount accounted in currency <paramref name="targetCurrency" /> with conversion rate
        /// <paramref name="targetCurrencyRate" /> with respect to <paramref name="baseCurrency" />.
        /// </summary>
        /// <param name="amountToConvert">Amount to convert accounted in <paramref name="originalCurrency" />.</param>
        /// <param name="originalCurrency">ISO 4217 code for the currency that the <paramref name="amountToConvert" /> is accounted in.</param>
        /// <param name="originalCurrencyRate">Currency rate with respect to the <paramref name="baseCurrency" />
        /// for the currency that the <paramref name="amountToConvert" /> is accounted in. (should be zero or positive)</param>
        /// <param name="targetCurrency">ISO 4217 code for the currency that the returned value is accounted in.</param>
        /// <param name="targetCurrencyRate">Currency rate with respect to the <paramref name="baseCurrency" />
        /// for the currency that the returned value is accounted in.(should be zero or positive)</param>
        /// <param name="baseCurrency">Base currency identified by ISO 4217 code.</param>
        /// <param name="amountSignificantDigits">Round order applied to the result.</param>
        /// <param name="currencyRateSignificantDigits">Round order applied to <paramref name="originalCurrencyRate" />
        /// and <paramref name="targetCurrencyRate" />.</param>
        /// <param name="defaultAmount">Return value in case a conversion is not possible,
        /// e.g. <paramref name="targetCurrencyRate" /> is zero.</param>
        /// <returns><paramref name="amountToConvert" /> converted to <paramref name="targetCurrency" />.</returns>
        /// <returns>amountToConvert value in targetCurrency units</returns>
        /// <exception cref="ArgumentException">Parameters originalCurrencyRate, targetCurrencyRate,
        /// amountSignificantDigits and currencyRateSignificantDigits cannot be negative.</exception>
        public static double ToCurrency(this double amountToConvert, string originalCurrency,
                                        double originalCurrencyRate, string targetCurrency, double targetCurrencyRate,
                                        string baseCurrency, int amountSignificantDigits = DefaultAmountSignificantDigits,
                                        int currencyRateSignificantDigits = DefaultCurrencyRateSignificantDigits,
                                        double defaultAmount = DefaultAmountDouble)
        {
            if ((0.0).GreaterThan(originalCurrencyRate))
            {
                throw new ArgumentException(string.Format(Properties.Resources.ParameterCannotBeNegative,
                                                          nameof(originalCurrencyRate)), nameof(originalCurrencyRate));
            }
            if ((0.0).GreaterThan(targetCurrencyRate))
            {
                throw new ArgumentException(string.Format(Properties.Resources.ParameterCannotBeNegative,
                                                          nameof(targetCurrencyRate)), nameof(targetCurrencyRate));
            }
            if (amountSignificantDigits < 0)
            {
                throw new ArgumentException(string.Format(Properties.Resources.ParameterCannotBeNegative,
                                                          nameof(amountSignificantDigits)), nameof(amountSignificantDigits));
            }
            if (currencyRateSignificantDigits < 0)
            {
                throw new ArgumentException(string.Format(Properties.Resources.ParameterCannotBeNegative,
                                                          nameof(currencyRateSignificantDigits)), nameof(currencyRateSignificantDigits));
            }

            // zero remains zero in any currency
            if (amountToConvert.AccountingRound(amountSignificantDigits).EqualsTo(0.0, amountSignificantDigits))
            {
                return(0);
            }

            // if the currencies are the same, amount is the same
            if (originalCurrency.IsSameCurrency(targetCurrency, baseCurrency))
            {
                return(amountToConvert.AccountingRound(amountSignificantDigits));
            }

            // base currency rate with respect to itself is always 1
            double validatedOriginalCurrencyRate = originalCurrencyRate;

            if (originalCurrency.IsBaseCurrency(baseCurrency))
            {
                validatedOriginalCurrencyRate = 1;
            }

            double validatedTargetCurrencyRate = targetCurrencyRate;

            if (targetCurrency.IsBaseCurrency(baseCurrency))
            {
                validatedTargetCurrencyRate = 1;
            }

            // apply currencyRateSignificantDigits
            validatedOriginalCurrencyRate = validatedOriginalCurrencyRate.AccountingRound(currencyRateSignificantDigits);
            validatedTargetCurrencyRate   = validatedTargetCurrencyRate.AccountingRound(currencyRateSignificantDigits);

            // do calculus if possible
            if (validatedTargetCurrencyRate.GreaterThan(0.0, currencyRateSignificantDigits))
            {
                return(((amountToConvert * validatedOriginalCurrencyRate).AccountingRound(amountSignificantDigits)
                        / validatedTargetCurrencyRate).AccountingRound(amountSignificantDigits));
            }

            return(defaultAmount.AccountingRound(amountSignificantDigits));
        }
 /// <summary>
 /// Gets a string that represents the value formated by the ffdata standarts.
 /// </summary>
 /// <param name="value">number to format</param>
 public static string ToFFDataFormat(this double value)
 {
     return(value.AccountingRound(2).ToString("#.00", CultureInfo.InvariantCulture));
 }