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

[Q] - If the organisationsnummer is a personnummer and the person in question is above 100 years old, Shouldn't the Format function return a + separator? #38

Closed
torenius opened this issue Jan 30, 2024 · 7 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@torenius
Copy link

torenius commented Jan 30, 2024

First of all, this is a greate package :)

We have a few rows in our database that have a personnummer as there organisationsnummer and are above 100 years old.
If I use your personnummer library it respects the + in the number. But when parsing with this library and calling Format it will return with - instead.

Is there any specific reason why you whent with that solution? It seems intended, so Im woundering if there is any good reason for not returning a + in does occasions?

Why do this?

public string Format(bool separator = true)
{
    var num = ShortString;
    return separator ? $"{num!.Substring(0, 6)}-{num!.Substring(6)}" : num!;
}

private string ShortString => ((IsPersonnummer ? _personnummer!.Format(false) : _number)!)
        .Replace("-", "")
        .Replace("+", "");

Instead of just?

public string Format(bool separator = true)
{
   if (IsPersonnummer) return _personnummer!.Format(false, !separator);

    return separator ? $"{_number!.Substring(0, 6)}-{_number!.Substring(6)}" : _number!;
}
@torenius torenius added the question Further information is requested label Jan 30, 2024
@Johannestegner
Copy link
Member

This is likely something we have missed and I'd say that it's a bug and not intentional.
As you say, the check if it is a personnummer should be added and the formatting should be passed to the Personnummer library instead.

Will take it up with the team and make sure this is how we handle it in all packages.

Thank you for the report!

@Johannestegner Johannestegner added the bug Something isn't working label Jan 31, 2024
@Johannestegner Johannestegner self-assigned this Jan 31, 2024
@Johannestegner
Copy link
Member

Further research makes me think that I was wrong in that it is a bug and that it actually is intentional.
I will do some more research and get back to you here when I get a clear answer, but it seems like org-nr for "enskild firma" always makes use of - and never +.

@Johannestegner
Copy link
Member

Small update on this issue. I asked Bolagsverket, whom had no answer and redirected me to Skatteverket. Currently awaiting an answer from them.
Bolagsverket said that there are no active EF:s with an owner above 100 years though, but we do ofcourse want to handle it correctly. I'll update here with more info :)

@torenius
Copy link
Author

torenius commented Feb 2, 2024

Thank you :)

@Johannestegner
Copy link
Member

Johannestegner commented Feb 19, 2024

I finally got a response from Skatteverket (that took a while!), and they say that for enskild firma, it's supposed to be formatted as with a standard personnummer (that is, with a + if its older than 100 years).

I will correct this asap (or you may open up a pull request if you wish!) in this and the other repos :)

@Johannestegner
Copy link
Member

Fixed in latest release (1.2.0).

Thank you again!

@torenius
Copy link
Author

Thank you :)

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

No branches or pull requests

2 participants