Skip to content

feat: complete source-backed NT009 optional preview groups (issue 95) - #104

Merged
vitormattos merged 2 commits into
mainfrom
feat/issue-95-nt009-remaining-annex-groups
Oct 9, 2026
Merged

vitormattos merged 2 commits into
mainfrom
feat/issue-95-nt009-remaining-annex-groups

Conversation

@vitormattos

@vitormattos vitormattos commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Follow-up to issue #95 (NT009 v1.01)

Base: main at 2a8b660c4f4471d62a79d7aa64597740bc9ae2ad after #103.

Implemented from the checksum-pinned official Annex VI v1.04.01 matrix

  • IBSCBS/indZFMALC: operation-indicator whitelist in Annex VI row 377 plus explicit caller verification of ZFM/ALC geographical eligibility; no inferred zero CBS amounts.
  • IBSCBS/tpOper and gRefNFSe/refNFSe (rows 378–380): document-operation codes 1–5 and required 1–99 explicitly supplied prior invoice keys when tpOper is 2/3.
  • IBSCBS/tpEnteGov (row 381): codes 1–4 with caller-verified government-purchase context.
  • IBSCBS/indDoacao (row 382): opt-in explicitly classified donation without consideration; no inferred classification/credit amounts.
  • IBSCBS/valores/trib/gIBSCBS/gTribRegular (rows 431–433) and gDif (rows 434–437): typed DTOs and cardinality/format checks.
  • Correct element ordering, 13 additional positive/negative tests and current downstream compatibility notes.

No change to the existing DpsData constructor, XmlBuilder::buildDps(), NfseClient::emit(), DpsSchemaValidator or Akaunting dependency. All new arguments are opt-in and appended to the NT009 preview DTO. Published Annex VII v1.03.00 codes are verified through OfficialDomainCatalog. Advisory Annex VIII is not enforced.

What this PR does not (and cannot yet) certify

As of 2026-10-09, the official RTC page publishes NT009 v1.01 and Annexes VI/VII, but its production documentation still identifies NFSe-ESQUEMAS_XSD-v1.01-20260209 and its restricted production documentation NFSe-ESQUEMAS_XSD-PRODREST-v1.01-20260727. Neither is identified as an effective NT009 v1.04.01 contract for the target SEFIN environment. The NT009 PDF and Annex VI also disagree about the gIBSCBSAjuste parent. Fiscal tax-domain repercussions and SEFIN acceptance are not established.

Consequently, these models remain review-only. It would be unsafe to introduce the new draft structure into the real emitter or claim all production acceptance criteria are met. Do not mark issue #95 as completed merely because this structural PR merges; reconcile the normative activation evidence and test against an official effective XSD first.

Verification

  • Cryptographically signed DCO commit via Git Signing MCP.
  • Checked row numbers and cardinality against the committed deterministic Annex I/VI comparison.
  • Lint repair: The original PHP CS Fixer failure was import ordering in tests/Unit/Xml/Nt009DpsPreviewBuilderTest.php. The first attempted unified patches failed git apply --check (not network fetch); fixed with a complete-file upsert in signed commit fb5a87889ee860cea631c5b2a141c3bae9cae4c4. The verified follow-up diff changes only two import positions. All six GitHub Actions workflows were restarted on this commit and their results are pending; do not merge until green.
  • No independent network-backed local Composer test environment was available.

Official pages: https://www.gov.br/nfse/pt-br/biblioteca/documentacao-tecnica/rtc ; https://www.gov.br/nfse/pt-br/biblioteca/documentacao-tecnica/documentacao-atual ; https://www.gov.br/nfse/pt-br/biblioteca/documentacao-tecnica/producao-restrita .

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos
vitormattos marked this pull request as ready for review October 9, 2026 13:45
@vitormattos
vitormattos merged commit 2f9324a into main Oct 9, 2026
13 checks passed
@vitormattos
vitormattos deleted the feat/issue-95-nt009-remaining-annex-groups branch October 9, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant