Greenter: Electronic Invoicing for Peru
repository·master·Indexed 43 days ago
https://github.com/thegreenter/greenterA PHP library for implementing SUNAT-compliant electronic invoicing in Peru. It automates UBL XML generation, digital signing, communication with SUNAT web services, and CDR processing. The ecosystem includes specialized packages for CPE validation, XML parsing, HTML-to-PDF report generation, and a lightweight 'Greenter Lite' version. Requires PHP 7.4+ and extensions including soap, zlib, openssl, and curl.
What's inside Greenter
- CPE Validator is a tool designed to validate electronic documents based on the CPE (Comprobante de Pago Electrónico) Validation Rules defined by SUNAT (Superintendencia Nacional de Aduanas y de Administración Tributaria). It ensures that electronic documents comply with the technical specifications required by the Peruvian tax authority.
Overview of Greenter for Electronic Invoicing in Peru
masterGreenter is a PHP library designed to implement Electronic Invoicing (Facturación Electrónica) in Peru, compliant with SUNAT regulations. It automates the core components of the invoicing process, including:
- Generating XML files according to the UBL standard.
- Signing XML files using a digital certificate.
- Sending invoices to SUNAT web services.
- Processing the CDR (Comprobante de Recepción).
- Providing various utility tools for the invoicing lifecycle.
For a practical implementation reference, you can view the @greenter/demo repository.
What is Greenter Lite?
masterGreenter Lite is a lightweight version of the Greenter library. It includes only the minimum required packages necessary to generate and send electronic receipts (comprobantes electrónicos). Use this version if you want to minimize dependencies while maintaining core functionality.Overview of Greenter Validator
masterGreenter Validator is a specialized component designed for electronic invoicing (Facturación Electrónica). Its primary purpose is to validate entities that represent electronic receipts/invoices (comprobantes electrónicos).Overview of Greenter WebServices
masterThewspackage provides the connection logic required to communicate with SUNAT (Superintendencia Nacional de Aduanas y de Administración Tributaria) web services. It is specifically designed for the transmission of electronic documents (comprobantes electrónicos) to the Peruvian tax authority.Overview of XML Parser - Greenter
masterThexml-parserpackage is a component of the Greenter ecosystem designed to convert XML data from electronic receipts (comprobantes electrónicos) into structured PHP classes. This allows developers to interact with XML data using object-oriented patterns instead of manual XML parsing.Convert HTML electronic receipts to PDF with htmltopdf
masterThe
htmltopdfpackage allows you to convert HTML representations of electronic receipts (comprobantes electrónicos) into PDF documents.For detailed implementation guides and technical specifications, refer to the official documentation at https://greenter.dev/packages/report/#reporte-en-pdf.
Identify SUNAT error codes and descriptions with XCodes
masterXCodes is a resource provided by Greenter that contains the error codes and their corresponding descriptions originating from SUNAT (Superintendencia Nacional de Aduanas y de Administración Tributaria) web services. It serves as a reference for developers to understand and handle errors returned during electronic invoicing processes in Peru.Generate HTML representations of electronic receipts with Greenter Report
masterThereportpackage allows you to create HTML representations of electronic receipts (comprobantes electrónicos). This is useful for generating human-readable versions of electronic documents for viewing or printing.Use Documents Data for testing
masterThepackages/datapackage provides invoice entities (Entidades de facturas) designed specifically to be used as examples for writing tests. Instead of manually constructing complex invoice objects, you can use these pre-defined entities to ensure your test suites are working with realistic data structures.Getting Started with Greenter
masterTo begin implementing electronic invoicing with Greenter, follow these resources:
- Basic Example: Start with the Greenter Starter Guide for a step-by-step implementation.
- Educational Guide: Read the Electronic Invoicing Guide to understand the underlying concepts and regulations.
- Non-PHP Environments: If you are using a programming language other than PHP, use Lycet to interact with the API via REST.
System Requirements for Greenter
masterTo use Greenter, ensure your environment meets the following requirements:
- PHP Version:
7.4or higher. - Required PHP Extensions:
soapzlibopensslcurl
- PHP Version: