Repository navigation
feat: adiciona suporte a CNPJ alfanumérico nos campos de CPF/CNPJ - #19
Merged
Merged
Conversation
- adiciona Util\DocumentUtil::cnpj(), que valida CNPJ numérico ou alfanumérico pelo cálculo de DV da Receita Federal e o retorna sem máscara e em maiúsculas - DocumentUtil::cpfCnpj() passa a tratar um documento com letras como CNPJ alfanumérico, em vez de descartar as letras - cobre com os vetores oficiais da Receita, testes dos models e da request do CustomerEndpoint::create - documenta as regras de documento no README e no docs/sdk.md e registra a v1.5.0 no CHANGELOG
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.
O que muda
Desde julho de 2026, a Receita Federal atribui CNPJ alfanumérico às novas inscrições: 12 caracteres
[A-Z0-9]mais 2 DVs numéricos. OasCnpjdakubinyete/assertationdescarta letras, então o SDK recusava esses CNPJs.Util\DocumentUtil::cnpj()valida CNPJ numérico ou alfanumérico pelo cálculo de DV da Receita, em que o valor de cada caractere é o código ASCII menos 48, com módulo 11. Ele devolve o CNPJ sem máscara e em maiúsculas.DocumentUtil::cpfCnpj()passa a tratar um documento com letras como CNPJ alfanumérico. CPF e CNPJ numéricos seguem a regra do fix: decide entre CPF e CNPJ pela quantidade de dígitos do documento #18.12.ABC.345/01DE-35MutatorAttributeException12ABC34501DE3512.abc.345/01de-35MutatorAttributeException12ABC34501DE3512.ABC.345/01DE-36(DV errado)MutatorAttributeExceptionMutatorAttributeExceptionCPF 074.598.263-8307459826383MutatorAttributeExceptionA última linha é a mudança de comportamento: as letras deixam de ser descartadas.
Como foi testado
DocumentUtil, com os vetores oficiais do código de referência da Receita;CustomerEndpoint::create, que inspeciona o body.DigitoVerificadorde referência da Receita, sem nenhuma divergência.Release
MINOR,
v1.5.0, depois dav1.4.2. A entrada noCHANGELOG.mde a seção "CPF e CNPJ" do README estão neste PR.Closes #17
🤖 Generated with Claude Code