[IMP] l10n_br_nfse_paulistana: serializador parametrizado para schema v02 (Reforma Tributária)#733
Draft
mileo wants to merge 1 commit into
Draft
Conversation
…(RT 2026) Add PAULISTANA_BINDINGS registry mapping nfse_version to the nfselib bindings module and header Versao: - v02: schema v01 (legacy, taxable events until 2025-12-31), Versao=1 - v03: schema v02 (Reforma Tributaria IBS/CBS), Versao=2 serialize_nfse_paulistana(nfse_version=...) keeps v02 as default, so current behavior is unchanged. In the v03 bindings tpAssinatura is xs:base64Binary (generateDS export b64encodes and requires bytes), so the RPS signature string is ascii-encoded before assignment. KNOWN GAP (follow-up): in schema v02 the service amount fields moved to new groups; ValorTotalServicos/ValorTotalDeducoes (Cabecalho) and ValorServicos (RPS) are silently swallowed by the generateDS constructor kwargs and are absent from the v03 output. Mapping the amounts (and the new IBS/CBS groups) is required before using v03 for real emission.
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.
Contexto
Preparação para a emissão de NFS-e paulistana com os schemas da Reforma Tributária 2026 (IBS/CBS). Empilhado sobre #732 (fix dos testes) — mergear aquele primeiro.
Na
nfselib.paulistana, o pacotev03contém as bindings do schema v02 da prefeitura (zipschemas-reformatributaria-v02-4, Manual WS v3.3.7).O que muda
PAULISTANA_BINDINGSmapeandonfse_version→ módulo de bindings +Versaodo cabeçalho (v02→1,v03→2).serialize_nfse_paulistana(nfse_version="v02")— default mantém o comportamento atual (schema legado). Com `"v03"", gera o lote no schema novo.tpAssinaturavirouxs:base64Binary(o export do generateDS aplica b64encode e exige bytes) → a string de 86 posições do RPS é codificada em ascii antes da atribuição. Mesmo ponto do bug latente no [IMP] paulistana: reforma tributaria erpbrasil/erpbrasil.edoc#94, que perdeu o.encode("ascii").test_serialize_nfse_paulistana_v03validando módulo de binding,Versao=2, assinatura em bytes e export do XML.No schema v02 os campos de valores mudaram de estrutura:
ValorTotalServicos/ValorTotalDeducoes(Cabecalho) eValorServicos(RPS) não são mais aceitos com esses nomes — o construtor do generateDS engole kwargs desconhecidos silenciosamente e o XML sai sem os valores de serviço. O mapeamento dos valores e dos grupos novos (IBS/CBS,tpValores,RetencaoPisCofins/NT-007) fica para PR subsequente.Testes
invoke test -m l10n_br_nfse_paulistananum doodba 18.0: 6 testes, 0 failed, 0 errors.