class sap.ui.model.odata.type.Currency

Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Module: sap/ui/model/odata/type/Currency
Application Component: CA-UI5-COR

This class represents the Currency composite type with the parts amount, currency, and currency customizing. The type may only be used for amount and currency parts from a sap.ui.model.odata.v4.ODataModel or a sap.ui.model.odata.v2.ODataModel. The amount part is formatted according to the customizing for the currency. Use the result of the promise returned by sap.ui.model.odata.v4.ODataMetaModel#requestCurrencyCodes for OData V4 or by sap.ui.model.odata.ODataMetaModel#requestCurrencyCodes for OData V2 as currency customizing part. If no currency customizing is available, UI5's default formatting applies.


Constructor

Constructor for a Currency composite type.

new sap.ui.model.odata.type.Currency(oFormatOptions?, oConstraints?)
Param Type Default Value Description
oFormatOptions? object

See parameter oFormatOptions of sap.ui.model.type.Currency#constructor. Format options are immutable, that is, they can only be set once on construction. Format options that are not supported or have a different default are listed below. If the format option showMeasure is set to false, model messages for the currency code are not propagated to the control if the corresponding binding supports the feature of ignoring messages, see sap.ui.model.Binding#supportsIgnoreMessages, and the corresponding binding parameter is not set manually.

customCurrencies? object

Not supported; the type derives this from its currency customizing part.

parseAsString? boolean true

Whether the amount is parsed to a string; set to false if the amount's underlying type is represented as a number, for example sap.ui.model.odata.type.Int32

unitOptional? boolean

Whether the amount is parsed if no currency is entered; defaults to true if neither showMeasure nor showNumber is set to a falsy value, otherwise defaults to false

emptyString? any 0

Defines how an empty string is parsed into the amount. With the default value 0 the amount becomes 0 when an empty string is parsed.

preserveDecimals? boolean true

By default decimals are preserved, unless oFormatOptions.style is given as "short" or "long"; since 1.89.0

oConstraints? object

Only the 'skipDecimalsValidation' constraint is supported. Constraints are immutable, that is, they can only be set once on construction.

skipDecimalsValidation? boolean false

Whether to skip validation of the number of decimals based on the code list customizing; since 1.93.0


Methods Overview

Method Description
sap.ui.model.odata.type.Currency.extend

Creates a new subclass of class sap.ui.model.odata.type.Currency with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.model.type.Currency.extend.

formatValue

Formats the given values of the parts of the Currency composite type to the given target type.

sap.ui.model.odata.type.Currency.getMetadata

Returns a metadata object for class sap.ui.model.odata.type.Currency.

getName

Returns the type's name.

parseValue

Parses the given string value to an array containing amount and currency.

References:

  • sap.ui.model.type.Currency#parseValue

validateValue

Validates whether the given value in model representation as returned by #parseValue is valid and meets the conditions of this type's currency customizing.

sap.ui.model.odata.type.Currency.extend

Creates a new subclass of class sap.ui.model.odata.type.Currency with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.model.type.Currency.extend.

Param Type DefaultValue Description
sClassName string

Name of the class being created

oClassInfo object

Object literal with information about the class

FNMetaImpl function

Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class

formatValue

Formats the given values of the parts of the Currency composite type to the given target type.

Param Type DefaultValue Description
aValues any[]

Array of part values to be formatted; contains in the following order: amount, currency, currency customizing. The first call to this method where all parts are set determines the currency customizing; subsequent calls use this customizing, so that the corresponding part may be omitted. Changes to the currency customizing part after this first method call are not considered: The currency customizing for this Currency instance remains unchanged.

sTargetType string

The target type; must be "string" or a type with "string" as its primitive type. See sap.ui.model.odata.type for more information.

sap.ui.model.odata.type.Currency.getMetadata

Returns a metadata object for class sap.ui.model.odata.type.Currency.

getName

Returns the type's name.

parseValue

Parses the given string value to an array containing amount and currency.

References:

Param Type DefaultValue Description
vValue string

The value to be parsed

sSourceType string

The source type (the expected type of vValue); must be "string", or a type with "string" as its primitive type. See sap.ui.model.odata.type for more information.

aCurrentValues any[]

Not used

validateValue

Validates whether the given value in model representation as returned by #parseValue is valid and meets the conditions of this type's currency customizing.

Param Type DefaultValue Description
aValues any[]

An array containing amount and currency in this order, see return value of #parseValue