Fix [FD-43836] PATCH of purchase_cost for assets for comma as decimal separator #15412
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.
A customer who was using the "1.234,56" number format was having problems doing a
PATCH
of the purchase_cost for assets.When he tried to pass "12,34" he got an error that a number was required. When he used an actual float, as in
{"purchase_cost": 12.34}
- the period got stripped out and the value was changed to 1234.00.We already do some magic on creating new assets to allow for this. But we were not doing the same magic when doing a
PATCH
for an existing asset.I also decided - and maybe this is me getting a little ahead of myself - that if you actually pass in an actual Float via JSON, then that Float is probably what you wanted. That change is a little bit scarier (to me), since it changes the
setPurchaseCost
mutator inSnipeModel
.I added in some tests for the
PATCH
method for US and EU formats, for string-numbers and real floats, making sure they still work as expected.