openproject
openproject copied to clipboard
change rounding scale from 2 to 4 digits
A rate will be saved with a scale of 4 in the database. Without this patch the form is prefill with a rounded rate with a scale of 2 when you open the update form even when a scale of 4 is defined in the database. You won't see the real value of the database. Even worst is when you click on save you will save this new rounded value. Example: You define a rate of 0.125 and save it. In the database the 0.125 is saved. When you reopen the rates form you will see an 0.13. When you open the update view of the rate, you will see a prefilled form with 0.13. When you now click on save the untouched value will be saved to the database. In the database the rate of 0.13 saved.
This patch change the update view so that the prefilled form shows the rate with a scale of 4 like it is saved in the database.
Hi @sdaro , thanks for the contribution. I'm fine with raising the precision as it's stored with higher precision as you mentioned. We'll need to add tests for it and the added number_with_delimiter
as that might affect parsing of the value in other langues.
Best Oliver
Hi @oliverguenther ,
I think a good way to test it is to open the update page with entries in the database and just click save again and check if the value stays the same. (This test would fail without this patch) The correct position for this test is this file, right? /openproject/modules/costs/spec/features/users_hourly_rates_spec.rb
For the function number_with_delimiter
I'm not sure if I understand you correctly. Do you want to implement a test for every language that is supported by i18n? number_with_delimiter
is own by ruby on rails and should be heavly tested there in my opinion.
Can you tell me how I'm executing all tests of openproject within a docker container?
Best David
Hi @oliverguenther ,
I think a good way to test it is to open the update page with entries in the database and just click save again and check if the value stays the same. (This test would fail without this patch) The correct position for this test is this file, right? /openproject/modules/costs/spec/features/users_hourly_rates_spec.rb
Yes that's the correct place. You can try to update it or I'll give it a shot when I find the time.
For the function
number_with_delimiter
I'm not sure if I understand you correctly. Do you want to implement a test for every language that is supported by i18n?number_with_delimiter
is own by ruby on rails and should be heavly tested there in my opinion.
It's not the output of number_with_delimiter
that is the problem but rather our parsing side after you output that number to the input. The input fields change their delimiters/decimal separators depending on the language. However we can also include this in the feature test such as shown here: https://github.com/opf/openproject/blob/ccfa29c728889c9917990cbd51ea60722b6bb59a/modules/budgets/spec/features/budgets/update_budget_spec.rb#L140-L143
Can you tell me how I'm executing all tests of openproject within a docker container?
With docker, you can run the tests like described here: https://www.openproject.org/docs/development/development-environment-docker/#tests
Closing old PRs. Please reopen if work is still being conducted on this.