Skip to content

Commit 0087fd6

Browse files
fix: xml generation set CDATA string as raw content (#222)
1 parent 710d1f5 commit 0087fd6

File tree

18 files changed

+35
-25
lines changed

18 files changed

+35
-25
lines changed

core/src/main/java/io/github/project/openubl/xbuilder/renderer/EngineProducer.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.github.project.openubl.xbuilder.content.catalogs.Catalog7;
2121
import io.quarkus.qute.Engine;
2222
import io.quarkus.qute.HtmlEscaper;
23+
import io.quarkus.qute.RawString;
2324
import io.quarkus.qute.ReflectionValueResolver;
2425
import io.quarkus.qute.TemplateLocator.TemplateLocation;
2526
import io.quarkus.qute.ValueResolver;
@@ -54,6 +55,15 @@ public class EngineProducer {
5455
.removeStandaloneLines(true)
5556
.addResultMapper(new HtmlEscaper(List.of("text/html", "text/xml", "application/xml", "application/xhtml+xml")))
5657
.addValueResolver(new ReflectionValueResolver())
58+
.addValueResolver(ValueResolver.builder()
59+
.applyToBaseClass(String.class)
60+
.applyToName("raw")
61+
.resolveSync(ctx -> {
62+
String value = ((String) ctx.getBase());
63+
return new RawString(value);
64+
})
65+
.build()
66+
)
5767
.addValueResolver(ValueResolver.builder()
5868
.applyToBaseClass(LocalDate.class)
5969
.applyToName("format")

core/src/main/resources/templates/Renderer/creditNote.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{#include ubl/standard/include/ubl-extensions.xml /}
66
{#include ubl/standard/include/general-data.xml item=this /}
77
{#for key in leyendas.keySet}
8-
<cbc:Note languageLocaleID="{key}"><![CDATA[{leyendas.get(key)}]]></cbc:Note>
8+
<cbc:Note languageLocaleID="{key}"><![CDATA[{leyendas.get(key).raw}]]></cbc:Note>
99
{/for}
1010
<cbc:DocumentCurrencyCode listID="ISO 4217 Alpha" listAgencyName="United Nations Economic Commission for Europe" listName="Currency">{moneda}</cbc:DocumentCurrencyCode>
1111
{#include "ubl/standard/include/note/invoice-reference.xml" item=this /}

core/src/main/resources/templates/Renderer/debitNote.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{#include ubl/standard/include/ubl-extensions.xml /}
66
{#include ubl/standard/include/general-data.xml item=this /}
77
{#for key in leyendas.keySet}
8-
<cbc:Note languageLocaleID="{key}"><![CDATA[{leyendas.get(key)}]]></cbc:Note>
8+
<cbc:Note languageLocaleID="{key}"><![CDATA[{leyendas.get(key).raw}]]></cbc:Note>
99
{/for}
1010
<cbc:DocumentCurrencyCode listID="ISO 4217 Alpha" listAgencyName="United Nations Economic Commission for Europe" listName="Currency">{moneda}</cbc:DocumentCurrencyCode>
1111
{#include "ubl/standard/include/note/invoice-reference.xml" item=this /}

core/src/main/resources/templates/Renderer/despatchAdvice.xml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{#include ubl/standard/include/general-data.xml item=this /}
1010
<cbc:DespatchAdviceTypeCode>{tipoComprobante}</cbc:DespatchAdviceTypeCode>
1111
{#if observaciones}
12-
<cbc:Note><![CDATA[{observaciones}]]></cbc:Note>
12+
<cbc:Note><![CDATA[{observaciones.raw}]]></cbc:Note>
1313
{/if}
1414
{#if documentoBaja}
1515
<cac:OrderReference>
@@ -31,7 +31,7 @@
3131
<cbc:ID schemeID="6" schemeName="Documento de Identidad" schemeAgencyName="PE:SUNAT" schemeURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo06">{remitente.ruc}</cbc:ID>
3232
</cac:PartyIdentification>
3333
<cac:PartyLegalEntity>
34-
<cbc:RegistrationName><![CDATA[{remitente.razonSocial}]]></cbc:RegistrationName>
34+
<cbc:RegistrationName><![CDATA[{remitente.razonSocial.raw}]]></cbc:RegistrationName>
3535
</cac:PartyLegalEntity>
3636
</cac:Party>
3737
</cac:DespatchSupplierParty>
@@ -41,7 +41,7 @@
4141
<cbc:ID schemeID="{destinatario.tipoDocumentoIdentidad}" schemeName="Documento de Identidad" schemeAgencyName="PE:SUNAT" schemeURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo06">{destinatario.numeroDocumentoIdentidad}</cbc:ID>
4242
</cac:PartyIdentification>
4343
<cac:PartyLegalEntity>
44-
<cbc:RegistrationName><![CDATA[{destinatario.nombre}]]></cbc:RegistrationName>
44+
<cbc:RegistrationName><![CDATA[{destinatario.nombre.raw}]]></cbc:RegistrationName>
4545
</cac:PartyLegalEntity>
4646
</cac:Party>
4747
</cac:DeliveryCustomerParty>
@@ -50,7 +50,7 @@
5050
<cbc:CustomerAssignedAccountID schemeID="6">{proveedor.ruc}</cbc:CustomerAssignedAccountID>
5151
<cac:Party>
5252
<cac:PartyLegalEntity>
53-
<cbc:RegistrationName><![CDATA[{proveedor.razonSocial}]]></cbc:RegistrationName>
53+
<cbc:RegistrationName><![CDATA[{proveedor.razonSocial.raw}]]></cbc:RegistrationName>
5454
</cac:PartyLegalEntity>
5555
</cac:Party>
5656
</cac:SellerSupplierParty>
@@ -77,7 +77,7 @@
7777
<cbc:ID schemeID="{envio.transportista.tipoDocumentoIdentidad}">{envio.transportista.numeroDocumentoIdentidad}</cbc:ID>
7878
</cac:PartyIdentification>
7979
<cac:PartyName>
80-
<cbc:Name><![CDATA[{envio.transportista.nombre}]]></cbc:Name>
80+
<cbc:Name><![CDATA[{envio.transportista.nombre.raw}]]></cbc:Name>
8181
</cac:PartyName>
8282
</cac:CarrierParty>
8383
<cac:TransportMeans>
@@ -123,7 +123,9 @@
123123
<cbc:LineID>{it_index.add(1)}</cbc:LineID>
124124
</cac:OrderLineReference>
125125
<cac:Item>
126-
<cbc:Name><![CDATA[{it.descripcion}]]></cbc:Name>
126+
{#if it.descripcion}
127+
<cbc:Name><![CDATA[{it.descripcion.raw}]]></cbc:Name>
128+
{/if}
127129
<cac:SellersItemIdentification>
128130
<cbc:ID>{it.codigo}</cbc:ID>
129131
</cac:SellersItemIdentification>

core/src/main/resources/templates/Renderer/invoice.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
<cbc:InvoiceTypeCode listID="{tipoOperacion}" listAgencyName="PE:SUNAT" listName="Tipo de Documento" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo01">{tipoComprobante}</cbc:InvoiceTypeCode>
1111
{#if leyendas}
1212
{#for key in leyendas.keySet}
13-
<cbc:Note languageLocaleID="{key}"><![CDATA[{leyendas.get(key)}]]></cbc:Note>
13+
<cbc:Note languageLocaleID="{key}"><![CDATA[{leyendas.get(key).raw}]]></cbc:Note>
1414
{/for}
1515
{/if}
1616
{#if observaciones}
17-
<cbc:Note><![CDATA[{observaciones}]]></cbc:Note>
17+
<cbc:Note><![CDATA[{observaciones.raw}]]></cbc:Note>
1818
{/if}
1919
<cbc:DocumentCurrencyCode listID="ISO 4217 Alpha" listAgencyName="United Nations Economic Commission for Europe" listName="Currency">{moneda}</cbc:DocumentCurrencyCode>
2020
{#if ordenDeCompra}

core/src/main/resources/templates/Renderer/perception.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<sac:SUNATPerceptionSystemCode>{tipoRegimen}</sac:SUNATPerceptionSystemCode>
2525
<sac:SUNATPerceptionPercent>{tipoRegimenPorcentaje}</sac:SUNATPerceptionPercent>
2626
{#if observacion}
27-
<cbc:Note><![CDATA[{observacion}]]></cbc:Note>
27+
<cbc:Note><![CDATA[{observacion.raw}]]></cbc:Note>
2828
{/if}
2929
<cbc:TotalInvoiceAmount currencyID="{moneda}">{importeTotalPercibido}</cbc:TotalInvoiceAmount>
3030
<sac:SUNATTotalCashed currencyID="{moneda}">{importeTotalCobrado}</sac:SUNATTotalCashed>

core/src/main/resources/templates/Renderer/retention.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<sac:SUNATRetentionSystemCode>{tipoRegimen}</sac:SUNATRetentionSystemCode>
2525
<sac:SUNATRetentionPercent>{tipoRegimenPorcentaje}</sac:SUNATRetentionPercent>
2626
{#if observacion}
27-
<cbc:Note><![CDATA[{observacion}]]></cbc:Note>
27+
<cbc:Note><![CDATA[{observacion.raw}]]></cbc:Note>
2828
{/if}
2929
<cbc:TotalInvoiceAmount currencyID="{moneda}">{importeTotalRetenido}</cbc:TotalInvoiceAmount>
3030
<sac:SUNATTotalPaid currencyID="{moneda}">{importeTotalPagado}</sac:SUNATTotalPaid>

core/src/main/resources/templates/ubl/common/signature.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<cbc:ID>{firmante.ruc}</cbc:ID>
66
</cac:PartyIdentification>
77
<cac:PartyName>
8-
<cbc:Name><![CDATA[{firmante.razonSocial}]]></cbc:Name>
8+
<cbc:Name><![CDATA[{firmante.razonSocial.raw}]]></cbc:Name>
99
</cac:PartyName>
1010
</cac:SignatoryParty>
1111
<cac:DigitalSignatureAttachment>

core/src/main/resources/templates/ubl/standard/include/address.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
{/if}
1919
{#if direccion.direccion}
2020
<cac:AddressLine>
21-
<cbc:Line><![CDATA[{direccion.direccion}]]></cbc:Line>
21+
<cbc:Line><![CDATA[{direccion.direccion.raw}]]></cbc:Line>
2222
</cac:AddressLine>
2323
{/if}
2424
{#if direccion.codigoPais}

core/src/main/resources/templates/ubl/standard/include/customer.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<cbc:ID schemeID="{cliente.tipoDocumentoIdentidad}" schemeAgencyName="PE:SUNAT" schemeName="Documento de Identidad" schemeURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo06">{cliente.numeroDocumentoIdentidad}</cbc:ID>
55
</cac:PartyIdentification>
66
<cac:PartyLegalEntity>
7-
<cbc:RegistrationName><![CDATA[{cliente.nombre}]]></cbc:RegistrationName>
7+
<cbc:RegistrationName><![CDATA[{cliente.nombre.raw}]]></cbc:RegistrationName>
88
{#if cliente.direccion}
99
<cac:RegistrationAddress>
1010
{#include ubl/standard/include/address.xml direccion=cliente.direccion /}

0 commit comments

Comments
 (0)