openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

sap.ui.model.type.Currency shortRefNumber does not work with 1000

Open aboccassiniavvale opened this issue 2 years ago • 7 comments

OpenUI5 version: 1.122.0

Browser/version (+device/version): Google Chrome 123.0.6312.122

Any other tested browsers/devices(OK/FAIL):

URL (minimal example if possible): https://sapui5.hana.ondemand.com/#/entity/sap.ui.model.type.Currency/sample/sap.ui.core.sample.TypeCurrency

User/password (if required and possible - do not post any confidential information here):

Steps to reproduce the problem:

  1. Open https://sapui5.hana.ondemand.com/#/entity/sap.ui.model.type.Currency/sample/sap.ui.core.sample.TypeCurrency
  2. Change the "style:'short'" example with
<Label text="style:'short'" />
<Text text="{
  parts: ['/amount', '/currency'],
  type: 'sap.ui.model.type.Currency',
  formatOptions: {
	  style : 'short',
          shortRefNumber: 1000
  }
}" />
  1. The example shown will lose the formatting
  2. If you change the parameter shortRefNumber from 1000 to 1000000 the example will come back to work.

What is the expected result? I would have expected the amount to be formatted taking into account the shortRefNumber parameter even with the value 1000. I would only like to format the value in thousands and not in millions.

What happens instead? The formatter does not seem to work for the miles unit

Any other information? (attach screenshot if possible) image image

aboccassiniavvale avatar Apr 15 '24 09:04 aboccassiniavvale

Reading also this part of the documentation https://sapui5.hana.ondemand.com/sdk/#/topic/91f2f2866f4d1014b6dd926db0e91070.html, it would appear that the 'short' style is also not working as it should show '123M USD'.

To format a number in compact format, set the option style to either short or long. These styles control which version of scale name is used. For example, 1000000 is formatted as 1M with short and 1 Million with long.

aboccassiniavvale avatar Apr 15 '24 09:04 aboccassiniavvale

Hello @aboccassiniavvale ,

I couldn't reproduce the issue. I am using Google Chrome in "en" locale. In my case the currency is formatted to "123,457K USD". Can you test again? Double check if the code you have written is reflected to the sample.

Best regards, Petar

dimovpetar avatar Apr 16 '24 08:04 dimovpetar

Hello @dimovpetar , thanks for your help. I tried with the "en" locale and it works fine. Is it possible to have the same formatter with "K" unit in other locale? I also noticed that the 'long' style is not respected anyway. I would have expected "123 Mio USD", right? image

Best regards, Alessandro

aboccassiniavvale avatar Apr 16 '24 08:04 aboccassiniavvale

Hello @aboccassiniavvale ,

What locale were you using at the first example? It might be that 123.456.789,12 is the expected "short" value.

Best regards, Petar

dimovpetar avatar Apr 16 '24 12:04 dimovpetar

Hello @dimovpetar , i was in "it" locale.

Thanks, Alessandro

aboccassiniavvale avatar Apr 17 '24 06:04 aboccassiniavvale

Hello @aboccassiniavvale ,

I have created internal query with number DINC0124876. Our currency experts will give their statement whether:

  • "short" result in Italian is wrong
  • "long" result in English and Italian is wrong

Best regards, Petar

dimovpetar avatar Apr 17 '24 10:04 dimovpetar

Hello @aboccassiniavvale ,

The behavior you describe corresponds exactly to the expected behavior and is therefore not an error. The CLDR specifies whether and how a currency deals with certain format options. As you can see at https://github.com/unicode-org/cldr-json/blob/44.0.0/cldr-json/cldr-numbers-full/main/it/numbers.json, it is not intended in the Italian language to use the "K" in the "currencyFormat-short". The behavior for "long" is also as expected because "long" does not exist in the currency and the default is therefore used.

Best regards, Stefan

StSche avatar Apr 18 '24 13:04 StSche