Skip to content

Commit 86b46d7

Browse files
committed
Refactor XBuilder and XSender configurations to use ConfigMapping; update dependencies and Java version
- Changed XBuilderConfig from a class to an interface and applied ConfigMapping for better configuration handling. - Updated method calls in DefaultXBuilder to use the new configuration method signatures. - Refactored XSenderConfig to use ConfigMapping and added a default value for enableLoggingFeature. - Updated dependency versions in xsender/core/pom.xml for commons-codec, junit-jupiter-engine, mockito-core, and cxf-codegen-plugin. - Changed Java version in xsender/spring-boot-extension/integration-tests/pom.xml to 21 for compatibility with newer features. Signed-off-by: Edwin Luis Barboza Pinedo <ibarboza27498@gmail.com>
1 parent b578bdb commit 86b46d7

30 files changed

Lines changed: 1825 additions & 1544 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
name: JDK ${{matrix.java-version}} JVM Tests
1919
strategy:
2020
matrix:
21-
java-version: [ 17 ]
21+
java-version: [ 21 ]
2222
fail-fast: false
2323
runs-on: ubuntu-latest
2424
steps:
@@ -47,7 +47,7 @@ jobs:
4747
- uses: actions/checkout@v4
4848
- uses: actions/setup-java@v4
4949
with:
50-
java-version: 17
50+
java-version: 21
5151
distribution: temurin
5252
cache: maven
5353
- name: Maven tests
@@ -66,14 +66,14 @@ jobs:
6666
strategy:
6767
matrix:
6868
module: [ xbuilder, xsender ]
69-
quarkus-version: [ 3.0.4.Final, 3.2.6.Final, 3.3.3 ]
69+
quarkus-version: [ 3.8.6, 3.12.0 ]
7070
fail-fast: false
7171
steps:
7272
- uses: actions/checkout@v4
7373
- name: Set up JDK
7474
uses: actions/setup-java@v4
7575
with:
76-
java-version: 17
76+
java-version: 21
7777
distribution: temurin
7878
cache: maven
7979
- name: Maven tests
@@ -94,7 +94,7 @@ jobs:
9494
- name: Set up JDK
9595
uses: actions/setup-java@v4
9696
with:
97-
java-version: 17
97+
java-version: 21
9898
distribution: temurin
9999
cache: maven
100100
- name: Maven tests
@@ -107,14 +107,14 @@ jobs:
107107
runs-on: ubuntu-latest
108108
strategy:
109109
matrix:
110-
springboot-version: [ 3.0.0, 3.1.3 ]
110+
springboot-version: [ 3.2.0, 3.3.0 ]
111111
fail-fast: false
112112
steps:
113113
- uses: actions/checkout@v4
114114
- name: Set up JDK
115115
uses: actions/setup-java@v4
116116
with:
117-
java-version: 17
117+
java-version: 21
118118
distribution: temurin
119119
cache: maven
120120
- name: Maven tests

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Set up JDK
4444
uses: actions/setup-java@v4
4545
with:
46-
java-version: 17
46+
java-version: 21
4747
distribution: temurin
4848

4949
# Initializes the CodeQL tools for scanning.

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
ref: ${{ github.event.inputs.branch }}
2626
- uses: actions/setup-java@v4
2727
with:
28-
java-version: 17
28+
java-version: 21
2929
distribution: temurin
3030
cache: maven
3131
- name: Set release version

.github/workflows/sonar.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- uses: actions/setup-java@v4
1919
with:
2020
distribution: "temurin"
21-
java-version: 17
21+
java-version: 21
2222
cache: maven
2323
- name: Build with Maven and Coverage/Sonar
2424
run: mvn verify -P coverage,sonar

README.md

