May 17, 2020 at 8:25 am #868
When creating a new itemized invoice, i.e.,
when an item is added, the price is displayed in localized format with thousands separator.
When saving the invoice, this creates an error “Incorrect decimal value: ‘6,068.83’ for column ‘unit_price’ at row 1” (log file enclosed).
The solution is to normalize the numbers before inserting them into the database.
Could you give a hint as to where this can be patched (I’m new to the structure of simple invoices).
- This topic was modified 2 weeks, 1 day ago by joncas.
Attachments:You must be logged in to view attached files.May 17, 2020 at 8:44 am #871
p.s.: Searching the files listed in the error log, it looks like the patch would be on in /modules/invoices/save.php
the “insert” case on line 71, one should use SiLocal::dbStd($_POST[“unit_price$i”]) instead of the unmodified $_POST[“unit_price$i”] (as the “edit” case does)
May 17, 2020 at 1:03 pm #873kdj3112Participant
- This reply was modified 2 weeks, 1 day ago by joncas.
Good to hear you found and fixed the problem,
If you have any further questions, feel free to ask.May 18, 2020 at 3:52 am #874RRowleyParticipant
I think you addressed a symptom, not the problem. The existing code handles these values fine on my system. What server are you using (XAMPP, WAMP, Linux, etc.)? What version of PHP is running on that server?
Are you willing to share your phpinfo.php output? To do this, modify the phpinfo.php file that is in your primary directory and set the $secure variable to “true”. Then run it by entering your si URL with the file name. Ex: simepleinvoices/phpinfo.php if you use “simpleinvoices” to access your version of SI. Be sure to mask any personal info in this output before sharing it.
Note: Be sure to change the $secure variable back to “false” after getting this information.
May 18, 2020 at 4:52 am #876
- This reply was modified 2 weeks, 1 day ago by RRowley.
It may depend on the localization settings? This site is set to British English, so numbers display with a comma as thousands separator (see enclosed screenshot), and apparently this is passed on in the POST arguments because the sql error was complaining that this was being used in the insert command.
In your code the “edit” function already did use SiLocal::dbStd to filter that out, so it would seem logical that the insert should, too, no?
Enclosed also the phpinfo: this is a dedicated Linux server running Ubuntu 18.04
Attachments:You must be logged in to view attached files.
- You must be logged in to reply to this topic.