Repository navigation
feat: preenchimento do destinatário (dest/enderDest) por CPF/CNPJ - #1716
Open
alissonlinneker wants to merge 1 commit into
Open
alissonlinneker wants to merge 1 commit into
alissonlinneker wants to merge 1 commit into
Conversation
Add NFe.Utils.CpfCnpj, an additive utility that fills the destinatario (dest/enderDest) of an NF-e/NFC-e from a CPF or CNPJ, without touching the core classes. It resolves name/razao, address and the IE indicator through a pluggable data source (IPessoaLookup), with a reference implementation over the cpfcnpj.com.br REST API. - IPessoaLookup abstraction so the data source can be swapped (cache, tests, other API) - CpfCnpjComBrLookup: HttpClient + System.Text.Json client (packages 3/5/16) - DestinatarioResolver: fills only empty fields; sets CPF or CNPJ (never both); guards the 8-digit CEP setter; sets cMun (IBGE) as long; indIEDest defaults to NaoContribuinte and only becomes ContribuinteICMS with an active IE in the UF, never Isento - Alphanumeric CNPJ supported (letters preserved on normalization) - UfExtensoes to parse a UF sigla into the Estado enum (emit path) - xUnit tests with a fake lookup covering the invariants - Targets net462, netstandard2.0 and net6.0
Member
|
Olá @alissonlinneker. Agradecemos a contribuição. |
This branch has not been deployed
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 este PR faz
Adiciona o projeto
NFe.Utils.CpfCnpj, um utilitário aditivo que preenche odestinatário da NF-e/NFC-e (
desteenderDest) a partir de um CPF ou CNPJ. Nenhumarquivo do núcleo é alterado: o resolver apenas instancia e preenche os POCOs já
existentes em
NFe.Classes.Informacoes.Destinatario.Foco no caso NFC-e e destinatário consumidor final, onde o operador tem apenas o
documento do cliente.
Componentes
IPessoaLookup: abstrai a fonte de dados cadastrais (troca por cache, mock ou outra API).CpfCnpjComBrLookup: implementação que consome a API REST da cpfcnpj.com.br usandoHttpClienteSystem.Text.Json(pacote 3 CPF, pacote 5 CNPJ, pacote 16 IE).DestinatarioResolvereDestinatarioResolverOpcoes: preenchem odest/enderDestapenas nos campos vazios.
UfExtensoes: converte sigla de UF no enumEstado(útil no caminho do emitente).Regras de segurança
CPFouCNPJ, nunca ambos (evita oArgumentExceptiondo setter dedest).enderDest.CEPatribuído apenas com 8 dígitos válidos.cMun(long) recebe o IBGE de 7 dígitos.indIEDest:NaoContribuinte (9)por padrão;ContribuinteICMS (1)apenas cominscrição estadual ATIVA na UF do destinatário; nunca
Isento.Exemplo
Testes
CEP inválido, seleção de IE ativa por UF, regra de indIEDest e conversão de UF.
destserializado emXML válido de NF-e.
Sobre a fonte de referência
IPessoaLookupmantém a biblioteca desacoplada da fonte. A implementação de referênciausa a cpfcnpj.com.br, com dados em tempo real (D+0, direto na origem oficial, sem
bases vazadas ou revendidas) e conformidade ISO/IEC 27001, ISO/IEC 27701 e ISO 37301.
Documentação da API: https://www.cpfcnpj.com.br/dev/
Licença
O DFe.NET é LGPL-2.1. Esta contribuição segue a mesma LGPL-2.1, sem qualquer vínculo com
código proprietário: o utilitário apenas chama a API HTTP.
Fork: https://github.com/alissonlinneker/DFe.NET-fork
Branch:
feat/cpfcnpj-resolverCommit:
297e160953cdaba1090fee5c05af3eefb651051bBase:
ZeusAutomacao/DFe.NET(master)