fix(ec/ruc): do not enforce mod-11 check digit on company RUCs - #168
Open
menyinch wants to merge 1 commit into
Open
fix(ec/ruc): do not enforce mod-11 check digit on company RUCs#168menyinch wants to merge 1 commit into
menyinch wants to merge 1 commit into
Conversation
SRI issues public (third digit 6) and juridical (third digit 9) RUCs without any check-digit algorithm, so the historical mod-11 scheme rejects real registry-valid numbers (e.g. 0993381661001). Keep the structural checks (length, province, establishment number) for company RUCs and full cedula validation for natural-person RUCs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GgezMx4ZYyFgH8u4hgjsZ8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
EC.ruc.validaterejects real, registry-valid Ecuadorian company RUCs withInvalidChecksum. Example:0993381661001fails the mod-11 weighted sum ([4,3,2,7,6,5,4,3,2,1]→ 159, 159 mod 11 = 5 ≠ 0) but is a valid taxpayer per SRI's official lookup (https://srienlinea.sri.gob.ec/sri-en-linea/SriRucWeb/ConsultaRuc/Consultas/consultaRuc).Why
The mod-11 check-digit scheme for company RUCs is a historical/community algorithm. The SRI has clarified that RUCs issued to private companies (third digit 9), public companies (third digit 6), and foreign natural persons are not generated with any algorithm, and check-digit validation has never been a requirement — see the SRI statement quoted in https://minka.gob.ec/mintel/ge/rutr/gobec_forms/-/issues/32. The SRI's own e-invoicing scheme added an explicit exception to skip mod-11 validation for these numbers. Only cédula-based RUCs (third digit 0–5) carry a reliable check digit, because the cédula itself has one.
python-stdnum has the same issue; other implementations (e.g. Odoo's Ecuadorian localization) dropped the company-RUC checksum for this same reason.
Change
0000/000). The 6-branch fallback to cédula validation is gone with the checksum that triggered it.ec/ci.1792060347-001assertedInvalidChecksumfor an off-by-one tenth digit on a juridical RUC — that is exactly the false invariant, so it now asserts valid; added SRI-valid company RUCs (0993381661001,1760001550001), anInvalidChecksumcase on a natural-person RUC, andInvalidComponentcases (establishment000/0000, bad province).All 1641 tests pass; lint and prettier clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_01GgezMx4ZYyFgH8u4hgjsZ8