Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 311: Numbers internationalization #576

Conversation

veggiematts
Copy link
Contributor

@veggiematts veggiematts commented Apr 11, 2019

Background & discussion, see Issue #311

Currently, all numbers in Coral are in the default format:

  • en_US
  • 2 decimals

This patchs allows to define how numbers should be parsed and displayed in Coral.

First of all, install the php-intl package.

The configuration takes place in common/configuration.ini, as such:

[settings]
number_locale = "fr_FR"
number_decimals = 2

If number_locale is omitted, it will be defaulted to en_US
If number_decimals is omitted, it will be defaulted to 2

Please note that is PR includes and obsoletes:

This PR currently affects every part of the resources module using
cost_to_integer and integer_to_cost function:

  • new resource, api, api_client, imports, summary and cost history.

Special sql processing has been made to exports and dashboards.
Special javascript processing has been made to cost history.

Test plan:

  1. Change the default values (as provided in the example above, for instance)
  2. Check that resource exports and dashboards show the correct number formatting
  3. Check that cost history fields correctly parses the numbers according to the
    locale when calculating priceTaxIncluded
  4. Check that cost history correctly displays the numbers according to the
    locale when calculating priceTaxIncluded
  5. Check that the numbers are correctly stored to and fetched from the database
    according to the locale in cost history
  6. Check that the import tool correctly parses the numbers according to the locale
  7. Check that it also works the default values or no values at all

ialford and others added 27 commits December 11, 2018 18:37
 - Add an option to display all the data.
 - Rename Object class in source code
organizations/install/upgrade_koral_vendors.sql was not properly renamed to be processed by the installer, leading to a missing ilsID field, which allows to jump back to the ILS when a Coral and ILS vendor are linked.
Remove SUSHI COUNTER 3 support
Remove COUNTER 3 from SUSHI settings
Currently, all numbers in Coral are in the default format:

 - en_US
 - 2 decimals

This patchs allows to define how numbers should be parsed and displayed in Coral.

The configuration takes place in common/configuration.ini, as such:

[settings]
number_locale = "fr_FR"
number_decimals = 2
number_decimal_separator = ","

If number_locale is omitted, it will be defaulted to en_US
If number_decimals is omitted, it will be defaulted to 2
If number_decimal_separator is ommited, it will be defaulted to '.'

Please note that is PR includes and obsoletes:
 - PR 575: Allow to define SQL number format in common/configuration.ini
 - PR 418: Cost history numeric error

This PR currently affects every part of the resources module using
cost_to_integer and integer_to_cost function:
 - new resource, api, api_client, imports, summary and cost history.

Special sql processing has been made to exports and dashboards.
Special javascript processing has been made to cost history.

Test plan:
 1) Change the default values (as provided in the example above, for instance)
 2) Check that resource exports and dashboards show the correct number formatting
 3) Check that cost history fields correctly parses the numbers according to the
    locale when calculating priceTaxIncluded
 4) Check that cost history correctly displays the numbers according to the
    locale when calculating priceTaxIncluded
 5) Check that the numbers are correctly stored to and fetched from the database
    according to the locale in cost history
 6) Check that the import tool correctly parses the numbers according to the locale
 7) Check that it also works the default values or no values at all
 - use parseFloatI18n instead of a regex
 - use NumberFormatter::TYPE_DOUBLE explicitely
@poacherone
Copy link
Collaborator

poacherone commented Apr 12, 2019

I tried testing this PR but couldn't get it to work properly. In the dashboard and on exports, it works well, but the Resource Acquisitions tab shows a blank page whenever there are any actual costs (with no cost history, it displays fine). It looks like this:

Coral resource blank

I don't know if this is an issue with my test environment, or if anyone else can reproduce this?

@veggiematts
Copy link
Contributor Author

Any error in the logs ?

@poacherone
Copy link
Collaborator

poacherone commented Apr 12, 2019

[php7:error] [pid 4155] [client 130.237.153.122:54600] PHP Fatal error: Uncaught Error: Class 'NumberFormatter' not found in /var/www/html/coral/resources/directory.php:34\nStack trace:\n#0 /var/www/html/coral/resources/ajax_htmldata/getAcquisitionsDetails.php(144): integer_to_cost(NULL)\n#1 /var/www/html/coral/resources/ajax_htmldata.php(24): include('/var/www/html/c...')\n#2 {main}\n thrown in /var/www/html/coral/resources/directory.php on line 34, referer: /coral/resources/resource.php?resourceID=5808

queryluke and others added 23 commits December 1, 2019 12:46
…-bugs

SirsiDynix: Additional Datepicker fixes
Currently, all numbers in Coral are in the default format:

 - en_US
 - 2 decimals

This patchs allows to define how numbers should be parsed and displayed in Coral.

The configuration takes place in common/configuration.ini, as such:

[settings]
number_locale = "fr_FR"
number_decimals = 2
number_decimal_separator = ","

If number_locale is omitted, it will be defaulted to en_US
If number_decimals is omitted, it will be defaulted to 2
If number_decimal_separator is ommited, it will be defaulted to '.'

Please note that is PR includes and obsoletes:
 - PR 575: Allow to define SQL number format in common/configuration.ini
 - PR 418: Cost history numeric error

This PR currently affects every part of the resources module using
cost_to_integer and integer_to_cost function:
 - new resource, api, api_client, imports, summary and cost history.

Special sql processing has been made to exports and dashboards.
Special javascript processing has been made to cost history.

Test plan:
 1) Change the default values (as provided in the example above, for instance)
 2) Check that resource exports and dashboards show the correct number formatting
 3) Check that cost history fields correctly parses the numbers according to the
    locale when calculating priceTaxIncluded
 4) Check that cost history correctly displays the numbers according to the
    locale when calculating priceTaxIncluded
 5) Check that the numbers are correctly stored to and fetched from the database
    according to the locale in cost history
 6) Check that the import tool correctly parses the numbers according to the locale
 7) Check that it also works the default values or no values at all
 - use parseFloatI18n instead of a regex
 - use NumberFormatter::TYPE_DOUBLE explicitely
 - Fix error messages with price tax included and price tax excluded
 - Add more explicit message for error on payment
 - Add more strict control on amount input
 - Remove the need for number_decimal_separator
 - Fix javascript void() calls
 - Use the selected locale in isAmount function
 - Remove whitespaces upon form submission
 - Use ParseFloatI18n on cost form submission, since it is already
   what has been used to validate the data.
 - Remove whitespaces in amount when parsing it.
 - Warn the user if php-intl is not enabled, instead of silently crashing.
 - Add compatibility for dashboards recent developments
@veggiematts
Copy link
Contributor Author

Ok, just rebased this to development branch.
Since it has been tested ok by @poacherone and @LibClaire, I'm merging this.

@veggiematts veggiematts merged commit c6eca51 into coral-erm:development Jan 8, 2020
@poacherone
Copy link
Collaborator

Tested against the development branch, and works as intended. Good work @veggiematts!

@veggiematts veggiematts added this to Documentation needed in February 2020 release Feb 10, 2020
@rtatterson rtatterson moved this from Documentation needed to Documentation updated in February 2020 release Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an enhancement (not a bug) important Not critical but should be addressed
Projects
February 2020 release
Documentation updated
Development

Successfully merging this pull request may close these issues.

None yet

9 participants