- Issue created by @Anybody
Thank you so much for this wonderful and super helpful module to do quick and easy calculation on views.
I guess for English / US number formatting the module is working super well, but it looks like the module is calculating with formatted numbers instead of raw values, so the functionality is broken in other languages.
For example the German number format of
1 234.56
(EN)
is
1.234,56
(DE)
and there are a plenty of other number formattings.
Sadly, Drupals functionality for number formatting (also as view settings) is still poor, so you can't really fight well against these formats manually.
I created a Drupal Commerce Reports view, that outputs the sum of all orders in a month and then multiplies them wtih 0.01 for some internal calculations.
Workaround
In a related issue I found the workaround from @jrochate to use a global text field and twig to preprocess the values:
{{ fieldxyz|striptags|trim }}
(
https://www.drupal.org/project/views_simple_math_field/issues/3134991#co...
✨
Pulling in rendered Views Field View content vs raw
Active
)
This works great to reverse the German number formatting hackish:
{{ amount|striptags|trim|replace({'.': '', ',': '.'}) }}
Maybe in a first step, this should be documents as workaround on the module page and in the README? But finally it would be great to always use the raw value.
Set up a German Drupal project and create a Drupal Commerce Reports view like described above to reproduce the issue. Same for other languages with different number formats from the English (PHP decimals) defaults.
Always use raw values for calculations or add a setting to chose if the formatted or the raw value should be used
Just format the output of the calculation (already possible)
Active
3.0
Code