Skip to content

Support emission under administrative or judicial decision rules #56

Description

@vitormattos

Parent epic: #47

Context

The current production documentation includes a dedicated contributor guide for emission under administrative or judicial decisions, including RTC/IBS-CBS related cases.

This is not part of the normal LibreCode issuance path but is part of protocol completeness and avoids future raw-XML workarounds.

Goal

Model the official decision-related DPS fields and validations as an opt-in capability.

Scope

  • identify exact production XSD/layout fields and business constraints
  • add typed DTO fields/value objects only where required
  • serialize in correct XSD order
  • document that the consumer is responsible for legal eligibility
  • expose capability without changing ordinary emission defaults

Constraints

  • no legal inference or automatic decision classification
  • feature remains opt-in
  • do not mix NFS-e Via-only decision fields with normal contributor API fields

Tests

  • representative valid decision payloads from official documentation
  • required-field validation
  • incompatible field combinations rejected
  • ordinary DPS byte/semantic regression

Definition of done

  • official production examples represented by tests
  • XSD validation passes
  • migration/API documentation added

Current official contract discovery (2026-10-04)

The current production guide Emissão de NFS-e nos casos de decisão administrativa ou judicial changes the implementation boundary assumed when this issue was opened.

The documented decision flow is not merely an opt-in set of additional DPS fields. It is a dedicated bypass flow where the contributor constructs the complete NFS-e XML and submits it to:

POST /decisao-judicial/nfse

The guide documents contributor-owned fields for this path, including the decision status, NFS-e number/identifier and generated NFS-e metadata, and states that normal query/cancellation operations apply after authorization. Substitution can also be processed through the decision flow.

The existing issqnTipoSuspensao / issqnNumeroProcessoSuspensao support models the regular DPS exigSusp group and must not be treated as implementation of this issue.

Revised implementation direction

  • model the decision flow as a first-class protocol operation separate from ordinary DPS issuance;
  • create a typed complete-NFS-e decision payload/builder from the exact current production layout;
  • submit only through the dedicated decision endpoint;
  • validate the generated complete NFS-e XML against the exact supported official schema;
  • preserve ordinary emission defaults and APIs unchanged;
  • do not infer legal eligibility, decision classification, numbering or values;
  • add query/cancel/substitution contract tests proving interoperability after authorization.

Do not implement this issue by adding unrelated decision fields to DpsData.

Activity

  1. vitormattos commented on Oct 4, 2026

    @vitormattos
    MemberAuthor

    Implementation status after #81:

    • complete decision-flow NFS-e builder is now on main
    • contributor-owned bypass fields and fixed invariants are typed/tested
    • representative signed document is validated against NFSe_v1.01.xsd
    • ordinary DPS issuance remains unchanged

    Remaining transport work is now in #82: dedicated POST /decisao-judicial/nfse using the official xmlGZipB64 contract. Keep this issue open until #82 is merged and documentation/interoperability requirements are rechecked.

  2. vitormattos commented on Oct 4, 2026

    @vitormattos
    MemberAuthor

    Completed by #81, #82 and #84.

    Final contract:

    • complete decision-flow NFS-e is built as a first-class protocol document
    • fixed bypass invariants and access-key construction are covered by tests
    • signed representative document validates against the official NFS-e v1.01 schema
    • transport uses the dedicated POST /decisao-judicial/nfse endpoint with official xmlGZipB64 payload
    • mutable POST is not blindly retried
    • the capability is exposed separately through DecisionNfseIssuerInterface, preserving ordinary NfseClientInterface compatibility
    • successful authorization is proven to interoperate with normal query/cancel APIs
    • substitution relationship is preserved in the embedded DPS
    • public documentation records legal eligibility boundaries, the current nDFSe manual/XSD contradiction, schema validation guidance, and current IBS/CBS limitation

    All PR gates for the final implementation passed before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions