Fixed #9789 and Fixed #10088 and Fixed [fd23442] - Fix currency problems especially with European currency format #10141
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We've had a few reports now of problems when people pick one of the common European currency formats -
1.234.567,89
We've tried to make small piecemeal changes here and there, but this is most comprehensive version I can come up with so far. The logic is, every time we display a currency we use a special helper to do so, and every time we take currency as input we use a special helper to parse the value.
Here's a breakdown of the changes:
ParseCurrency
helper now respects the Snipe-IT settings, and is used in most places of ParseFloat, which was tied to the system'slocale
purchase_cost_numeric
field which is in computer-format rather than human-readable. We will probably eventually want to add that everywhere. This could be a breaking change for some people, but it seems more like a bug on our part? Happy to discuss and come up with alternatives if we prefer.app/Helpers/Helper.php
class to thealias
portion of the app-config, to make it easier to use the main Helper in most blades. I didn't bother going back through all the blades to remove the now-extraneous namespace reference though. That would've added way too much noise.resources/views/hardware/qr-view.blade.php
was in actual use anymore, so I deleted it.Helper::formatCurrencyOutput()
method, to be consistent throughout the system.sumFormatter()
Javascript method able to handle correctly-formatted or misformatted currency values, but I decided against doing that - I'd rather have any places that remain where we do not correctly format the currency stick out so we can fix them, if I missed any of them.Assorted miscellaneous notes
master
, which is unusual - butdevelop
has all the v6 stuff in it right now.ParseCurrency
helper but that seems dangerous and weird, and I don't know if that's the right move. I'm happy to pull it. The big problem here would be if someonePOST
'ed something with1.234,56
and we parsed it incorrectly. I think the previous application ofParseFloat
was incorrect here, and we shouldn't have been doing any parsing, since this is an API. That's weird, though, in that we return values in a parsed format.e()
the variable that was input. It's actually possible that this isn't even a bug -e('1')
is going to be the same as1
, right? I might have been confused. I can certainly pull it.cleanFloat()
method only yanked out the first thousands-indicator (comma for us, period for some of the EU) - so I changed it to yank them all. Some of my test purchase prices were in the millions :) I doubt this would've ever come up, but I figured it's better to be correct.