price needs to be normalized when creating itemized invoice

SimpleInvoices Group Forum Forums Fearless359 SimpleInvoices Discussion Group price needs to be normalized when creating itemized invoice

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #868
    joncas
    Participant

    When creating a new itemized invoice, i.e.,
    /index.php?module=invoices&view=itemised
    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).
    Many thanks!

    • This topic was modified 2 weeks, 1 day ago by joncas.
    Attachments:
    You must be logged in to view attached files.
    #871
    joncas
    Participant

    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)

    • This reply was modified 2 weeks, 1 day ago by joncas.
    #873
    kdj3112
    Participant

    Hi joncas,

    Good to hear you found and fixed the problem,
    If you have any further questions, feel free to ask.

    #874
    RRowley
    Participant

    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.

    • This reply was modified 2 weeks, 1 day ago by RRowley.
    #876
    joncas
    Participant

    Hello,

    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.
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.