Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Currency not being $ #111

Closed
rfwerk opened this issue Mar 6, 2023 · 9 comments · Fixed by #112
Closed

Currency not being $ #111

rfwerk opened this issue Mar 6, 2023 · 9 comments · Fixed by #112
Assignees
Labels
bug Something isn't working

Comments

@rfwerk
Copy link

rfwerk commented Mar 6, 2023

When importing orders or viewing components on Mouser I get an error as only '$' is parsed:

2023-03-05 21:11:40.8976|ERROR|Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware|An unhandled exception has occurred while executing the request.|System.FormatException: The input string '€ 0,141' was

not in a correct format.

at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, ReadOnlySpan`1 value, TypeCode type)

at Binner.Common.Integrations.Models.Mouser.PriceBreak.get_Cost() in C:\projects\binner\Binner\Library\Binner.Common\Integrations\Models\Mouser\MouserPart.cs:line 63

Code does:

        get
        {
            if (!string.IsNullOrEmpty(Price))
                return double.Parse(Price.Replace("$", ""));
            return 0;
        }

For the moment I will patch my copy to play with it a bit

@replaysMike
Copy link
Owner

replaysMike commented Mar 7, 2023 via email

@replaysMike replaysMike self-assigned this Mar 10, 2023
@replaysMike replaysMike added bug Something isn't working in-progress This ticket is currently being worked on labels Mar 10, 2023
@replaysMike
Copy link
Owner

I wasn't able to repro this on my end, perhaps you have a part that has no cost associated with it for some reason. However, I have patched the issue regardless and it will be included in v.2.2.6

@rfwerk
Copy link
Author

rfwerk commented Mar 10, 2023

Hi,
I tested your fix, but it does not solve the issue.
For a component, for me using the EU site for Mouser, the variable price = "€ 0,931"
So it should check for "€", next to "$" and possibly more currencies.
It does not help if I set the currency in my account to US$. My orders can be imported then, but parts still carry the price in EUR.

@replaysMike
Copy link
Owner

ah - I misunderstood the question, didn't realize you were in EU and Mouser supports euros. I'll fix this properly then - right now ;)

replaysMike added a commit that referenced this issue Mar 10, 2023
…e fairly reliable at getting the proper value from the Mouser api.
@replaysMike
Copy link
Owner

ok I've implemented a new culture based currency formatter in commit b76e152

it will get merged in with today's release but feel free to test it if you like

replaysMike added a commit that referenced this issue Mar 11, 2023
…e fairly reliable at getting the proper value from the Mouser api.
@replaysMike
Copy link
Owner

Now available in v2.2.6. Let me know if you are still experiencing the issue

@rfwerk
Copy link
Author

rfwerk commented Mar 12, 2023

Hi, now loading web orders or searching components works, thanks.
Of course everything has $ signs but that is because the rest of the app has no concept of currency I guess. But this is enough to test it.

@replaysMike
Copy link
Owner

Thanks for letting me know - I'll add this to my task list for the next release (next week) to properly internationalize currencies. It definitely was not designed with that in mind at the start, but shouldn't be too difficult to update.

@replaysMike replaysMike removed the in-progress This ticket is currently being worked on label Apr 4, 2023
@hyperglitch
Copy link

hyperglitch commented Mar 19, 2024

This happened when I tried to import Mouser order on version 2.6.1, local installation

API Error
System.FormatException
Failed to import order!
An exception occurred of type System.FormatException
The input string '€ 218,63' was not in a correct format.

Same web order number and API keys on the binner.io resulted in more verbose error message:

API Error
System.FormatException
Failed to import order! An exception occurred of type System.FormatException
The input string '€ 218,63' was not in a correct format.
Api Endpoint: https://binner.io/api/part/import
at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, ReadOnlySpan`1 value, TypeCode type) at System.Double.Parse(String s) at Binner.Services.PartService.GetExternalMouserOrderAsync(OrderImportRequest request) in C:\projects\binner-io\Binner\Library\Binner.Services\PartService.cs:line 514 at Binner.Services.PartService.GetExternalOrderAsync(OrderImportRequest request) in C:\projects\binner-io\Binner\Library\Binner.Services\PartService.cs:line 241 at Binner.Web.Controllers.PartController.OrderImportAsync(OrderImportRequest request) in C:\projects\binner-io\Binner\Binner.Web\Controllers\PartController.cs:line 498

Let me know if I can enable some additional debugging info or I can (privately) give you the order number and API key to check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants