feat: LLM navigation support + Reforma Tributaria IBS/CBS/IS (NT 2025.002-RTC)#448
feat: LLM navigation support + Reforma Tributaria IBS/CBS/IS (NT 2025.002-RTC)#448felps-dev wants to merge 8 commits intoTadaSoftware:mainfrom
Conversation
Source maps provide section-by-section breakdowns with exact line ranges for all files over 200 lines, enabling LLMs to navigate directly to specific code sections instead of reading entire files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add core XML infrastructure for Brazil's dual VAT system (IVA Dual): - CST enumerations for IBS, CBS and IS in flags.py - Product-level and invoice-level entity fields in notafiscal.py - XML serialization (impostoMisto group) in serializacao.py - Totals accumulation and vNF formula updated - 5 test cases covering all serialization scenarios - Documentation in docs/reforma_tributaria.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ia tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Por favor crie uma pasta docs e coloque as documentações e referencie na docstring para os arquivos .md, para não ficar poluída as pastas de código. |
Address PR TadaSoftware#448 review feedback: consolidate documentation files under docs/ directory and use model-agnostic AGENTS.md naming. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…RTC schema Remove impostoMisto wrapper — IBSCBS is now direct child of <imposto>. Unify entity field naming to ibscbs_* pattern with shared vBC. Add IBSCBSTot totals with nested gIBS/gCBS structure, cMunFGIBS in <ide>, finNFe 5/6, and IS entity fields ready for 2027. Update docs and source maps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive support for Brazil's Reforma Tributaria (Constitutional Amendment 132/2023) dual VAT system and LLM navigation aids through source maps. The implementation focuses on core XML serialization infrastructure for the three new taxes (IBS, CBS, IS) that will gradually replace five existing taxes starting in 2026.
Changes:
- Added source map documentation files (
*_map.md) enabling efficient navigation of large files (>200 lines) without reading entire contents - Implemented IBS/CBS/IS entity fields, CST enumerations, XML serialization with
<IBSCBS>as direct child of<imposto>, and totals accumulation in separate<IBSCBSTot>group - Added comprehensive test suite (8 test methods) covering full taxation, exemption, backward compatibility, totals accumulation, legacy/reform coexistence, vNF exclusion, and IS entity storage
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_nfe_serializacao_reforma_tributaria.py | 8 comprehensive test cases for IBS/CBS/IS XML serialization and totals |
| pynfe/utils/flags.py | Added IBS_CBS_TIPOS_TRIBUTACAO (15 3-digit CSTs), IS_TIPOS_TRIBUTACAO (7 2-digit CSTs), and finNFe values 5/6 |
| pynfe/entidades/notafiscal.py | Added reforma tributaria entity fields (ibscbs_, is_, totais_*, municipio_fato_gerador_ibs) with proper Decimal initialization and accumulation logic |
| pynfe/processamento/serializacao.py | Implemented IBSCBS/IS serialization methods with CST-based conditional emission, totals in IBSCBSTot group, vNF exclusion logic |
| docs/reforma_tributaria.md | Comprehensive documentation of tax reform implementation with usage examples and technical references |
| docs/*_map.md | Source navigation maps for serializacao.py, comunicacao.py, notafiscal.py, flags.py, and other large files |
| AGENTS.md | LLM navigation guide mandating source map consultation before reading large files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Contexto sobre o desenvolvimento da Reforma Tributaria: O plano inicial de implementacao foi feito utilizando o Gemini, que gerou uma estrutura com bastante alucinacao sobre o XSD do XML — nomes de tags incorretos, estruturas de grupos inventadas, e relacoes entre elementos que nao existiam no schema real (PL 010b / Apos testes com clientes reais em producao e validacao direta no SEFAZ, fomos corrigindo os problemas com auxilio do Claude, ate chegar na estrutura correta:
O XML agora esta validando corretamente no ambiente de producao do SEFAZ. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Validado, todos os clientes da minha base estão emitindo normalmente NF-e e NFC-e com a reforma tributária. |
Summary
AGENTS.mdand source map files (*_map.md) for all large files (>200 lines), enabling LLM tools to navigate the codebase efficiently without reading entire files<IBSCBS>as direct child of<imposto>), totals accumulation (<IBSCBSTot>), tests, and documentationReforma Tributaria Details
Adds support for the three new taxes introduced by Brazil's tax reform (NT 2025.002-RTC):
Scope: Core XML serialization only (entity fields, CSTs, serialization, totals). No Split Payment, cashback, or transition calculation helpers.
Key design decisions:
<IBSCBS>is a direct child of<imposto>(no wrapper element) — per NT 2025.002-RTC schema (TTribNFetype)<gIBSUF>(estadual) and<gIBSMun>(municipal) with shared<vBC><IBSCBSTot>(typeTIBSCBSMonoTot) as sibling of<ICMSTot>under<total><cMunFGIBS>in<ide>header for IBS municipality of taxable eventvNFdoes NOT include IBS/CBS/IS values (prohibited in 2025-2026)_serializar_is()exists, not called)finNFe=5(Nota de Debito) andfinNFe=6(Nota de Credito) addedBackward compatible: If no
ibscbs_*fields are set, the<IBSCBS>group is not emitted — existing NF-e generation is unaffected.Files Changed
pynfe/utils/flags.pypynfe/entidades/notafiscal.pypynfe/processamento/serializacao.pytests/test_nfe_serializacao_reforma_tributaria.py(10 test cases)docs/reforma_tributaria.md,AGENTS.md,docs/*_map.mdsource mapsTest plan
<ide>headerruff checkpasses with no issues🤖 Generated with Claude Code