SAP / openui5

OpenUI5 lets you build enterprise-ready web applications, responsive to all devices, running on almost any browser of your choice.
http://openui5.org
Apache License 2.0
2.92k stars 1.23k forks source link

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

Closed aboccassiniavvale closed 3 months ago

aboccassiniavvale commented 3 months ago

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
    }
    }" />
  3. The example shown will lose the formatting
  4. 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 commented 3 months ago

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.

dimovpetar commented 3 months ago

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

aboccassiniavvale commented 3 months ago

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

dimovpetar commented 3 months ago

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

aboccassiniavvale commented 3 months ago

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

Thanks, Alessandro

dimovpetar commented 3 months ago

Hello @aboccassiniavvale ,

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

Best regards, Petar

StSche commented 3 months ago

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