Skip to content

Commit 2788e20

Browse files
minify xmls (#4)
1 parent 733cfdf commit 2788e20

File tree

9 files changed

+279
-0
lines changed

9 files changed

+279
-0
lines changed

src/main/resources/io/github/project/openubl/xmlbuilderlib/templates/standard/credit-note.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<@compress single_line=true>
12
<#setting number_format="computer">
23
<?xml version="1.0" encoding="ISO-8859-1"?>
34
<CreditNote xmlns="urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2"
@@ -25,3 +26,4 @@
2526
</cac:CreditNoteLine>
2627
</#list>
2728
</CreditNote>
29+
</@compress>

src/main/resources/io/github/project/openubl/xmlbuilderlib/templates/standard/debit-note.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<@compress single_line=true>
12
<#setting number_format="computer">
23
<?xml version="1.0" encoding="ISO-8859-1"?>
34
<DebitNote xmlns="urn:oasis:names:specification:ubl:schema:xsd:DebitNote-2"
@@ -25,3 +26,4 @@
2526
</cac:DebitNoteLine>
2627
</#list>
2728
</DebitNote>
29+
</@compress>

src/main/resources/io/github/project/openubl/xmlbuilderlib/templates/standard/invoice.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<@compress single_line=true>
12
<#setting number_format="computer">
23
<?xml version="1.0" encoding="ISO-8859-1"?>
34
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
@@ -107,3 +108,4 @@
107108
</cac:InvoiceLine>
108109
</#list>
109110
</Invoice>
111+
</@compress>

src/main/resources/io/github/project/openubl/xmlbuilderlib/templates/sunat/perception.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<@compress single_line=true>
12
<?xml version="1.0" encoding="ISO-8859-1"?>
23
<Perception xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:Perception-1"
34
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
@@ -46,3 +47,4 @@
4647
</sac:SUNATPerceptionDocumentReference>
4748
</#list>
4849
</Perception>
50+
</@compress>

src/main/resources/io/github/project/openubl/xmlbuilderlib/templates/sunat/retention.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<@compress single_line=true>
12
<?xml version="1.0" encoding="ISO-8859-1"?>
23
<Retention xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:Retention-1"
34
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
@@ -46,3 +47,4 @@
4647
</sac:SUNATRetentionDocumentReference>
4748
</#list>
4849
</Retention>
50+
</@compress>

src/main/resources/io/github/project/openubl/xmlbuilderlib/templates/sunat/summary-document.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<@compress single_line=true>
12
<?xml version="1.0" encoding="ISO-8859-1"?>
23
<SummaryDocuments xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:SummaryDocuments-1"
34
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
@@ -105,3 +106,4 @@
105106
</sac:SummaryDocumentsLine>
106107
</#list>
107108
</SummaryDocuments>
109+
</@compress>

src/main/resources/io/github/project/openubl/xmlbuilderlib/templates/sunat/voided-document.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<@compress single_line=true>
12
<?xml version="1.0" encoding="ISO-8859-1"?>
23
<VoidedDocuments xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:VoidedDocuments-1"
34
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
@@ -26,3 +27,4 @@
2627
<sac:VoidReasonDescription><![CDATA[${descripcionSustento}]]></sac:VoidReasonDescription>
2728
</sac:VoidedDocumentsLine>
2829
</VoidedDocuments>
30+
</@compress>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
* Copyright 2019 Project OpenUBL, Inc. and/or its affiliates
3+
* and other contributors as indicated by the @author tags.
4+
*
5+
* Licensed under the Eclipse Public License - v 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.eclipse.org/legal/epl-2.0/
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package io.github.project.openubl.xmlbuilderlib.integrationtest.ubl;
18+
19+
import io.github.project.openubl.xmlbuilderlib.facade.DocumentManager;
20+
import io.github.project.openubl.xmlbuilderlib.facade.DocumentWrapper;
21+
import io.github.project.openubl.xmlbuilderlib.integrationtest.AbstractUBLTest;
22+
import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog6;
23+
import io.github.project.openubl.xmlbuilderlib.models.input.common.ClienteInputModel;
24+
import io.github.project.openubl.xmlbuilderlib.models.input.common.ProveedorInputModel;
25+
import io.github.project.openubl.xmlbuilderlib.models.input.standard.DocumentLineInputModel;
26+
import io.github.project.openubl.xmlbuilderlib.models.input.standard.invoice.InvoiceInputModel;
27+
import io.github.project.openubl.xmlbuilderlib.models.output.standard.invoice.InvoiceOutputModel;
28+
import org.junit.jupiter.api.Test;
29+
30+
import java.math.BigDecimal;
31+
import java.util.Arrays;
32+
33+
public class SpecialCharactersTest extends AbstractUBLTest {
34+
35+
public SpecialCharactersTest() throws Exception {
36+
}
37+
38+
@Test
39+
void testVoidedDocument_Factura_MinData() throws Exception {
40+
// Given
41+
InvoiceInputModel input = InvoiceInputModel.Builder.anInvoiceInputModel()
42+
.withSerie("F001")
43+
.withNumero(1)
44+
.withProveedor(ProveedorInputModel.Builder.aProveedorInputModel()
45+
.withRuc("12345678912")
46+
.withRazonSocial("Project OpenUBL S.A.C.")
47+
.build()
48+
)
49+
.withCliente(ClienteInputModel.Builder.aClienteInputModel()
50+
.withNombre("Ñoño Álvarez")
51+
.withNumeroDocumentoIdentidad("12121212121")
52+
.withTipoDocumentoIdentidad(Catalog6.RUC.toString())
53+
.build()
54+
)
55+
.withDetalle(Arrays.asList(
56+
DocumentLineInputModel.Builder.aDocumentLineInputModel()
57+
.withDescripcion("Item1")
58+
.withCantidad(new BigDecimal(10))
59+
.withPrecioUnitario(new BigDecimal(100))
60+
.build(),
61+
DocumentLineInputModel.Builder.aDocumentLineInputModel()
62+
.withDescripcion("Item2")
63+
.withCantidad(new BigDecimal(10))
64+
.withPrecioUnitario(new BigDecimal(100))
65+
.build())
66+
)
67+
.build();
68+
69+
// When
70+
DocumentWrapper<InvoiceOutputModel> result = DocumentManager.createXML(input, config, systemClock);
71+
InvoiceOutputModel output = result.getOutput();
72+
String xml = result.getXml();
73+
74+
// Then
75+
assertOutputHasNoConstraintViolations(validator, output);
76+
assertSnapshot(xml, "xml/invoice_specialCharacters.xml");
77+
assertSendSunat(xml);
78+
}
79+
}
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
<?xml version="1.0" encoding="ISO-8859-1"?>
2+
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
3+
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
4+
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
5+
xmlns:ccts="urn:un:unece:uncefact:documentation:2"
6+
xmlns:cec="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
7+
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
8+
xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
9+
xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2"
10+
xmlns:sac="urn:sunat:names:specification:ubl:peru:schema:xsd:SunatAggregateComponents-1"
11+
xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"
12+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
13+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
14+
>
15+
<ext:UBLExtensions>
16+
<ext:UBLExtension>
17+
<ext:ExtensionContent/>
18+
</ext:UBLExtension>
19+
</ext:UBLExtensions>
20+
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
21+
<cbc:CustomizationID>2.0</cbc:CustomizationID>
22+
<cbc:ID>F001-1</cbc:ID>
23+
<cbc:IssueDate>2019-12-24</cbc:IssueDate>
24+
<cbc:IssueTime>20:30:59</cbc:IssueTime>
25+
<cbc:InvoiceTypeCode listAgencyName="PE:SUNAT" listID="0101" listName="SUNAT:Identificador de Tipo de Documento"
26+
listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo01">01
27+
</cbc:InvoiceTypeCode>
28+
<cbc:DocumentCurrencyCode listAgencyName="United Nations Economic Commission for Europe" listID="ISO 4217 Alpha"
29+
listName="Currency">PEN
30+
</cbc:DocumentCurrencyCode>
31+
<cac:Signature>
32+
<cbc:ID>12345678912</cbc:ID>
33+
<cac:SignatoryParty>
34+
<cac:PartyIdentification>
35+
<cbc:ID>12345678912</cbc:ID>
36+
</cac:PartyIdentification>
37+
<cac:PartyName>
38+
<cbc:Name>Project OpenUBL S.A.C.</cbc:Name>
39+
</cac:PartyName>
40+
</cac:SignatoryParty>
41+
<cac:DigitalSignatureAttachment>
42+
<cac:ExternalReference>
43+
<cbc:URI>#PROJECT-OPENUBL-SIGN</cbc:URI>
44+
</cac:ExternalReference>
45+
</cac:DigitalSignatureAttachment>
46+
</cac:Signature>
47+
<cac:AccountingSupplierParty>
48+
<cac:Party>
49+
<cac:PartyIdentification>
50+
<cbc:ID schemeAgencyName="PE:SUNAT" schemeID="6"
51+
schemeName="SUNAT:Identificador de Documento de Identidad"
52+
schemeURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo06">12345678912
53+
</cbc:ID>
54+
</cac:PartyIdentification>
55+
<cac:PartyLegalEntity>
56+
<cbc:RegistrationName>Project OpenUBL S.A.C.</cbc:RegistrationName>
57+
</cac:PartyLegalEntity>
58+
</cac:Party>
59+
</cac:AccountingSupplierParty>
60+
<cac:AccountingCustomerParty>
61+
<cac:Party>
62+
<cac:PartyIdentification>
63+
<cbc:ID schemeAgencyName="PE:SUNAT" schemeID="6"
64+
schemeName="SUNAT:Identificador de Documento de Identidad"
65+
schemeURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo06">12121212121
66+
</cbc:ID>
67+
</cac:PartyIdentification>
68+
<cac:PartyLegalEntity>
69+
<cbc:RegistrationName><![CDATA[Ñoño Álvarez]]></cbc:RegistrationName>
70+
</cac:PartyLegalEntity>
71+
</cac:Party>
72+
</cac:AccountingCustomerParty>
73+
<cac:TaxTotal>
74+
<cbc:TaxAmount currencyID="PEN">360</cbc:TaxAmount>
75+
<cac:TaxSubtotal>
76+
<cbc:TaxableAmount currencyID="PEN">2000</cbc:TaxableAmount>
77+
<cbc:TaxAmount currencyID="PEN">360</cbc:TaxAmount>
78+
<cac:TaxCategory>
79+
<cbc:ID schemeAgencyName="United Nations Economic Commission for Europe" schemeID="UN/ECE 5305"
80+
schemeName="Tax Category Identifie">S
81+
</cbc:ID>
82+
<cac:TaxScheme>
83+
<cbc:ID schemeAgencyName="PE:SUNAT" schemeID="UN/ECE 5153" schemeName="Codigo de tributos">1000
84+
</cbc:ID>
85+
<cbc:Name>IGV</cbc:Name>
86+
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
87+
</cac:TaxScheme>
88+
</cac:TaxCategory>
89+
</cac:TaxSubtotal>
90+
</cac:TaxTotal>
91+
<cac:LegalMonetaryTotal>
92+
<cbc:LineExtensionAmount currencyID="PEN">2000</cbc:LineExtensionAmount>
93+
<cbc:TaxInclusiveAmount currencyID="PEN">2360</cbc:TaxInclusiveAmount>
94+
<cbc:PayableAmount currencyID="PEN">2360</cbc:PayableAmount>
95+
</cac:LegalMonetaryTotal>
96+
<cac:InvoiceLine>
97+
<cbc:ID>1</cbc:ID>
98+
<cbc:InvoicedQuantity unitCode="NIU" unitCodeListAgencyName="United Nations Economic Commission for Europe"
99+
unitCodeListID="UN/ECE rec 20">10
100+
</cbc:InvoicedQuantity>
101+
<cbc:LineExtensionAmount currencyID="PEN">1000</cbc:LineExtensionAmount>
102+
<cac:PricingReference>
103+
<cac:AlternativeConditionPrice>
104+
<cbc:PriceAmount currencyID="PEN">118</cbc:PriceAmount>
105+
<cbc:PriceTypeCode listAgencyName="PE:SUNAT" listName="SUNAT:Indicador de Tipo de Precio"
106+
listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo16">01
107+
</cbc:PriceTypeCode>
108+
</cac:AlternativeConditionPrice>
109+
</cac:PricingReference>
110+
<cac:TaxTotal>
111+
<cbc:TaxAmount currencyID="PEN">180</cbc:TaxAmount>
112+
<cac:TaxSubtotal>
113+
<cbc:TaxableAmount currencyID="PEN">1000</cbc:TaxableAmount>
114+
<cbc:TaxAmount currencyID="PEN">180</cbc:TaxAmount>
115+
<cac:TaxCategory>
116+
<cbc:ID schemeAgencyName="United Nations Economic Commission for Europe" schemeID="UN/ECE 5305"
117+
schemeName="Tax Category Identifier">S
118+
</cbc:ID>
119+
<cbc:Percent>18</cbc:Percent>
120+
<cbc:TaxExemptionReasonCode listAgencyName="PE:SUNAT"
121+
listName="SUNAT:Codigo de Tipo de Afectacion del IGV"
122+
listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo07">10
123+
</cbc:TaxExemptionReasonCode>
124+
<cac:TaxScheme>
125+
<cbc:ID schemeAgencyName="PE:SUNAT" schemeID="UN/ECE 5153" schemeName="Codigo de tributos">
126+
1000
127+
</cbc:ID>
128+
<cbc:Name>IGV</cbc:Name>
129+
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
130+
</cac:TaxScheme>
131+
</cac:TaxCategory>
132+
</cac:TaxSubtotal>
133+
</cac:TaxTotal>
134+
<cac:Item>
135+
<cbc:Description>Item1</cbc:Description>
136+
</cac:Item>
137+
<cac:Price>
138+
<cbc:PriceAmount currencyID="PEN">100</cbc:PriceAmount>
139+
</cac:Price>
140+
</cac:InvoiceLine>
141+
<cac:InvoiceLine>
142+
<cbc:ID>2</cbc:ID>
143+
<cbc:InvoicedQuantity unitCode="NIU" unitCodeListAgencyName="United Nations Economic Commission for Europe"
144+
unitCodeListID="UN/ECE rec 20">10
145+
</cbc:InvoicedQuantity>
146+
<cbc:LineExtensionAmount currencyID="PEN">1000</cbc:LineExtensionAmount>
147+
<cac:PricingReference>
148+
<cac:AlternativeConditionPrice>
149+
<cbc:PriceAmount currencyID="PEN">118</cbc:PriceAmount>
150+
<cbc:PriceTypeCode listAgencyName="PE:SUNAT" listName="SUNAT:Indicador de Tipo de Precio"
151+
listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo16">01
152+
</cbc:PriceTypeCode>
153+
</cac:AlternativeConditionPrice>
154+
</cac:PricingReference>
155+
<cac:TaxTotal>
156+
<cbc:TaxAmount currencyID="PEN">180</cbc:TaxAmount>
157+
<cac:TaxSubtotal>
158+
<cbc:TaxableAmount currencyID="PEN">1000</cbc:TaxableAmount>
159+
<cbc:TaxAmount currencyID="PEN">180</cbc:TaxAmount>
160+
<cac:TaxCategory>
161+
<cbc:ID schemeAgencyName="United Nations Economic Commission for Europe" schemeID="UN/ECE 5305"
162+
schemeName="Tax Category Identifier">S
163+
</cbc:ID>
164+
<cbc:Percent>18</cbc:Percent>
165+
<cbc:TaxExemptionReasonCode listAgencyName="PE:SUNAT"
166+
listName="SUNAT:Codigo de Tipo de Afectacion del IGV"
167+
listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo07">10
168+
</cbc:TaxExemptionReasonCode>
169+
<cac:TaxScheme>
170+
<cbc:ID schemeAgencyName="PE:SUNAT" schemeID="UN/ECE 5153" schemeName="Codigo de tributos">
171+
1000
172+
</cbc:ID>
173+
<cbc:Name>IGV</cbc:Name>
174+
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
175+
</cac:TaxScheme>
176+
</cac:TaxCategory>
177+
</cac:TaxSubtotal>
178+
</cac:TaxTotal>
179+
<cac:Item>
180+
<cbc:Description>Item2</cbc:Description>
181+
</cac:Item>
182+
<cac:Price>
183+
<cbc:PriceAmount currencyID="PEN">100</cbc:PriceAmount>
184+
</cac:Price>
185+
</cac:InvoiceLine>
186+
</Invoice>

0 commit comments

Comments
 (0)