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

Add Syntax Check to Slovakia #45

Merged
merged 3 commits into from
Jul 17, 2024
Merged

Conversation

iekadou
Copy link
Contributor

@iekadou iekadou commented Jul 16, 2024

Add Slovakia TIN Check Digit

@iekadou iekadou requested a review from lekoala as a code owner July 16, 2024 15:34
Copy link

what-the-diff bot commented Jul 16, 2024

PR Summary

  • Inclusion of New Constants in SlovakiaSpec file
    Several constants have been appended to the 'SlovakiaSpec.php' file. These have been established to validate or invalidate specific numeric or syntax criteria which helps the system perform specific actions.

  • Addition of Pattern Constant in Slovakia File
    A new 'PATTERN' constant has been introduced inside the 'Slovakia.php' file. This constant guides the system to recognize and behave according to certain patterns found within the data.

  • Introduction of 'hasValidRule' method in Slovakia File
    A new method - 'hasValidRule', has been added to the 'Slovakia.php' file. This method effectively checks whether certain given rules or conditions are met in the course of operation. It enhances specificity and precision, enabling the system to act more accurately upon use-case scenarios.

Copy link
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Do you have documentation for this?

Comment on lines 42 to 40
if (strlen($tin) === 10
&& (int) $tin % 11 === 0) {
return true;
}
if (strlen($tin) === 10) {
return ((int) substr($tin, 0, 9) % 11) % 10 === (int) substr($tin, 9, 1);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (strlen($tin) === 10
&& (int) $tin % 11 === 0) {
return true;
}
if (strlen($tin) === 10) {
return ((int) substr($tin, 0, 9) % 11) % 10 === (int) substr($tin, 9, 1);
}
if (strlen($tin) === 10) {
if ( (int) $tin % 11 === 0) {
return true;
}
return ((int) substr($tin, 0, 9) % 11) % 10 === (int) substr($tin, 9, 1);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the EU checker page (https://ec.europa.eu/taxation_customs/tin/#/check-tin) you can try e.g. 2822030541
This TIN is valid, even if it has 10 digits and starts with < 54.

We decompiled the Java lib you can find here:
https://taxation-customs.ec.europa.eu/document/download/07664928-b4f3-47a5-81f7-438767dc01cb_en?v=1721203258495

The modulo 11 check has those 2 modes in the decompiled lib.

@drupol drupol force-pushed the add-algo-to-slovakia branch from b2fd537 to 861c59a Compare July 17, 2024 08:20
src/CountryHandler/Slovakia.php Outdated Show resolved Hide resolved
@drupol drupol merged commit d3a6a1e into loophp:master Jul 17, 2024
13 of 14 checks passed
@drupol
Copy link
Contributor

drupol commented Jul 17, 2024

Thank you!

@iekadou
Copy link
Contributor Author

iekadou commented Jul 17, 2024

@drupol Can we do a new release for this? :)

@drupol
Copy link
Contributor

drupol commented Jul 17, 2024

Yes that's the plan. I have a few quirks to fix before, I will try to take care of this after my day, in the evening.

drupol added a commit that referenced this pull request Jul 17, 2024
Now Slovakia has proper check thanks to #45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants