How villano14/sunat-go works
sunat-go is a library for preparing Peruvian electronic tax documents and submitting them to SUNAT. Its main workflow accepts caller-provided document data, renders UBL, signs the XML, sends it through the relevant SOAP or GRE REST interface, and parses returned CDRs or status. The graph also preserves optional calculations, document catalogs, purchase settlements, batch summaries/reversions, withholding documents, status queries, and caller-prepared ZIP packs. Some flow links are based on README documentation because their implementation excerpts were not provided.
Main entry points: sunat_gre.go GRE Client · sunat_batch.go Batch and Status Facade · sunat.go Document Client · sign.go XML Signer
Components 27
Documents and Data
- Invoices and Notes
model/invoice.go - Batch Documents
model/batch.go - Purchase Settlements
model/purchase.go - Retention and Perception
model/withholding.go - Despatch Guides
model/despatch.go - SUNAT Catalogs
catalog/catalog.go
Calculation and UBL
- Line Calculations
calc/calc.go - Document Totals
calc/totals.go - Settlement Calculations
calc/settlement.go - Invoice UBL
ubl/invoice.go - Summary and Void UBL
ubl/batch.go - Settlement UBL
ubl/purchase.go - Other UBL Documents
ubl
SOAP SUNAT
- Document Client
sunat.go - Batch and Status Facade
sunat_batch.go - Other SOAP Facades
sunat_note.go - SOAP Transport
transport/transport.go - Batch and Consult Transport
transport/batch.go - Otros CPE Transport
transport/otroscpe.go
GRE REST
- GRE Client
sunat_gre.go - GRE REST and OAuth
gre/gre.go - Token Handling
gre/token.go
Shared Services
- XML Signer
sign/sign.go - Certificate Loading
sign/cert.go - CDR Parsing
cdr/cdr.go
Other components
- Library Caller
- SUNAT Services
Connections 33
- Library Caller → Document Client: builds or sends
README.md - Document Client → Invoice UBL: renders invoices
README.md - Document Client → XML Signer: signs XML
sunat.go - Document Client → SOAP Transport: submits documents
README.md - Library Caller → Batch and Status Facade: builds or sends
README.md - Batch and Status Facade → Summary and Void UBL: renders batches
sunat_batch.go - Batch and Status Facade → XML Signer: signs XML
sunat_batch.go - Batch and Status Facade → Batch and Consult Transport: sends and polls
README.md - Batch and Status Facade → CDR Parsing: parses CDR
sunat_batch.go - Library Caller → Other SOAP Facades: uses document flows
README.md - Other SOAP Facades → Other UBL Documents: renders documents
README.md - Other SOAP Facades → Otros CPE Transport: sends documents
README.md - SOAP Transport → SUNAT Services: SOAP requests
README.md - Batch and Consult Transport → SUNAT Services: status and CDR queries
README.md - Library Caller → GRE Client: builds or sends guides
README.md - GRE Client → Despatch Guides: accepts guide data
sunat_gre.go - GRE Client → Other UBL Documents: renders despatch
sunat_gre.go - GRE Client → XML Signer: signs XML
sunat_gre.go - GRE Client → GRE REST and OAuth: sends and checks status
sunat_gre.go - GRE Client → CDR Parsing: parses returned CDR
sunat_gre.go - GRE REST and OAuth → SUNAT Services: REST requests
README.md - GRE REST and OAuth → Token Handling: obtains OAuth token
gre/gre.go - Library Caller → Line Calculations: optionally calculates lines
README.md - Library Caller → Document Totals: optionally aggregates
README.md - Library Caller → Settlement Calculations: optionally calculates settlement
README.md - Line Calculations → SUNAT Catalogs: uses codes
calc/calc.go - Line Calculations → Invoices and Notes: returns line data
calc/calc.go - Document Totals → SUNAT Catalogs: classifies taxes
calc/totals.go - Settlement Calculations → Purchase Settlements: produces settlement
calc/settlement.go - Invoices and Notes → Invoice UBL: renders as UBL
ubl/invoice.go - Batch Documents → Summary and Void UBL: renders as UBL
ubl/batch.go - Purchase Settlements → Settlement UBL: renders as UBL
ubl/purchase.go - Certificate Loading → XML Signer: loads credentials