CiviReport does not localize custom fields of type Number
How to reproduce
- Set localization settings: decimal separator to
,
and thousand separator to.
- Add a custom group for cases
- Add a custom field of Type
Number
and Field typeText
- Enter a value such as
1,234.56
which is localized1.234,56
- Create a new CiviCase detail report. Check the column to display the custom field.
Expected result
Value of the custom field displayed as 1.234,56
Actual result
Value of custom field is displayed as 1234.56
(note the decimal separator and the missing thousand separator).
Comment
The display value of custom number fields is also broken on the manage case screen.
We have a function CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency
to format money fields. However we do not have such a function for number fields with a decimal. So basically nowhere in CiviCRM a number field is formatted according to localization settings. Unless the smarty modifier |crmNumberFormat
is used in the template.
A fix should probably happen in CRM_Core_BAO_CustomField::formatDisplayValue
, see https://github.com/civicrm/civicrm-core/blob/master/CRM/Core/BAO/CustomField.php#L1187
However I am not exactly sure how to fix this as I could not find a number formatting function such as we have for the money field. Does such a function exists and if so where do I find it?