Skip to content

Wrong format when number has more than 3 digits #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<@compress single_line=true>
<#setting number_format="computer">
<?xml version="1.0" encoding="ISO-8859-1"?>
<DespatchAdvice xmlns="urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
Expand Down Expand Up @@ -130,3 +132,4 @@
</cac:DespatchLine>
</#list>
</DespatchAdvice>
</@compress>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<@compress single_line=true>
<#setting number_format="computer">
<?xml version="1.0" encoding="ISO-8859-1"?>
<Perception xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:Perception-1"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<@compress single_line=true>
<#setting number_format="computer">
<?xml version="1.0" encoding="ISO-8859-1"?>
<Retention xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:Retention-1"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<@compress single_line=true>
<#setting number_format="computer">
<?xml version="1.0" encoding="ISO-8859-1"?>
<SummaryDocuments xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:SummaryDocuments-1"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<@compress single_line=true>
<#setting number_format="computer">
<?xml version="1.0" encoding="ISO-8859-1"?>
<VoidedDocuments xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:VoidedDocuments-1"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* Copyright 2019 Project OpenUBL, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Eclipse Public License - v 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.eclipse.org/legal/epl-2.0/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.project.openubl.xmlbuilderlib.integrationtest.ubl.summarydocument;

import io.github.project.openubl.xmlbuilderlib.facade.DocumentManager;
import io.github.project.openubl.xmlbuilderlib.facade.DocumentWrapper;
import io.github.project.openubl.xmlbuilderlib.integrationtest.AbstractUBLTest;
import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog1;
import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog19;
import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog6;
import io.github.project.openubl.xmlbuilderlib.models.input.common.ClienteInputModel;
import io.github.project.openubl.xmlbuilderlib.models.input.common.ProveedorInputModel;
import io.github.project.openubl.xmlbuilderlib.models.input.sunat.*;
import io.github.project.openubl.xmlbuilderlib.models.output.sunat.SummaryDocumentOutputModel;
import org.junit.jupiter.api.Test;

import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Collections;

public class SummaryDocumentCasesTest extends AbstractUBLTest {

public SummaryDocumentCasesTest() throws Exception {
}

@Test
void testSummaryDocument_withBigNumbers_shouldFormatNumbers() throws Exception {
// Given
Calendar calendar = Calendar.getInstance();
calendar.set(2019, Calendar.DECEMBER, 1, 20, 30, 59);
calendar.setTimeZone(timeZone);

SummaryDocumentInputModel input = SummaryDocumentInputModel.Builder.aSummaryDocumentInputModel()
.withNumero(1)
.withFechaEmisionDeComprobantesAsociados(calendar.getTimeInMillis())
.withProveedor(ProveedorInputModel.Builder.aProveedorInputModel()
.withRuc("12345678912")
.withRazonSocial("Openubl S.A.C.")
.build()
)
.withDetalle(Collections.singletonList(
SummaryDocumentLineInputModel.Builder.aSummaryDocumentLineInputModel()
.withTipoOperacion(Catalog19.ADICIONAR.toString())
.withComprobante(SummaryDocumentComprobanteInputModel.Builder.aSummaryDocumentComprobanteInputModel()
.withTipo(Catalog1.BOLETA.toString())
.withSerieNumero("B001-1")
.withCliente(ClienteInputModel.Builder.aClienteInputModel()
.withNombre("Maria Pérez")
.withNumeroDocumentoIdentidad("12345678")
.withTipoDocumentoIdentidad(Catalog6.DNI.toString())
.build()
)
.withImpuestos(SummaryDocumentImpuestosInputModel.Builder.aSummaryDocumentImpuestosInputModel()
.withIgv(new BigDecimal("180.02"))
.build()
)
.withValorVenta(SummaryDocumentComprobanteValorVentaInputModel.Builder.aSummaryDocumentComprobanteValorVentaInputModel()
.withImporteTotal(new BigDecimal("1180.12"))
.withGravado(new BigDecimal("1000.1"))
.build()
)
.build()
)
.build()
))
.build();

// When
DocumentWrapper<SummaryDocumentOutputModel> result = DocumentManager.createXML(input, config, systemClock);
SummaryDocumentOutputModel output = result.getOutput();
String xml = result.getXml();

// Then
assertOutputHasNoConstraintViolations(validator, output);
assertSnapshot(xml, "xml/summarydocument/summaryDocument_formatNumbers.xml");
assertSendSunat(xml);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<SummaryDocuments xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:SummaryDocuments-1"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns:ccts="urn:un:unece:uncefact:documentation:2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
xmlns:ns11="urn:sunat:names:specification:ubl:peru:schema:xsd:Perception-1"
xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2"
xmlns:sac="urn:sunat:names:specification:ubl:peru:schema:xsd:SunatAggregateComponents-1"
xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ext:UBLExtensions>
<ext:UBLExtension>
<ext:ExtensionContent/>
</ext:UBLExtension>
</ext:UBLExtensions>
<cbc:UBLVersionID>2.0</cbc:UBLVersionID>
<cbc:CustomizationID>1.1</cbc:CustomizationID>
<cbc:ID>RC-20191224-1</cbc:ID>
<cbc:ReferenceDate>2019-12-01</cbc:ReferenceDate>
<cbc:IssueDate>2019-12-24</cbc:IssueDate>
<cac:Signature>
<cbc:ID>12345678912</cbc:ID>
<cac:SignatoryParty>
<cac:PartyIdentification>
<cbc:ID>12345678912</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<cbc:Name><![CDATA[Openubl S.A.C.]]></cbc:Name>
</cac:PartyName>
</cac:SignatoryParty>
<cac:DigitalSignatureAttachment>
<cac:ExternalReference>
<cbc:URI>#PROJECT-OPENUBL-SIGN</cbc:URI>
</cac:ExternalReference>
</cac:DigitalSignatureAttachment>
</cac:Signature>
<cac:AccountingSupplierParty>
<cbc:CustomerAssignedAccountID>12345678912</cbc:CustomerAssignedAccountID>
<cbc:AdditionalAccountID>6</cbc:AdditionalAccountID>
<cac:Party>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Openubl S.A.C.]]></cbc:RegistrationName>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
<sac:SummaryDocumentsLine>
<cbc:LineID>1</cbc:LineID>
<cbc:DocumentTypeCode>03</cbc:DocumentTypeCode>
<cbc:ID>B001-1</cbc:ID>
<cac:AccountingCustomerParty>
<cbc:CustomerAssignedAccountID>12345678</cbc:CustomerAssignedAccountID>
<cbc:AdditionalAccountID>1</cbc:AdditionalAccountID>
</cac:AccountingCustomerParty>
<cac:Status>
<cbc:ConditionCode>1</cbc:ConditionCode>
</cac:Status>
<sac:TotalAmount currencyID="PEN">1180.12</sac:TotalAmount>
<sac:BillingPayment>
<cbc:PaidAmount currencyID="PEN">1000.1</cbc:PaidAmount>
<cbc:InstructionID>01</cbc:InstructionID>
</sac:BillingPayment>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="PEN">180.02</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxAmount currencyID="PEN">180.02</cbc:TaxAmount>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:ID>1000</cbc:ID>
<cbc:Name>IGV</cbc:Name>
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
</sac:SummaryDocumentsLine>
</SummaryDocuments>