IN is storing too many significant digits in the database, I don’t like the look and am concerned it will result in random hard to track rounding errors.
For example one of my line item costs is stored as: 34.75999999999999801048033987171947956085205078125
It should be 34.76, I suspect this was introduced as an artifact of the v4 to v5 conversion. Is there an automated way to clean this situation?
April 13, 2023, 4:40pm
@david can you please advise?
April 13, 2023, 10:45pm
we only check for type when storing the amounts in the line items (float) however we do apply rounding to the native currency when performing any calculations. Here is a short block that you can run in tinker to ensure all of your amounts in line items are converted to 2 decimal precision.
$line_items = $invoice->line_items;
foreach($line_items as $item)
$item->cost = round($item->cost,2);
$invoice->line_items = $line_items;
Thank you. What is tinker?
April 14, 2023, 8:08am
From the command line you can run,
PHP artisan tinker
This will allow you to run the above command.
Will this round recurring invoices?
April 14, 2023, 9:55pm
For Recurring Invoices, you would just need to change the command from