From 51d288a8d27857519dbd83becf1ba29b4cb5e97e Mon Sep 17 00:00:00 2001 From: carlosthe19916 <2582866+carlosthe19916@users.noreply.github.com> Date: Sun, 16 Apr 2023 16:52:15 +0200 Subject: [PATCH 1/3] XML CDATA set raw content --- .../main/resources/templates/Renderer/creditNote.xml | 2 +- .../main/resources/templates/Renderer/debitNote.xml | 2 +- .../resources/templates/Renderer/despatchAdvice.xml | 12 ++++++------ .../main/resources/templates/Renderer/invoice.xml | 4 ++-- .../main/resources/templates/Renderer/perception.xml | 2 +- .../main/resources/templates/Renderer/retention.xml | 2 +- .../resources/templates/ubl/common/signature.xml | 2 +- .../templates/ubl/standard/include/address.xml | 2 +- .../templates/ubl/standard/include/customer.xml | 2 +- .../templates/ubl/standard/include/document-line.xml | 4 ++-- .../ubl/standard/include/note/invoice-reference.xml | 2 +- .../templates/ubl/standard/include/supplier.xml | 2 +- .../templates/ubl/sunat/include/agent-party.xml | 4 ++-- .../templates/ubl/sunat/include/receiver-party.xml | 2 +- .../templates/ubl/sunat/include/supplier.xml | 2 +- 15 files changed, 23 insertions(+), 23 deletions(-) diff --git a/core/src/main/resources/templates/Renderer/creditNote.xml b/core/src/main/resources/templates/Renderer/creditNote.xml index a268d348..91d0f406 100644 --- a/core/src/main/resources/templates/Renderer/creditNote.xml +++ b/core/src/main/resources/templates/Renderer/creditNote.xml @@ -5,7 +5,7 @@ {#include ubl/standard/include/ubl-extensions.xml /} {#include ubl/standard/include/general-data.xml item=this /} {#for key in leyendas.keySet} - + {/for} {moneda} {#include "ubl/standard/include/note/invoice-reference.xml" item=this /} diff --git a/core/src/main/resources/templates/Renderer/debitNote.xml b/core/src/main/resources/templates/Renderer/debitNote.xml index bc4fdaeb..f0e8fdfe 100644 --- a/core/src/main/resources/templates/Renderer/debitNote.xml +++ b/core/src/main/resources/templates/Renderer/debitNote.xml @@ -5,7 +5,7 @@ {#include ubl/standard/include/ubl-extensions.xml /} {#include ubl/standard/include/general-data.xml item=this /} {#for key in leyendas.keySet} - + {/for} {moneda} {#include "ubl/standard/include/note/invoice-reference.xml" item=this /} diff --git a/core/src/main/resources/templates/Renderer/despatchAdvice.xml b/core/src/main/resources/templates/Renderer/despatchAdvice.xml index 3d220ca4..a37cf7ef 100644 --- a/core/src/main/resources/templates/Renderer/despatchAdvice.xml +++ b/core/src/main/resources/templates/Renderer/despatchAdvice.xml @@ -9,7 +9,7 @@ {#include ubl/standard/include/general-data.xml item=this /} {tipoComprobante} {#if observaciones} - + {/if} {#if documentoBaja} @@ -31,7 +31,7 @@ {remitente.ruc} - + @@ -41,7 +41,7 @@ {destinatario.numeroDocumentoIdentidad} - + @@ -50,7 +50,7 @@ {proveedor.ruc} - + @@ -77,7 +77,7 @@ {envio.transportista.numeroDocumentoIdentidad} - + @@ -123,7 +123,7 @@ {it_index.add(1)} - + {it.codigo} diff --git a/core/src/main/resources/templates/Renderer/invoice.xml b/core/src/main/resources/templates/Renderer/invoice.xml index fa3ac8d4..2e037f0d 100644 --- a/core/src/main/resources/templates/Renderer/invoice.xml +++ b/core/src/main/resources/templates/Renderer/invoice.xml @@ -10,11 +10,11 @@ {tipoComprobante} {#if leyendas} {#for key in leyendas.keySet} - + {/for} {/if} {#if observaciones} - + {/if} {moneda} {#if ordenDeCompra} diff --git a/core/src/main/resources/templates/Renderer/perception.xml b/core/src/main/resources/templates/Renderer/perception.xml index d923ef08..653c7606 100644 --- a/core/src/main/resources/templates/Renderer/perception.xml +++ b/core/src/main/resources/templates/Renderer/perception.xml @@ -24,7 +24,7 @@ {tipoRegimen} {tipoRegimenPorcentaje} {#if observacion} - + {/if} {importeTotalPercibido} {importeTotalCobrado} diff --git a/core/src/main/resources/templates/Renderer/retention.xml b/core/src/main/resources/templates/Renderer/retention.xml index 1a44f28e..b78f7497 100644 --- a/core/src/main/resources/templates/Renderer/retention.xml +++ b/core/src/main/resources/templates/Renderer/retention.xml @@ -24,7 +24,7 @@ {tipoRegimen} {tipoRegimenPorcentaje} {#if observacion} - + {/if} {importeTotalRetenido} {importeTotalPagado} diff --git a/core/src/main/resources/templates/ubl/common/signature.xml b/core/src/main/resources/templates/ubl/common/signature.xml index 96109f95..18dc6461 100644 --- a/core/src/main/resources/templates/ubl/common/signature.xml +++ b/core/src/main/resources/templates/ubl/common/signature.xml @@ -5,7 +5,7 @@ {firmante.ruc} - + diff --git a/core/src/main/resources/templates/ubl/standard/include/address.xml b/core/src/main/resources/templates/ubl/standard/include/address.xml index d9866108..27368e0f 100644 --- a/core/src/main/resources/templates/ubl/standard/include/address.xml +++ b/core/src/main/resources/templates/ubl/standard/include/address.xml @@ -18,7 +18,7 @@ {/if} {#if direccion.direccion} - + {/if} {#if direccion.codigoPais} diff --git a/core/src/main/resources/templates/ubl/standard/include/customer.xml b/core/src/main/resources/templates/ubl/standard/include/customer.xml index ae7bb59c..a17b9b9b 100644 --- a/core/src/main/resources/templates/ubl/standard/include/customer.xml +++ b/core/src/main/resources/templates/ubl/standard/include/customer.xml @@ -4,7 +4,7 @@ {cliente.numeroDocumentoIdentidad} - + {#if cliente.direccion} {#include ubl/standard/include/address.xml direccion=cliente.direccion /} diff --git a/core/src/main/resources/templates/ubl/standard/include/document-line.xml b/core/src/main/resources/templates/ubl/standard/include/document-line.xml index 762dafc4..90c9db0d 100644 --- a/core/src/main/resources/templates/ubl/standard/include/document-line.xml +++ b/core/src/main/resources/templates/ubl/standard/include/document-line.xml @@ -16,7 +16,7 @@ {item.iscBaseImponible.scale(2)} {item.isc.scale(2)} - {item.tasaIsc.multiply(100)} + {item.tasaIsc.multiplyByInt(100).scale(2)} {item.iscTipo} 2000 @@ -56,7 +56,7 @@ {/if} - + {item.precio.scale(2)} diff --git a/core/src/main/resources/templates/ubl/standard/include/note/invoice-reference.xml b/core/src/main/resources/templates/ubl/standard/include/note/invoice-reference.xml index 26d35a10..de08fff8 100644 --- a/core/src/main/resources/templates/ubl/standard/include/note/invoice-reference.xml +++ b/core/src/main/resources/templates/ubl/standard/include/note/invoice-reference.xml @@ -1,7 +1,7 @@ {item.comprobanteAfectadoSerieNumero} {item.comprobanteAfectadoTipo} - + {#if item.ordenDeCompra} diff --git a/core/src/main/resources/templates/ubl/standard/include/supplier.xml b/core/src/main/resources/templates/ubl/standard/include/supplier.xml index da6265ac..44337fbf 100644 --- a/core/src/main/resources/templates/ubl/standard/include/supplier.xml +++ b/core/src/main/resources/templates/ubl/standard/include/supplier.xml @@ -9,7 +9,7 @@ {/if} - + {#if proveedor.direccion} {#include ubl/standard/include/address.xml direccion=proveedor.direccion /} diff --git a/core/src/main/resources/templates/ubl/sunat/include/agent-party.xml b/core/src/main/resources/templates/ubl/sunat/include/agent-party.xml index 1c801657..4d887f11 100644 --- a/core/src/main/resources/templates/ubl/sunat/include/agent-party.xml +++ b/core/src/main/resources/templates/ubl/sunat/include/agent-party.xml @@ -4,10 +4,10 @@ {#if proveedor.nombreComercial} - + {/if} - + diff --git a/core/src/main/resources/templates/ubl/sunat/include/receiver-party.xml b/core/src/main/resources/templates/ubl/sunat/include/receiver-party.xml index 442200a5..0521d8bd 100644 --- a/core/src/main/resources/templates/ubl/sunat/include/receiver-party.xml +++ b/core/src/main/resources/templates/ubl/sunat/include/receiver-party.xml @@ -3,6 +3,6 @@ {cliente.numeroDocumentoIdentidad} - + diff --git a/core/src/main/resources/templates/ubl/sunat/include/supplier.xml b/core/src/main/resources/templates/ubl/sunat/include/supplier.xml index 7f433137..6d72d7f7 100644 --- a/core/src/main/resources/templates/ubl/sunat/include/supplier.xml +++ b/core/src/main/resources/templates/ubl/sunat/include/supplier.xml @@ -3,7 +3,7 @@ 6 - + From af18f5c2f00f09dce23b01dedfc4574149ee9a0a Mon Sep 17 00:00:00 2001 From: carlosthe19916 <2582866+carlosthe19916@users.noreply.github.com> Date: Sun, 16 Apr 2023 17:17:38 +0200 Subject: [PATCH 2/3] Fix tests --- .../openubl/xbuilder/renderer/EngineProducer.java | 10 ++++++++++ .../resources/templates/Renderer/despatchAdvice.xml | 2 ++ .../templates/ubl/standard/include/document-line.xml | 2 +- .../despatchadvice/DespatchAdviceTest/minData.xml | 1 - 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/io/github/project/openubl/xbuilder/renderer/EngineProducer.java b/core/src/main/java/io/github/project/openubl/xbuilder/renderer/EngineProducer.java index bf21994c..c0241c1d 100644 --- a/core/src/main/java/io/github/project/openubl/xbuilder/renderer/EngineProducer.java +++ b/core/src/main/java/io/github/project/openubl/xbuilder/renderer/EngineProducer.java @@ -20,6 +20,7 @@ import io.github.project.openubl.xbuilder.content.catalogs.Catalog7; import io.quarkus.qute.Engine; import io.quarkus.qute.HtmlEscaper; +import io.quarkus.qute.RawString; import io.quarkus.qute.ReflectionValueResolver; import io.quarkus.qute.TemplateLocator.TemplateLocation; import io.quarkus.qute.ValueResolver; @@ -54,6 +55,15 @@ public class EngineProducer { .removeStandaloneLines(true) .addResultMapper(new HtmlEscaper(List.of("text/html", "text/xml", "application/xml", "application/xhtml+xml"))) .addValueResolver(new ReflectionValueResolver()) + .addValueResolver(ValueResolver.builder() + .applyToBaseClass(String.class) + .applyToName("raw") + .resolveSync(ctx -> { + String value = ((String) ctx.getBase()); + return new RawString(value); + }) + .build() + ) .addValueResolver(ValueResolver.builder() .applyToBaseClass(LocalDate.class) .applyToName("format") diff --git a/core/src/main/resources/templates/Renderer/despatchAdvice.xml b/core/src/main/resources/templates/Renderer/despatchAdvice.xml index a37cf7ef..476a8283 100644 --- a/core/src/main/resources/templates/Renderer/despatchAdvice.xml +++ b/core/src/main/resources/templates/Renderer/despatchAdvice.xml @@ -123,7 +123,9 @@ {it_index.add(1)} + {#if it.descripcion} + {/if} {it.codigo} diff --git a/core/src/main/resources/templates/ubl/standard/include/document-line.xml b/core/src/main/resources/templates/ubl/standard/include/document-line.xml index 90c9db0d..927a4301 100644 --- a/core/src/main/resources/templates/ubl/standard/include/document-line.xml +++ b/core/src/main/resources/templates/ubl/standard/include/document-line.xml @@ -16,7 +16,7 @@ {item.iscBaseImponible.scale(2)} {item.isc.scale(2)} - {item.tasaIsc.multiplyByInt(100).scale(2)} + {item.tasaIsc.multiply(100).scale(2)} {item.iscTipo} 2000 diff --git a/core/src/test/resources/e2e/renderer/despatchadvice/DespatchAdviceTest/minData.xml b/core/src/test/resources/e2e/renderer/despatchadvice/DespatchAdviceTest/minData.xml index 5494d7fd..30aab7f8 100644 --- a/core/src/test/resources/e2e/renderer/despatchadvice/DespatchAdviceTest/minData.xml +++ b/core/src/test/resources/e2e/renderer/despatchadvice/DespatchAdviceTest/minData.xml @@ -83,7 +83,6 @@ 1 - 123456 From af17086239376eb0535bb1380db5e295ef9d6833 Mon Sep 17 00:00:00 2001 From: carlosthe19916 <2582866+carlosthe19916@users.noreply.github.com> Date: Sun, 16 Apr 2023 17:22:08 +0200 Subject: [PATCH 3/3] Fix tests --- .../openubl/quarkus/xbuilder/it/QuarkusXbuilderResourceTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/quarkus-extension/integration-tests/src/test/java/io/github/project/openubl/quarkus/xbuilder/it/QuarkusXbuilderResourceTest.java b/quarkus-extension/integration-tests/src/test/java/io/github/project/openubl/quarkus/xbuilder/it/QuarkusXbuilderResourceTest.java index 071226a4..45d9b4f1 100644 --- a/quarkus-extension/integration-tests/src/test/java/io/github/project/openubl/quarkus/xbuilder/it/QuarkusXbuilderResourceTest.java +++ b/quarkus-extension/integration-tests/src/test/java/io/github/project/openubl/quarkus/xbuilder/it/QuarkusXbuilderResourceTest.java @@ -1281,7 +1281,6 @@ public void testDespatchAdvice() { " 1\n" + " \n" + " \n" + - " \n" + " \n" + " 123456\n" + " \n" +