number-to-currency-formatter
Reactive icon

Number To Currency Formatter

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 23 February 2024
 by 
5.0
 (2 ratings)
number-to-currency-formatter

Number To Currency Formatter

Documentation
1.0.0

Number To Currency Documentation

  • If your application needs a hassle-free way to format decimal values into desired currency formats, our Number To Currency component is here to make your life easier. This tool offers Client actions that effortlessly convert decimal numbers into strings, representing them in a locale-specific format.
  • Behind the scenes, we leverage the magic of the toLocaleString() method in JavaScript. This method takes a decimal number and transforms it into a string that aligns with the user's locale and formatting preferences. Think commas as thousand separators and the right decimal separator – all handled seamlessly.
  • Here's how it works: the library methods take a decimal number as input and, like magic, return a beautifully formatted string. You can customize the formatting based on your locale settings or stick with the defaults.


Input Handling: Streamlined and Efficient


  • To ensure a seamless user experience, almost all possible input values, including Compact Display types, Currency Display types, Notation types, and Style lists, have been meticulously added through list appending.
  • For inputs with a multitude of possible items, such as currency and locales, a strategic decision has been made to store these values as JSON resources within the library for both NumberToCurrency_Simple and NumberToCurrency_Advanced actions.
  • This approach not only optimizes the handling of extensive options but also enhances the maintainability and scalability of the application. It reflects our commitment to providing a robust and user-friendly solution for your currency formatting needs.
  • Our library module boasts two actions, giving you the flexibility to choose between a simple or advanced approach to currency formatting. Let's dive in and explore the possibilities!


1) NumberToCurrency_Simple: Client Action Overview


  • Introducing NumberToCurrency_Simple, a client action designed for efficient currency formatting through the utilization of JavaScript's toLocaleString() method.
  • This client action accepts parameters including the numerical value, preferred locale, chosen currency, and the desired display format. By leveraging these options, NumberToCurrency_Simple produces a meticulously formatted currency string.
  • With precision at its core, this client action ensures a professional and polished presentation of numeric data in your specified currency format. It's a tool designed for effectiveness without compromising on sophistication. Explore the capabilities of NumberToCurrency_Simple and elevate the currency representation in your application.


Example 1: Number To Currency Simple

Parameters:

  1. Number: 15000.50
  2. Locale: en-US (Any Unicode CLDR Value)
  3. Currency: INR (Any Unicode CLDR Value)
  4. Currency Display: Symbol (Code or Name are also options)

Formatted Output: ₹15,000.5

In this example, NumberToCurrency_Simple transforms the given numerical value into a currency string using the specified locale, currency, and display preferences. The result is precisely formatted output in Indian Rupees (INR) with the currency symbol, showcasing the flexibility and accuracy of the component.


2) NumberToCurrency_Advanced: Client Action Overview


  • NumberToCurrency_Advanced is a client action leveraging JavaScript's toLocaleString() method for precise currency formatting. This advanced option provides a range of customizable parameters to meet diverse formatting needs.
  • Accepted Options:
  1. Number
  2. Locale
  3. Currency
  4. Currency Display
  5. Style
  6. Minimum Integer Digits
  7. Maximum Integer Digits
  8. Maximum Fraction Digits
  9. Use Grouping
  10. Notation
  11. Compact Display
  12. Set Minimum and Maximum Significant Digits
  • These configurable options afford you the ability to finely tune your currency representation. Whether it's controlling decimal precision, adjusting notation, or specifying compact display, NumberToCurrency_Advanced caters to a multitude of formatting requirements.
  • Use this client action to generate a meticulously formatted currency string tailored to your specifications. It's a versatile tool designed for precision and flexibility in currency presentation.


Example 1: Number To Currency Advanced

Parameters:

  1. Number: 15000.50
  2. Locale: en-US (Any Unicode CLDR Value)
  3. Currency: INR (Any Unicode CLDR Value)
  4. Currency Display (only when style is currency): Symbol (Code or Name are also options)
  5. Style: currency (Can be decimal or percent)
  6. Minimum Integer Digits: Default (1)
  7. Maximum Integer Digits: Default (0)
  8. Maximum Fraction Digits: Default (2)
  9. Use Grouping: True
  10. Notation: compact (Can be engineering, scientific, or standard)
  11. Compact Display (only when notation is compact): short (Can be long also)
  12. Set Significant Digits: True (For setting minimum and maximum significant digits if required)

Formatted Output: ₹15K

In this example, Number To Currency Advanced takes a numerical value and applies advanced formatting based on specified parameters. The result is a formatted output in Indian Rupees (INR) with the currency symbol, adhering to compact notation, and with a minimum and maximum significant digits configuration.