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 for a Currency
composite type.
new sap.ui.model.odata.type.Currency(oFormatOptions?, oConstraints?)
Param | Type | Default Value | Description |
---|---|---|---|
oFormatOptions? | object | See parameter |
|
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 |
unitOptional? | boolean | Whether the amount is parsed if no currency is entered; defaults to |
|
emptyString? | any | 0 | Defines how an empty string is parsed into the amount. With the default value |
preserveDecimals? | boolean | true | By default decimals are preserved, unless |
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 |
Method | Description |
---|---|
sap.ui.model.odata.type.Currency.extend |
Creates a new subclass of class sap.ui.model.odata.type.Currency with name
|
formatValue |
Formats the given values of the parts of the |
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.
|
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. |
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 |
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 |
|
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. |
Returns a metadata object for class sap.ui.model.odata.type.Currency.
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 |
|
aCurrentValues | any[] |
Not used |
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 |