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
Fix #9880 - Error when importing currency fields with a decimal separator #9881
Conversation
…ecimal separator set to a comma
Hello, @SinergiaCRM , Thanks, |
Yes, the assignment of |
$value = sugar_substr($value, $vardef['len']); | ||
} | ||
|
||
return $value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @SinergiaCRM,
Thank you for your PR.
Don't we also want to make sure the decimal separator is a "."? or is that what causes the problem on currencies at the moment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @clemente-raposo,
The code should work the same with any decimal separator. The importSanitize()
function returns the field value in the format defined by the user, so we only need to remove the thousands separator symbol set in the configuration.
Changing the values of the thousands separator and decimal separator with different characters, such as ",", ".", "@", "#", etc., and testing the import process could be a useful test. In the tests performed, it has worked correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @SinergiaCRM, thank you. Makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hey! I've given this some testing, and it seems like the fix does indeed resolve issues when importing new records. However, I seem to hit an error when trying to Import & Update records. I've set my User's Thousands Operator to "." Then, Importing to Update two Opportunities, I received the error: This doesn't seem to happen when importing NEW records, only when updating existing records. CSV Used attached, for reference: What are your thoughts? |
Hi @johnM2401, What versión of PHP, SuiteCRM, MySQL/MariaDB are you using? |
This pull request has been mentioned on SuiteCRM. There might be relevant details there: https://community.suitecrm.com/t/import-currency-field/34603/5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the delay, @SinergiaCRM
I've retested this after merging into the most recent version locally, (7.14), and cannot seem to replicate the issue I've raised above.
After some testing with various combinations of special-character Decimal/Thousands separators, it appears to be working well.
LGTM!
resolve #9880
Description
If the decimal separator is set to a comma "," in the user's settings, an error occurs when importing currency fields that include decimals because the decimal separator is removed and the result is the value of the field multiplied by 100.
The error was caused by the filter set for importing currency fields being incorrect, as it passes the same filter as float fields, when a currency field, after the currency symbol is removed, should follow the same treatment as a decimal field. This is what has been implemented in the solution.
Motivation and Context
Prevent errors when importing currency fields with different types of decimal separators.
How To Test
Types of changes
Final checklist
(It would be nice to specify in the documentation that the inheritance of security groups is applied exclusively at record creation time.)