Skip to content

feat: expand source-backed NT009 DPS review-only groups (#95) - #101

Merged
vitormattos merged 29 commits into
mainfrom
feat/issue-95-nt009-structured-groups
Oct 9, 2026
Merged

vitormattos merged 29 commits into
mainfrom
feat/issue-95-nt009-structured-groups

Conversation

@vitormattos

@vitormattos vitormattos commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Issue #95 — documented NT009 structures (non-emitting preview)

Continues merged PR #100, starting from main at 4fe03be2b4e289efc563b446ec680e3456bbdb53. Issue #95 has been reopened because the October NT009 contract was not yet implemented as a verified production emitter.

Implemented in this PR

  • Extend the explicit XmlBuilder::previewNt009Dps() API without changing the legacy buildDps(), DpsData constructor, DpsSchemaValidator or NfseClient::emit().
  • Recipient (infDPS/dest, Anexo VI rows 180–200): typed CNPJ/CPF/NIF choice and validated national/foreign address, correctly escaped text and conditional indDest group.
  • Base adjustment (infDPS/valores/vAjusteBC, rows 293–336): exactly one ISSQN percentage, value or document-backed mode, up to 1,000 docAjusteBC entries, typed mutually exclusive dFeNacional / docFiscalOutro / docOutro references, optional dates and independently specified supplier. Supplier street/address nesting follows the distinct official paths. The old DpsData::deducaoReducao / vDedRed is rejected in this preview rather than silently reused.
  • Movable property rental (IBSCBS/bensMoveis, rows 404–407): up to 1,000 NCM/description/quantity records, restricted to cTribNac=99.04.01.
  • Linked payments (IBSCBS/gPgtoVinc/pgto, rows 443–449): 1–99 transactions with validated methods, identifiers, and uniqueness.
  • Real estate (IBSCBS/imovel, rows 383–403): municipality, classified optional lease and up to 99 property units with addresses and per-unit adjustments.
  • Condominiums (IBSCBS/condominios, rows 408–421): billing categories, optional breakdowns and discounts, exact-decimal charge reconciliation with arbitrarily large cent sums without integer overflow or floats.
  • Deterministic PHPUnit for hierarchy, element order, financial and date conditions, XML-escaped input, cardinalities, invalid combinations, legacy isolation and large monetary amounts. Refined docs/NT009-CONTRACT-IMPLEMENTATION.md.

All new features remain under opt-in review-only Nt009DpsPreview, not under fiscal submission.

Latest verification

Commit: d0d1dd84ca207ae7bf1ba7bb69147b7015e958c5.

All six GitHub Actions workflows passed, including full PHPUnit across PHP 8.2/8.3/8.4 and coverage, Psalm, PHP CS Fixer, minimum-dependency checks, REUSE and commit conventions. Review-only changes do not touch the official Annex/XSD source-monitoring workflows; the baseline 450-row matrix and 40 official indicator snapshot from PR #100 remain unchanged.

All 29 incremental commits in this PR have been verified cryptographically by GitHub and include the server-confirmed DCO Signed-off-by. No squash, no merge, no changes to LibreCodeCoop/akaunting-nfse.

Normative blockers: issue #95 MUST remain open

  • The NFS-e official RTC portal, as currently published, still does not identify a deployed NT009 v1.04.01 compatible XSD or activation date for production/restricted production. Production v1.01 (Feb 2026) and restricted v1.01 (Jul 2026) are different packages. A source workbook is not a certified emission schema.
  • The NT009 PDF section 2.2 and Annex VI v1.04.01 differ on the placement of gIBSCBSAjuste. Do not silently decide its normative hierarchy.
  • Complete tax-code/classification indicators, detailed adjustment repercussions and additional conditional rules require independent official evidence before enforcing them. Annex VIII remains consultative.
  • This PR does not offer a validated NT009 emitter. Until an authoritative effective XSD and SEFIN acceptance behavior are verified, do not update Akaunting's Composer pin or route any fiscal submissions through the preview.

Reviewer outcome: this PR is ready for code review, but issue #95 is not ready for closure and production NT009 conformity is not claimed. Merge only after explicit user authorization.

…ents

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…isolation

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…n gates

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…view

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…itations

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…nces

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…rializer

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…modes

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…maining rules

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…floats

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos vitormattos changed the title feat: complete source-backed NT009 draft groups and guard legacy fiscal XML (#95) feat: expand source-backed NT009 DPS review-only groups (#95) Oct 9, 2026
@vitormattos
vitormattos marked this pull request as ready for review October 9, 2026 04:37
@vitormattos
vitormattos merged commit 2c5c846 into main Oct 9, 2026
13 checks passed
@vitormattos
vitormattos deleted the feat/issue-95-nt009-structured-groups branch October 9, 2026 04:39
vitormattos added a commit that referenced this pull request Oct 9, 2026
…-contract-guards

fix: validate published NT009 preview constraints after #101 (#95)
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