/// <summary> /// Transform decimal part of amount to words. /// </summary> /// <param name="amount">Decimal number</param> /// <param name="currency">Currency</param> /// <returns>ArrayList of words</returns> private ArrayList DecimalPartToWords(decimal amount, Currency currency, CurrencyOptions currencyOptions) { var words = new ArrayList(); var decimalPartAsFraction = currencyOptions?.DecimalAsFraction ?? false; var hideSubunit = currencyOptions?.HideSubunit ?? false; var decimalPart = amount.GetDecimalPart(); var decimalWords = DecimalToWords(decimalPart, currency, decimalPartAsFraction, hideSubunit); words.AddRange(decimalWords); return(words); }
///<inheritdoc/> public string ToWords(decimal amount, CurrencySymbol currencySymbol, CurrencyOptions currencyOptions) { var currency = _currencyDictionary.GetCurrency(currencySymbol); var integerWords = IntegerPartToWords(amount, currency); var withDecimalPart = !currencyOptions?.IntegerPartOnly ?? true; var integerAndDecimalPartSeparator = currencyOptions?.IntegerAndDecimalPartSeparator; var decimalWords = new ArrayList(); if (withDecimalPart) { decimalWords = DecimalPartToWords(amount, currency, currencyOptions); } return(JoinNumberParts(integerWords, decimalWords, integerAndDecimalPartSeparator)); }