Skip to content

Feat/danfse local generation#20

Merged
vitormattos merged 13 commits into
mainfrom
feat/danfse-local-generation
Jul 2, 2026
Merged

Feat/danfse local generation#20
vitormattos merged 13 commits into
mainfrom
feat/danfse-local-generation

Conversation

@YvesCesar

Copy link
Copy Markdown
Contributor

Summary

Replaces ADN-API DANFSe retrieval with local PDF generation from the authorized NFS-e XML. getDanfse() no longer makes a network call, it renders the document locally (HTML → PDF via dompdf), including the public-consultation QR code and IBGE municipality lookup. Adds a new Danfse\ subsystem, unit tests, and an NFS-e fixture.

Why

The ADN DANFSe generation API is sunset on 2026-07-01 (RTC Nota Técnica 008). Keeping that dependency would leave getDanfse broken after that date. Generating the PDF locally from the XML we already hold (ReceiptData::$rawXml, returned by emit/query) removes the network dependency, drops latency and a failure point, and keeps the feature working past the sunset.

Changes

Local DANFSe generation (new src/Danfse/ subsystem)

  • DanfseGenerator — orchestrates XML parse → authorized-NFS-e validation → HTML render → PDF (dompdf), wrapping failures in ArtifactException.
  • XmlToArray — converts the national XML into an associative array, skipping the digital signature (xmldsig namespace).
  • DanfseTemplate + template.php — build and render the layout (issuer, taker, intermediary, service, municipal/federal taxation, totals, QR code, homologação watermark).
  • Formatter — Brazilian formatting (CNPJ/CPF, phone, CEP, currency, dates, taxation code).
  • Data\Municipios — municipality lookup by IBGE code.
  • Domain enums: OpSimpNac, RegApTribSN, RegEspTrib, TpRetISSQN, TribISSQN, Ambiente.
  • Optional presentation config: DanfseConfig, MunicipalityBranding, LogoLoader (provider / municipality logo).

Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
@YvesCesar YvesCesar requested a review from vitormattos as a code owner June 30, 2026 22:17
Comment thread src/Danfse/HTMLTemplate.php
Comment thread tests/Unit/Danfse/EnumLabelsTest.php Outdated
Comment thread tests/Unit/Danfse/FormatterTest.php Outdated
Comment thread tests/Unit/Danfse/MunicipiosTest.php Outdated
Comment thread REUSE.toml Outdated
Comment thread REUSE.toml Outdated
Comment thread src/Contracts/NfseClientInterface.php
Comment thread tests/Unit/Danfse/FormatterTest.php Outdated
YvesCesar and others added 6 commits July 1, 2026 19:06
Co-authored-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
@YvesCesar YvesCesar force-pushed the feat/danfse-local-generation branch from 5f4b394 to 2c0eede Compare July 1, 2026 23:06
YvesCesar added 3 commits July 1, 2026 19:23
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
@YvesCesar

Copy link
Copy Markdown
Contributor Author

@vitormattos finalizei os ajustes da rodada de revisões.

@vitormattos vitormattos merged commit 3835241 into main Jul 2, 2026
10 checks passed
@vitormattos vitormattos deleted the feat/danfse-local-generation branch July 2, 2026 00:16
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.

2 participants