Caplin Trader 5.1.0

Class: module:ct-element/parser/AmountParser

module:ct-element/parser/AmountParser()

new module:ct-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"

AmountParser.parse("4.9MM", {})

See module:ct-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