Skip to content

Commit 33e9a4c

Browse files
Add format number to summary-document.ftl, retention.ftl, and perception.ftl (#26)
1 parent 576c4b1 commit 33e9a4c

File tree

7 files changed

+177
-0
lines changed

7 files changed

+177
-0
lines changed

src/main/resources/io/github/project/openubl/xmlbuilderlib/templates/standard/despatch-advice.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<@compress single_line=true>
2+
<#setting number_format="computer">
13
<?xml version="1.0" encoding="ISO-8859-1"?>
24
<DespatchAdvice xmlns="urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2"
35
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
@@ -130,3 +132,4 @@
130132
</cac:DespatchLine>
131133
</#list>
132134
</DespatchAdvice>
135+
</@compress>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<@compress single_line=true>
2+
<#setting number_format="computer">
23
<?xml version="1.0" encoding="ISO-8859-1"?>
34
<Perception xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:Perception-1"
45
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<@compress single_line=true>
2+
<#setting number_format="computer">
23
<?xml version="1.0" encoding="ISO-8859-1"?>
34
<Retention xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:Retention-1"
45
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<@compress single_line=true>
2+
<#setting number_format="computer">
23
<?xml version="1.0" encoding="ISO-8859-1"?>
34
<SummaryDocuments xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:SummaryDocuments-1"
45
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<@compress single_line=true>
2+
<#setting number_format="computer">
23
<?xml version="1.0" encoding="ISO-8859-1"?>
34
<VoidedDocuments xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:VoidedDocuments-1"
45
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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.summarydocument;
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.Catalog1;
23+
import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog19;
24+
import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog6;
25+
import io.github.project.openubl.xmlbuilderlib.models.input.common.ClienteInputModel;
26+
import io.github.project.openubl.xmlbuilderlib.models.input.common.ProveedorInputModel;
27+
import io.github.project.openubl.xmlbuilderlib.models.input.sunat.*;
28+
import io.github.project.openubl.xmlbuilderlib.models.output.sunat.SummaryDocumentOutputModel;
29+
import org.junit.jupiter.api.Test;
30+
31+
import java.math.BigDecimal;
32+
import java.util.Calendar;
33+
import java.util.Collections;
34+
35+
public class SummaryDocumentCasesTest extends AbstractUBLTest {
36+
37+
public SummaryDocumentCasesTest() throws Exception {
38+
}
39+
40+
@Test
41+
void testSummaryDocument_withBigNumbers_shouldFormatNumbers() throws Exception {
42+
// Given
43+
Calendar calendar = Calendar.getInstance();
44+
calendar.set(2019, Calendar.DECEMBER, 1, 20, 30, 59);
45+
calendar.setTimeZone(timeZone);
46+
47+
SummaryDocumentInputModel input = SummaryDocumentInputModel.Builder.aSummaryDocumentInputModel()
48+
.withNumero(1)
49+
.withFechaEmisionDeComprobantesAsociados(calendar.getTimeInMillis())
50+
.withProveedor(ProveedorInputModel.Builder.aProveedorInputModel()
51+
.withRuc("12345678912")
52+
.withRazonSocial("Openubl S.A.C.")
53+
.build()
54+
)
55+
.withDetalle(Collections.singletonList(
56+
SummaryDocumentLineInputModel.Builder.aSummaryDocumentLineInputModel()
57+
.withTipoOperacion(Catalog19.ADICIONAR.toString())
58+
.withComprobante(SummaryDocumentComprobanteInputModel.Builder.aSummaryDocumentComprobanteInputModel()
59+
.withTipo(Catalog1.BOLETA.toString())
60+
.withSerieNumero("B001-1")
61+
.withCliente(ClienteInputModel.Builder.aClienteInputModel()
62+
.withNombre("Maria Pérez")
63+
.withNumeroDocumentoIdentidad("12345678")
64+
.withTipoDocumentoIdentidad(Catalog6.DNI.toString())
65+
.build()
66+
)
67+
.withImpuestos(SummaryDocumentImpuestosInputModel.Builder.aSummaryDocumentImpuestosInputModel()
68+
.withIgv(new BigDecimal("180.02"))
69+
.build()
70+
)
71+
.withValorVenta(SummaryDocumentComprobanteValorVentaInputModel.Builder.aSummaryDocumentComprobanteValorVentaInputModel()
72+
.withImporteTotal(new BigDecimal("1180.12"))
73+
.withGravado(new BigDecimal("1000.1"))
74+
.build()
75+
)
76+
.build()
77+
)
78+
.build()
79+
))
80+
.build();
81+
82+
// When
83+
DocumentWrapper<SummaryDocumentOutputModel> result = DocumentManager.createXML(input, config, systemClock);
84+
SummaryDocumentOutputModel output = result.getOutput();
85+
String xml = result.getXml();
86+
87+
// Then
88+
assertOutputHasNoConstraintViolations(validator, output);
89+
assertSnapshot(xml, "xml/summarydocument/summaryDocument_formatNumbers.xml");
90+
assertSendSunat(xml);
91+
}
92+
93+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="ISO-8859-1"?>
2+
<SummaryDocuments xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:SummaryDocuments-1"
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" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
6+
xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
7+
xmlns:ns11="urn:sunat:names:specification:ubl:peru:schema:xsd:Perception-1"
8+
xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2"
9+
xmlns:sac="urn:sunat:names:specification:ubl:peru:schema:xsd:SunatAggregateComponents-1"
10+
xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"
11+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
12+
<ext:UBLExtensions>
13+
<ext:UBLExtension>
14+
<ext:ExtensionContent/>
15+
</ext:UBLExtension>
16+
</ext:UBLExtensions>
17+
<cbc:UBLVersionID>2.0</cbc:UBLVersionID>
18+
<cbc:CustomizationID>1.1</cbc:CustomizationID>
19+
<cbc:ID>RC-20191224-1</cbc:ID>
20+
<cbc:ReferenceDate>2019-12-01</cbc:ReferenceDate>
21+
<cbc:IssueDate>2019-12-24</cbc:IssueDate>
22+
<cac:Signature>
23+
<cbc:ID>12345678912</cbc:ID>
24+
<cac:SignatoryParty>
25+
<cac:PartyIdentification>
26+
<cbc:ID>12345678912</cbc:ID>
27+
</cac:PartyIdentification>
28+
<cac:PartyName>
29+
<cbc:Name><![CDATA[Openubl S.A.C.]]></cbc:Name>
30+
</cac:PartyName>
31+
</cac:SignatoryParty>
32+
<cac:DigitalSignatureAttachment>
33+
<cac:ExternalReference>
34+
<cbc:URI>#PROJECT-OPENUBL-SIGN</cbc:URI>
35+
</cac:ExternalReference>
36+
</cac:DigitalSignatureAttachment>
37+
</cac:Signature>
38+
<cac:AccountingSupplierParty>
39+
<cbc:CustomerAssignedAccountID>12345678912</cbc:CustomerAssignedAccountID>
40+
<cbc:AdditionalAccountID>6</cbc:AdditionalAccountID>
41+
<cac:Party>
42+
<cac:PartyLegalEntity>
43+
<cbc:RegistrationName><![CDATA[Openubl S.A.C.]]></cbc:RegistrationName>
44+
</cac:PartyLegalEntity>
45+
</cac:Party>
46+
</cac:AccountingSupplierParty>
47+
<sac:SummaryDocumentsLine>
48+
<cbc:LineID>1</cbc:LineID>
49+
<cbc:DocumentTypeCode>03</cbc:DocumentTypeCode>
50+
<cbc:ID>B001-1</cbc:ID>
51+
<cac:AccountingCustomerParty>
52+
<cbc:CustomerAssignedAccountID>12345678</cbc:CustomerAssignedAccountID>
53+
<cbc:AdditionalAccountID>1</cbc:AdditionalAccountID>
54+
</cac:AccountingCustomerParty>
55+
<cac:Status>
56+
<cbc:ConditionCode>1</cbc:ConditionCode>
57+
</cac:Status>
58+
<sac:TotalAmount currencyID="PEN">1180.12</sac:TotalAmount>
59+
<sac:BillingPayment>
60+
<cbc:PaidAmount currencyID="PEN">1000.1</cbc:PaidAmount>
61+
<cbc:InstructionID>01</cbc:InstructionID>
62+
</sac:BillingPayment>
63+
<cac:TaxTotal>
64+
<cbc:TaxAmount currencyID="PEN">180.02</cbc:TaxAmount>
65+
<cac:TaxSubtotal>
66+
<cbc:TaxAmount currencyID="PEN">180.02</cbc:TaxAmount>
67+
<cac:TaxCategory>
68+
<cac:TaxScheme>
69+
<cbc:ID>1000</cbc:ID>
70+
<cbc:Name>IGV</cbc:Name>
71+
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
72+
</cac:TaxScheme>
73+
</cac:TaxCategory>
74+
</cac:TaxSubtotal>
75+
</cac:TaxTotal>
76+
</sac:SummaryDocumentsLine>
77+
</SummaryDocuments>

0 commit comments

Comments
 (0)