Caplin Trader 4.5.2

Class: module:caplin/element/parser/AmountParser

module:caplin/element/parser/AmountParser

Constructor

new module:caplin/element/parser/AmountParser()

Parses an amount containing a thousands, millions or billions token into a number.

AmountParser is typically used in the XML Renderer Framework, but can be invoked programmatically as in the following example which evaluates to "4900000"

caplin.element.parser.AmountParser.parse("4.9MM", {})

See module:caplin/element/formatter/AmountFormatter for the complementary formatter.
Implements:

Methods

parse(vValue, attributes) → {String}

Parses an amount containing a thousands, millions or billions token into a number. If the amount does not match, then null is returned.
Parameters:
Name Type Description
vValue Variant the amount with tokens
attributes Map the map of attributes.
Properties
Name Type Attributes Default Description
thousands String <optional>
K the token representing thousands
millions String <optional>
M the token representing millions
billions String <optional>
B the token representing billions
Returns:
the numeric amount, or null if the value was not recognized.
Type
String