OCA / l10n-thailand

Thai localization
GNU Affero General Public License v3.0
50 stars 65 forks source link

Python Library (python-stdnum) for checking Thailand numbers. #224

Closed kittiu closed 2 years ago

kittiu commented 3 years ago

Based on this PR about Thai Citizen ID check -> https://github.com/OCA/l10n-thailand/pull/222

I have been asking from community about the best way to handle this. And just after the module l10n_th_hr_employee_identification_id got merged, I have got the good answer.

May I quote his answer from @alexis-via here,


https://pypi.org/project/python-stdnum/

I would also recommend to use python-stdnum. If the citizen ID validation for your country is not yet supported by python-stdnum, you can add it there ; the maintainer is very nice and reactive. I worked with him to add support for the new VAT numbers of Northern Ireland and it was added a few days later. For example, python-stdnum supports validation of France's social security numbers. Then we have a small "glue" module l10n_fr_hr_check_ssnid that uses python-stdnum and adds a constraint to validate the number :

https://github.com/OCA/l10n-france/blob/14.0/l10n_fr_hr_check_ssnid/models/hr_employee.py


I have checked https://pypi.org/project/python-stdnum/, and there is no Thailand's related number there yet. But as mentioned above, may be it is a good time to add Thai's number into this lib also. I.e., Citizen ID, Tax ID, etc.

cc @piruin are you interested? :)

piruin commented 3 years ago

Interesting! I will make PR at python-stdnum then update our module after it been released

Thank you for the information

sansirit commented 3 years ago

Great idea to implement the validation there.

Next question, what should be the scope of validation?

The check digit calculation for Thai 13-digit identification number and 13-digit Tax ID are using the same formula. So, there is no debate here. However, the first digit indicate the type of the ID number. As discussed here:

There might be a confusion if a foreigner person register to DBD as his/her own name. The foreigner will get a 13-digit number beginning with 0 as his/her ID number, instead of ID number beginning with 6 - 8.

So, we could check the first digit for person ID or company ID. Should we do this?

sansirit commented 2 years ago

I've noticed that @piruin has contributed the PIN, TIN, and MOA numbers validation to the python-stdnum. This issue should be resolved.

Next, we can incorporate the new stdnum validation into l10n-thailand.

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.