arthurdejong / python-stdnum

A Python library to provide functions to handle, parse and validate standard numbers.
https://arthurdejong.org/python-stdnum/
GNU Lesser General Public License v2.1
495 stars 205 forks source link

BUG on validate RUC for Ecuador (EC) #290

Closed francisrubio06 closed 2 years ago

francisrubio06 commented 2 years ago

The _isvalid method returns false with two RUCs already registered in the government.

RUC: 0993370026001

image

image

RUC: 1793189624001

image

image

arthurdejong commented 2 years ago

Thanks for reporting this. If you know a reliable source describing the format and validation I'd be more than happy to adapt the code. As it stands now it is mostly built up using bits and pieces that were provided by various people.

The current module first determines if the RUC is a natural, public or juridical number (based on the third digit) and then does the validation based on that. Both 0993370026001 and 1793189624001 are classified as juridical numbers (third digit is a 9) and the corresponding check digit validation fails. The 1793189624001 number validates as public RUC but 0993370026001 does not.

Without more documentation this is sadly very hard to fix properly.