Skip to content

Epic: complete and harden the National NFS-e protocol client #47

Description

@vitormattos

Outcome

Make nfse-php a robust, reusable protocol layer for the National NFS-e ecosystem, with versioned official contracts, complete contributor operations, strict validation and testable transport/security boundaries.

Why

The library already covers emission, DPS recovery, query, cancellation, selected event lookup, ADN distribution, municipal parameters, DANFSe v2, IBS/CBS, foreign takers and XML signature integrity. The remaining gaps are protocol completeness and preservation of testable architecture while the protocol surface grows.

A comparison with other National NFS-e SDKs found a recurring failure mode: clients/services gradually accumulate XML construction, certificate handling, signing, HTTP, retry and parsing responsibilities. #60 therefore requires a characterization-first architecture audit before major new protocol features are allowed to increase that coupling.

Other open implementations demonstrate useful patterns: versioned official XSD fixtures, domain-table snapshots, integration fixtures, explicit transport abstractions and substitution/event coverage. The official National NFS-e API also supports substitution semantics and generic event operations beyond the current convenience methods.

Scope

  • official schema/version lifecycle and XSD validation
  • NFS-e substitution support
  • complete generic SEFIN event operations
  • versioned official domain/correlation tables
  • received-signature trust verification separated from integrity verification
  • injectable/testable HTTP transport and safe retry policy
  • sanitized official response fixtures/contract tests
  • remaining production fiscal groups such as deductions/reductions/benefits and administrative/judicial decision emission

Out of scope

  • Akaunting UI/persistence
  • municipality-specific legacy SOAP providers
  • NFS-e Via/concessionaire features unless they become applicable to the normal contributor API
  • silently inferring tax treatment
  • unsafe retries of mutating fiscal operations

Success criteria

  • generated DPS/event XML is validated against the exact supported official XSD release
  • protocol versions and official tables are explicit and auditable
  • substitution and event lifecycle are represented without Akaunting-specific assumptions
  • transport behavior is injectable and deterministic in tests
  • XML signature integrity and certificate trust are distinct concepts in the API
  • fixture tests cover success, rejection, timeout and malformed upstream payloads

Definition of done

  • all child issues complete
  • public API changes documented with migration notes
  • compatibility tests pass on supported PHP versions and minimum dependency set
  • no cross-layer Akaunting dependency introduced

Intended GitHub issue type: Epic.

Child issues

Activity

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