Skip to content

Commit ad4b631

Browse files
fix: summaryDocuments include IGV always (#184)
1 parent 3b1bff1 commit ad4b631

File tree

4 files changed

+114
-3
lines changed

4 files changed

+114
-3
lines changed

xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/jaxb/mappers/SummaryDocumentsMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ default ComprobanteImpuestos mapLineComprobanteImpuestos(XMLSummaryDocumentsLine
119119
.flatMap(taxScheme -> Optional.ofNullable(taxScheme.getId()))
120120
.flatMap(code -> Catalog.valueOfCode(Catalog5.class, code))
121121
.orElse(null),
122-
XMLSummaryDocumentsLine.TaxTotal::getTaxAmount
122+
taxTotal -> Optional.ofNullable(taxTotal.getTaxAmount()).orElse(BigDecimal.ZERO)
123123
));
124124

125125
return ComprobanteImpuestos.builder()

xbuilder/core/src/main/resources/templates/Renderer/summaryDocuments.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
<cbc:Amount currencyID="{it.comprobante.moneda}">{it.comprobante.valorVenta.otrosCargos}</cbc:Amount>
7373
</cac:AllowanceCharge>
7474
{/if}
75-
{#if it.comprobante.impuestos.igv}
7675
<cac:TaxTotal>
7776
<cbc:TaxAmount currencyID="{it.comprobante.moneda}">{it.comprobante.impuestos.igv}</cbc:TaxAmount>
7877
<cac:TaxSubtotal>
@@ -86,7 +85,6 @@
8685
</cac:TaxCategory>
8786
</cac:TaxSubtotal>
8887
</cac:TaxTotal>
89-
{/if}
9088
{#if it.comprobante.impuestos.icb}
9189
<cac:TaxTotal>
9290
<cbc:TaxAmount currencyID="{it.comprobante.moneda}">{it.comprobante.impuestos.icb}</cbc:TaxAmount>

xbuilder/core/src/test/java/e2e/renderer/summarydocuments/SummaryDocumentsTest.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,44 @@ public void testMultipleVoidedDocuments() throws Exception {
105105
assertInput(input, "summaryDocuments.xml");
106106
}
107107

108+
@Test
109+
public void testVoidedDocument_anularBoletaExonerada() throws Exception {
110+
// Given
111+
SummaryDocuments input = SummaryDocuments.builder()
112+
.numero(1)
113+
.fechaEmisionComprobantes(dateProvider.now().minusDays(2))
114+
.proveedor(Proveedor.builder()
115+
.ruc("12345678912")
116+
.razonSocial("Softgreen S.A.C.")
117+
.build()
118+
)
119+
.comprobante(SummaryDocumentsItem.builder()
120+
.tipoOperacion(Catalog19.ANULADO.toString())
121+
.comprobante(Comprobante.builder()
122+
.tipoComprobante(Catalog1_Invoice.BOLETA.getCode())//
123+
.serieNumero("B001-1")
124+
.cliente(Cliente.builder()
125+
.nombre("Carlos Feria")
126+
.numeroDocumentoIdentidad("12345678")
127+
.tipoDocumentoIdentidad(Catalog6.DNI.getCode())
128+
.build()
129+
)
130+
.impuestos(ComprobanteImpuestos.builder()
131+
.igv(new BigDecimal("0"))
132+
.build()
133+
)
134+
.valorVenta(ComprobanteValorVenta.builder()
135+
.importeTotal(new BigDecimal("100"))
136+
.gravado(new BigDecimal("0"))
137+
.exonerado(new BigDecimal("0"))
138+
.build()
139+
)
140+
.build()
141+
)
142+
.build()
143+
)
144+
.build();
145+
146+
assertInput(input, "summaryDocuments_anularBoletaExonerada.xml");
147+
}
108148
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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-22</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[Softgreen 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[Softgreen 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>3</cbc:ConditionCode>
57+
</cac:Status>
58+
<sac:TotalAmount currencyID="PEN">100</sac:TotalAmount>
59+
<cac:TaxTotal>
60+
<cbc:TaxAmount currencyID="PEN">0</cbc:TaxAmount>
61+
<cac:TaxSubtotal>
62+
<cbc:TaxAmount currencyID="PEN">0</cbc:TaxAmount>
63+
<cac:TaxCategory>
64+
<cac:TaxScheme>
65+
<cbc:ID>1000</cbc:ID>
66+
<cbc:Name>IGV</cbc:Name>
67+
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
68+
</cac:TaxScheme>
69+
</cac:TaxCategory>
70+
</cac:TaxSubtotal>
71+
</cac:TaxTotal>
72+
</sac:SummaryDocumentsLine>
73+
</SummaryDocuments>

0 commit comments

Comments
 (0)