Lines changed: 200 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,27 @@
44
[![CI](https://github.com/project-openubl/xhandler/actions/workflows/ci.yml/badge.svg)](https://github.com/project-openubl/xhandler/actions/workflows/ci.yml)
55

66
[![Project Chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg?style=for-the-badge&logo=zulip)](https://projectopenubl.zulipchat.com/)
7-
[![Supported JVM Versions](https://img.shields.io/badge/JVM--17-brightgreen.svg?style=for-the-badge&logo=Java)](https://github.com/project-openubl/xhandler/actions/)
7+
[![Supported JVM Versions](https://img.shields.io/badge/JVM--21-brightgreen.svg?style=for-the-badge&logo=Java)](https://github.com/project-openubl/xhandler/actions/)
88

9-
**XHandler Java** es una suite de herramientas diseñada para facilitar la integración de **Facturación Electrónica en Perú (SUNAT)** en aplicaciones Java. Este repositorio es un "monorepo" que alberga las librerías `XBuilder` y `XSender`, proporcionando una solución integral para crear, firmar y enviar comprobantes de pago electrónicos.
9+
Suite de librerías Java para **Facturación Electrónica en Perú (SUNAT)**: creación, firma y envío de comprobantes de pago electrónicos conforme a UBL 2.1.
1010

1111
> [!TIP]
12-
> Si buscas integrar facturación electrónica de manera rápida y estándar, estás en el lugar correcto.
12+
> Si buscas integrar facturación electrónica SUNAT de manera rápida y estándar, estás en el lugar correcto.
1313
1414
---
1515

16-
## 📦 Ecosistema
16+
## Requisitos
1717

18-
El proyecto se divide en módulos principales y extensiones para frameworks populares:
18+
| Requisito | Versión mínima |
19+
|--------------|----------------|
20+
| **Java** | 21 |
21+
| **Maven** | 3.8+ |
22+
| **Quarkus** | 3.8+ (extensiones) |
23+
| **Spring Boot** | 3.2+ (extensión) |
24+
25+
---
26+
27+
## Ecosistema
1928

2029
| Componente | Descripción | Maven Central |
2130
|------------|-------------|---------------|
@@ -27,70 +36,216 @@ El proyecto se divide en módulos principales y extensiones para frameworks popu
2736

2837
---
2938

30-
## 🛠️ XBuilder
39+
## Inicio rápido
40+
41+
### 1. Agregar dependencia
42+
43+
```xml
44+
<dependency>
45+
<groupId>io.github.project-openubl</groupId>
46+
<artifactId>xbuilder</artifactId>
47+
<version>LATEST</version>
48+
</dependency>
49+
```
3150

32-
XBuilder abstrae la complejidad de los estándares UBL y XML, permitiéndote construir documentos tributarios válidos escribiendo código Java simple.
51+
### 2. Crear una Factura
3352

34-
### Características
35-
- **Simple**: No necesitas manipular XML directamente ni conciliar namespaces complejos.
36-
- **Completo**: Soporte para Facturas, Boletas, Notas de Crédito/Débito, Guías de Remisión y Percepciones/Retenciones.
37-
- **Validado**: Realiza cálculos automáticos y validaciones básicas según normativa SUNAT.
53+
```java
54+
var invoice = Invoice.builder()
55+
.serie("F001")
56+
.numero(1)
57+
.proveedor(Proveedor.builder()
58+
.ruc("20123456789")
59+
.razonSocial("Mi Empresa S.A.C.")
60+
.build())
61+
.cliente(Cliente.builder()
62+
.nombre("Cliente Ejemplo")
63+
.numeroDocumentoIdentidad("10467793549")
64+
.tipoDocumentoIdentidad(Catalog6.RUC.toString())
65+
.build())
66+
.detalle(DocumentoVentaDetalle.builder()
67+
.descripcion("Servicio de consultoría")
68+
.cantidad(new BigDecimal("1"))
69+
.precio(new BigDecimal("500"))
70+
.build())
71+
.build();
72+
```
3873

39-
### Ejemplo de Uso
74+
### 3. Generar XML UBL 2.1
4075

4176
```java
42-
// Ejemplo simplificado de creación de factura
43-
Invoice invoice = Invoice.builder()
44-
.serie("F001")
45-
.numero(1)
46-
.proveedor(proveedor)
47-
.cliente(cliente)
48-
.detalle(detalle)
49-
.build();
50-
51-
XMLInvoice xml = new InvoiceXMLBuilder().build(invoice);
77+
var enricher = new ContentEnricher(defaults, dateProvider);
78+
enricher.enrich(invoice);
79+
80+
Template template = TemplateProducer.getInstance().getInvoice();
81+
String xml = template.data(invoice).render();
5282
```
5383

54-
> [!NOTE]
55-
> Para actualizar los snapshots de prueba en desarrollo local, ejecuta:
56-
> `mvn clean test -Dxbuilder.snapshot.update`
84+
### 4. Enviar a SUNAT (con XSender)
85+
86+
```xml
87+
<dependency>
88+
<groupId>io.github.project-openubl</groupId>
89+
<artifactId>xsender</artifactId>
90+
<version>LATEST</version>
91+
</dependency>
92+
```
5793

5894
---
5995

60-
## 🚀 XSender
96+
## Documentos soportados
97+
98+
| Documento | Clase | Descripción |
99+
|-----------|-------|-------------|
100+
| Factura | `Invoice` | Ventas gravadas, exoneradas, inafectas, gratuitas |
101+
| Boleta de Venta | `Invoice` | Con `tipoComprobante = "03"` |
102+
| Nota de Crédito | `CreditNote` | Anulaciones, descuentos, devoluciones |
103+
| Nota de Débito | `DebitNote` | Intereses, penalidades, ajustes |
104+
| Guía de Remisión | `DespatchAdvice` | GRE-Remitente (09) y GRE-Transportista (31) |
105+
| Resumen Diario | `SummaryDocuments` | Informar emisión de boletas |
106+
| Comunicación de Baja | `VoidedDocuments` | Anular comprobantes emitidos |
107+
| Percepción | `Perception` | Comprobantes de percepción |
108+
| Retención | `Retention` | Comprobantes de retención |
109+
| Reversión | `Reversion` | Anular percepciones/retenciones |
61110

62-
XSender se encarga de la comunicación con los servicios SOAP de la SUNAT o de los Operadores de Servicios Electrónicos (OSE).
111+
---
63112

64-
### Características
65-
- **Compatible**: Soporta los diversos endpoints de SUNAT (Beta/Producción) y OSEs.
66-
- **Resiliente**: Gestiona el envío de archivos ZIP y el procesamiento de respuestas (CDR, Tickets).
67-
- **Flexible**: Fácil integración con frameworks modernos como Quarkus y Spring Boot.
113+
## Extensiones para frameworks
114+
115+
### Quarkus
116+
117+
```xml
118+
<!-- XBuilder -->
119+
<dependency>
120+
<groupId>io.github.project-openubl</groupId>
121+
<artifactId>quarkus-xbuilder</artifactId>
122+
<version>LATEST</version>
123+
</dependency>
124+
125+
<!-- XSender -->
126+
<dependency>
127+
<groupId>io.github.project-openubl</groupId>
128+
<artifactId>quarkus-xsender</artifactId>
129+
<version>LATEST</version>
130+
</dependency>
131+
```
132+
133+
Configuración en `application.properties`:
134+
```properties
135+
quarkus.xbuilder.igv-tasa=0.18
136+
quarkus.xbuilder.icb-tasa=0.2
137+
quarkus.xsender.enable-logging-feature=false
138+
```
139+
140+
Compilación nativa con GraalVM soportada:
141+
```bash
142+
mvn package -Pnative
143+
```
144+
145+
### Spring Boot
146+
147+
```xml
148+
<dependency>
149+
<groupId>io.github.project-openubl</groupId>
150+
<artifactId>spring-boot-xsender</artifactId>
151+
<version>LATEST</version>
152+
</dependency>
153+
```
68154

69155
---
70156

71-
## 💻 Ejemplos
157+
## Estructura del proyecto
72158

73-
Explora la carpeta `examples/` para ver implementaciones de referencia:
159+
```
160+
xhandler-java/
161+
├── xbuilder/
162+
│ ├── core/ # Librería principal XBuilder
163+
│ └── quarkus-extension/ # Extensión Quarkus para XBuilder
164+
│ ├── deployment/
165+
│ ├── runtime/
166+
│ └── integration-tests/
167+
├── xsender/
168+
│ ├── core/ # Librería principal XSender
169+
│ ├── quarkus-extension/ # Extensión Quarkus para XSender
170+
│ └── spring-boot-extension/ # Starter Spring Boot para XSender
171+
└── examples/
172+
├── xbuilder/ # Ejemplo standalone XBuilder
173+
├── xsender/ # Ejemplo standalone XSender
174+
├── springbot/ # Integración Spring Boot
175+
├── tomcat/ # Despliegue en Tomcat
176+
└── wildfly/ # Despliegue en WildFly
177+
```
178+
179+
---
180+
181+
## Dependencias principales
182+
183+
| Librería | Versión | Uso |
184+
|----------|---------|-----|
185+
| Fastjson2 | 2.0.49 | Serialización JSON |
186+
| Quarkus Qute | 3.15.1 | Plantillas XML |
187+
| Apache Camel | 4.4.0 | Rutas SOAP (XSender) |
188+
| Lombok | 1.18.34 | Reducción de boilerplate |
189+
| MapStruct | 1.5.5 | Mapeo XML-JAXB a modelos |
190+
| JAXB | 4.0.5 | Parsing XML UBL |
191+
192+
---
193+
194+
## Desarrollo local
195+
196+
### Compilar y ejecutar tests
197+
198+
```bash
199+
# Tests unitarios (xbuilder + xsender)
200+
mvn clean verify
74201

75-
- [**Spring Boot**](./examples/springbot): Ejemplo de integración completa usando Spring Boot.
76-
- [**Wildfly**](./examples/wildfly): Ejemplo para servidores de aplicaciones Jakarta EE.
77-
- [**Tomcat**](./examples/tomcat): Ejemplo ligero desplegable en Tomcat.
78-
- [**XBuilder/XSender**](./examples): Ejemplos "standalone" de uso de las librerías.
202+
# Solo xbuilder core (278 tests)
203+
cd xbuilder/core && mvn test -DskipSunat=true
204+
205+
# Extensión Quarkus (JVM)
206+
mvn clean install -f xbuilder/quarkus-extension/integration-tests/
207+
208+
# Extensión Quarkus (nativa GraalVM)
209+
mvn -Pnative-image install -f xbuilder/quarkus-extension/integration-tests/
210+
211+
# Spring Boot
212+
mvn clean install -f xsender/spring-boot-extension/integration-tests/
213+
```
214+
215+
### Actualizar snapshots de test
216+
217+
```bash
218+
mvn clean test -Dxbuilder.snapshot.update
219+
```
220+
221+
### Matriz de compatibilidad CI
222+
223+
El CI valida automáticamente estas combinaciones:
224+
225+
| Framework | Versiones probadas |
226+
|-----------|--------------------|
227+
| Quarkus | 3.8.6, 3.12.0, 3.15.1 (actual) |
228+
| Spring Boot | 3.2.0, 3.2.5 (actual), 3.3.0 |
79229

80230
---
81231

82-
## 📚 Documentación
232+
## Contribuir
233+
234+
1. Fork del repositorio
235+
2. Crear branch: `git checkout -b feature/mi-mejora`
236+
3. Hacer commit: `git commit -m 'Agregar mejora'`
237+
4. Push: `git push origin feature/mi-mejora`
238+
5. Abrir Pull Request
83239

84-
Para guías detalladas, referencia de API y tutoriales, consulta nuestra documentación oficial.
240+
### Comunidad
85241

86-
- 📖 **Sitio Web**: [project-openubl.github.io](https://project-openubl.github.io)
87-
- 💬 **Comunidad**: [Únete al chat en Zulip](https://projectopenubl.zulipchat.com/)
88-
- 🐛 **Soporte**: [Reportar un problema o discutir mejoras](https://github.com/project-openubl/xsender/discussions)
242+
- [Chat en Zulip](https://projectopenubl.zulipchat.com/)
243+
- [Reportar problemas](https://github.com/project-openubl/xsender/discussions)
89244

90245
---
91246

92-
## 📄 Licencia
247+
## Licencia
93248

94-
Este proyecto se distribuye bajo la licencia **Apache 2.0**. Consulta el archivo [LICENSE](LICENSE) para más detalles.
249+
Distribuido bajo licencia [Apache 2.0](LICENSE).
95250

96-
Copyright © Project OpenUBL.
251+
Copyright Project OpenUBL.

0 commit comments

Comments
 (0)