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

Request failed: Ogiltigt land: Sweden #242

Open
Joaqim opened this issue Apr 11, 2022 · 7 comments
Open

Request failed: Ogiltigt land: Sweden #242

Joaqim opened this issue Apr 11, 2022 · 7 comments
Labels
server-side Issue is on server side, therefore can't be fixed in SDK

Comments

@Joaqim
Copy link

Joaqim commented Apr 11, 2022

Bug report

Every other country that I've tested in the EU works with the culture-independent English country name.

We can see on the Fortnox front-end that when you input Sweden as Country it auto corrects to 'Sverige'.
But in the API, Sweden is not accepted at all and throws a FortnoxApiException.

Same with Czechia, which is expected by Fortnox to be 'Czech Republic'.

💻 Code

var isoCode = "SE"

// This should return English country name, but consider using InvariantCulture class instead.
var countryEnglishName = new RegionInfo(isoCode).EnglishName; 


var Invoice = new Invoice {
   ...
   Country = countryEnglishName,
   ...
}
...
await invoiceConnector.CreateAsync(invoice);

Actual behavior

Request failed: Ogiltigt land: Sweden

Expected behavior

We expect that all Country names conforming to English naming should be accepted by Fortnox as valid Country.

Notes

I currently use this utility function to circumvent this issue:

public static string GetEnglishName(string countryCode)
        {
            try
            {
                return countryCode.ToUpper() switch
                {
                    "SE" => "Sverige",
                    "CZ" => "Czech Republic",
                    _ => new RegionInfo(countryCode).EnglishName
                };
            }
            catch (Exception)
            {
                return $"Missing English Name for {countryCode}";
            }
        }
@richardrandak richardrandak added the server-side Issue is on server side, therefore can't be fixed in SDK label Apr 11, 2022
@Joaqim
Copy link
Author

Joaqim commented Apr 12, 2022

This seems to have been resolved without breaking changes, i.e both Sverige and Sweden now seems to be accepted as valid Country.

@Joaqim Joaqim closed this as completed Apr 12, 2022
@richardrandak
Copy link
Collaborator

Have you change some settings or anything?
I can still reproduce the issue with my sandbox..

@Joaqim
Copy link
Author

Joaqim commented Apr 12, 2022

I'm sorry, I might have been mistaken, I don't know what I could have changed to fix it on my side but I did get some inconsistent exceptions when switching between "Sweden" & "Sverige".

But as long as you have a consistent environment where you can reproduce it I'll leave it up to you to take over this issue as I'm actively developing with the environment where I first encountered the issue.

@Joaqim
Copy link
Author

Joaqim commented Apr 12, 2022

It might be as simple as my missing the Api Exception, I'm dealing with issues related to that as I'm moving away from exceptions to non-fatal warnings instead to allow the application to continue running.

I'm now wondering if it is specifically Customer connector Update/Create that complains about Country, instead of the Invoice which is what I assumed at first. EDIT: I see now that Customer only takes CountryCode.

But my point is moot if as long as you have a sandbox and can reliably track down the issue.

@richardrandak
Copy link
Collaborator

Well, I am not responsible for the Fortnox API and I am not sure if the SDK should "cover" this issue by doing translation... I will just report the issue to Fortnox support and see what's behind this

@richardrandak
Copy link
Collaborator

So, I spoke with the support, and the Fortnox developers are aware of this issue already, so it will be fixed... eventually :)

@Joaqim Joaqim reopened this May 3, 2022
@xpagedeveloper
Copy link

I think that the problem is like this. If the invoice has swedish (SE) as language the Swedish name for the country is needed.
If the Invoice has any other countrycode probably english then the english name apply.
Check out this issue and that repo for Ruby have a fix for it and all official values.
accodeing/fortnox-api#153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
server-side Issue is on server side, therefore can't be fixed in SDK
Projects
None yet
Development

No branches or pull requests

3 participants