Skip to content

Commit c00dd14

Browse files
Add guias (#83)
1 parent e4b8290 commit c00dd14

File tree

8 files changed

+268
-2
lines changed

8 files changed

+268
-2
lines changed

src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/Document.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,6 @@ public abstract class Document {
107107
/**
108108
* Guias de remision relacionadas
109109
*/
110-
private List<GuiaRemisionRelacionada> guiasRemisionRelacionadas;
110+
@Singular
111+
private List<Guia> guias;
111112
}
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,22 @@
1616
*/
1717
package io.github.project.openubl.xbuilder.content.models.standard.general;
1818

19+
import io.github.project.openubl.xbuilder.content.catalogs.Catalog6;
20+
import lombok.Builder;
1921
import lombok.Data;
2022

2123
@Data
22-
public class GuiaRemisionRelacionada {
24+
@Builder
25+
public class Guia {
2326

2427
private String serieNumero;
28+
29+
/**
30+
* Tipo de documento Guia.
31+
* <p>
32+
* Catalogo 01.
33+
* <p>
34+
* Valores válidos: "09", "31"
35+
*/
2536
private String tipoDocumento;
2637
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
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 /}
12+
{#include ubl/standard/include/guias.xml item=this /}
1213
{#include ubl/common/signature.xml firmante=this.firmante /}
1314
{#include ubl/standard/include/supplier.xml proveedor=this.proveedor /}
1415
{#include ubl/standard/include/customer.xml cliente=this.cliente /}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
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 /}
12+
{#include ubl/standard/include/guias.xml item=this /}
1213
{#include ubl/common/signature.xml firmante=this.firmante /}
1314
{#include ubl/standard/include/supplier.xml proveedor=this.proveedor /}
1415
{#include ubl/standard/include/customer.xml cliente=this.cliente /}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<cbc:ID>{ordenDeCompra}</cbc:ID>
2121
</cac:OrderReference>
2222
{/if}
23+
{#include ubl/standard/include/guias.xml item=this /}
2324
{#each anticipos.orEmpty}
2425
<cac:AdditionalDocumentReference>
2526
<cbc:ID>{it.comprobanteSerieNumero}</cbc:ID>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{#each item.guias.orEmpty}
2+
<cac:DespatchDocumentReference>
3+
<cbc:ID>{it.serieNumero}</cbc:ID>
4+
<cbc:DocumentTypeCode>{it.tipoDocumento}</cbc:DocumentTypeCode>
5+
</cac:DespatchDocumentReference>
6+
{/each}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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 Apache License - 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.apache.org/licenses/LICENSE-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 e2e.renderer.invoice;
18+
19+
import e2e.AbstractTest;
20+
import e2e.renderer.XMLAssertUtils;
21+
import io.github.project.openubl.xbuilder.content.catalogs.Catalog1;
22+
import io.github.project.openubl.xbuilder.content.catalogs.Catalog6;
23+
import io.github.project.openubl.xbuilder.content.models.common.Cliente;
24+
import io.github.project.openubl.xbuilder.content.models.common.Proveedor;
25+
import io.github.project.openubl.xbuilder.content.models.standard.general.DocumentoDetalle;
26+
import io.github.project.openubl.xbuilder.content.models.standard.general.Guia;
27+
import io.github.project.openubl.xbuilder.content.models.standard.general.Invoice;
28+
import io.github.project.openubl.xbuilder.enricher.ContentEnricher;
29+
import io.github.project.openubl.xbuilder.renderer.TemplateProducer;
30+
import io.quarkus.qute.Template;
31+
import java.math.BigDecimal;
32+
import org.junit.jupiter.api.Test;
33+
34+
public class InvoiceGuiasTest extends AbstractTest {
35+
36+
@Test
37+
public void testGuiaConSerieT() throws Exception {
38+
// Given
39+
Invoice input = Invoice
40+
.builder()
41+
.serie("F001")
42+
.numero(1)
43+
.proveedor(Proveedor.builder().ruc("12345678912").razonSocial("Softgreen S.A.C.").build())
44+
.cliente(
45+
Cliente
46+
.builder()
47+
.nombre("Carlos Feria")
48+
.numeroDocumentoIdentidad("12121212121")
49+
.tipoDocumentoIdentidad(Catalog6.RUC.toString())
50+
.build()
51+
)
52+
.detalle(
53+
DocumentoDetalle
54+
.builder()
55+
.descripcion("Item1")
56+
.cantidad(new BigDecimal("2"))
57+
.precio(new BigDecimal("100"))
58+
.build()
59+
)
60+
.detalle(
61+
DocumentoDetalle
62+
.builder()
63+
.descripcion("Item2")
64+
.cantidad(new BigDecimal("2"))
65+
.precio(new BigDecimal("100"))
66+
.build()
67+
)
68+
.guia(
69+
Guia.builder().tipoDocumento(Catalog1.GUIA_REMISION_REMITENTE.getCode()).serieNumero("T001-1").build()
70+
)
71+
.build();
72+
73+
ContentEnricher enricher = new ContentEnricher(defaults, dateProvider);
74+
enricher.enrich(input);
75+
76+
// When
77+
Template template = TemplateProducer.getInstance().getInvoice();
78+
String xml = template.data(input).render();
79+
80+
// Then
81+
XMLAssertUtils.assertSnapshot(xml, getClass(), "guiaSerieT.xml");
82+
XMLAssertUtils.assertSendSunat(xml);
83+
}
84+
}
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
13+
>
14+
<ext:UBLExtensions>
15+
<ext:UBLExtension>
16+
<ext:ExtensionContent/>
17+
</ext:UBLExtension>
18+
</ext:UBLExtensions>
19+
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
20+
<cbc:CustomizationID>2.0</cbc:CustomizationID>
21+
<cbc:ID>F001-1</cbc:ID>
22+
<cbc:IssueDate>2019-12-24</cbc:IssueDate>
23+
<cbc:InvoiceTypeCode listID="0101" listAgencyName="PE:SUNAT" listName="Tipo de Documento" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo01">01</cbc:InvoiceTypeCode>
24+
<cbc:DocumentCurrencyCode listID="ISO 4217 Alpha" listAgencyName="United Nations Economic Commission for Europe" listName="Currency">PEN</cbc:DocumentCurrencyCode>
25+
<cac:DespatchDocumentReference>
26+
<cbc:ID>T001-1</cbc:ID>
27+
<cbc:DocumentTypeCode>09</cbc:DocumentTypeCode>
28+
</cac:DespatchDocumentReference>
29+
<cac:Signature>
30+
<cbc:ID>12345678912</cbc:ID>
31+
<cac:SignatoryParty>
32+
<cac:PartyIdentification>
33+
<cbc:ID>12345678912</cbc:ID>
34+
</cac:PartyIdentification>
35+
<cac:PartyName>
36+
<cbc:Name><![CDATA[Softgreen S.A.C.]]></cbc:Name>
37+
</cac:PartyName>
38+
</cac:SignatoryParty>
39+
<cac:DigitalSignatureAttachment>
40+
<cac:ExternalReference>
41+
<cbc:URI>#PROJECT-OPENUBL-SIGN</cbc:URI>
42+
</cac:ExternalReference>
43+
</cac:DigitalSignatureAttachment>
44+
</cac:Signature>
45+
<cac:AccountingSupplierParty>
46+
<cac:Party>
47+
<cac:PartyIdentification>
48+
<cbc:ID schemeID="6" schemeAgencyName="PE:SUNAT" schemeName="Documento de Identidad" schemeURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo06">12345678912</cbc:ID>
49+
</cac:PartyIdentification>
50+
<cac:PartyLegalEntity>
51+
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
52+
<cac:RegistrationAddress>
53+
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
54+
</cac:RegistrationAddress>
55+
</cac:PartyLegalEntity>
56+
</cac:Party>
57+
</cac:AccountingSupplierParty>
58+
<cac:AccountingCustomerParty>
59+
<cac:Party>
60+
<cac:PartyIdentification>
61+
<cbc:ID schemeID="6" schemeAgencyName="PE:SUNAT" schemeName="Documento de Identidad" schemeURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo06">12121212121</cbc:ID>
62+
</cac:PartyIdentification>
63+
<cac:PartyLegalEntity>
64+
<cbc:RegistrationName><![CDATA[Carlos Feria]]></cbc:RegistrationName>
65+
</cac:PartyLegalEntity>
66+
</cac:Party>
67+
</cac:AccountingCustomerParty>
68+
<cac:PaymentTerms>
69+
<cbc:ID>FormaPago</cbc:ID>
70+
<cbc:PaymentMeansID>Contado</cbc:PaymentMeansID>
71+
</cac:PaymentTerms>
72+
<cac:TaxTotal>
73+
<cbc:TaxAmount currencyID="PEN">72.00</cbc:TaxAmount>
74+
<cac:TaxSubtotal>
75+
<cbc:TaxableAmount currencyID="PEN">400.00</cbc:TaxableAmount>
76+
<cbc:TaxAmount currencyID="PEN">72.00</cbc:TaxAmount>
77+
<cac:TaxCategory>
78+
<cbc:ID schemeAgencyName="United Nations Economic Commission for Europe" schemeID="UN/ECE 5305" schemeName="Tax Category Identifie">S</cbc:ID>
79+
<cac:TaxScheme>
80+
<cbc:ID schemeAgencyName="PE:SUNAT" schemeID="UN/ECE 5153" schemeName="Codigo de tributos">1000</cbc:ID>
81+
<cbc:Name>IGV</cbc:Name>
82+
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
83+
</cac:TaxScheme>
84+
</cac:TaxCategory>
85+
</cac:TaxSubtotal>
86+
</cac:TaxTotal>
87+
<cac:LegalMonetaryTotal>
88+
<cbc:LineExtensionAmount currencyID="PEN">400.00</cbc:LineExtensionAmount>
89+
<cbc:TaxInclusiveAmount currencyID="PEN">472.00</cbc:TaxInclusiveAmount>
90+
<cbc:PrepaidAmount currencyID="PEN">0</cbc:PrepaidAmount>
91+
<cbc:PayableAmount currencyID="PEN">472.00</cbc:PayableAmount>
92+
</cac:LegalMonetaryTotal>
93+
<cac:InvoiceLine>
94+
<cbc:ID>1</cbc:ID>
95+
<cbc:InvoicedQuantity unitCode="NIU" unitCodeListAgencyName="United Nations Economic Commission for Europe" unitCodeListID="UN/ECE rec 20">2</cbc:InvoicedQuantity>
96+
<cbc:LineExtensionAmount currencyID="PEN">200.00</cbc:LineExtensionAmount>
97+
<cac:PricingReference>
98+
<cac:AlternativeConditionPrice>
99+
<cbc:PriceAmount currencyID="PEN">118.00</cbc:PriceAmount>
100+
<cbc:PriceTypeCode listAgencyName="PE:SUNAT" listName="Tipo de Precio" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo16">01</cbc:PriceTypeCode>
101+
</cac:AlternativeConditionPrice>
102+
</cac:PricingReference>
103+
<cac:TaxTotal>
104+
<cbc:TaxAmount currencyID="PEN">36.00</cbc:TaxAmount>
105+
<cac:TaxSubtotal>
106+
<cbc:TaxableAmount currencyID="PEN">200.00</cbc:TaxableAmount>
107+
<cbc:TaxAmount currencyID="PEN">36.00</cbc:TaxAmount>
108+
<cac:TaxCategory>
109+
<cbc:ID schemeAgencyName="United Nations Economic Commission for Europe" schemeID="UN/ECE 5305" schemeName="Tax Category Identifier">S</cbc:ID>
110+
<cbc:Percent>18.00</cbc:Percent>
111+
<cbc:TaxExemptionReasonCode listAgencyName="PE:SUNAT" listName="Afectacion del IGV" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo07">10</cbc:TaxExemptionReasonCode>
112+
<cac:TaxScheme>
113+
<cbc:ID schemeAgencyName="PE:SUNAT" schemeID="UN/ECE 5153" schemeName="Codigo de tributos">1000</cbc:ID>
114+
<cbc:Name>IGV</cbc:Name>
115+
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
116+
</cac:TaxScheme>
117+
</cac:TaxCategory>
118+
</cac:TaxSubtotal>
119+
</cac:TaxTotal>
120+
<cac:Item>
121+
<cbc:Description><![CDATA[Item1]]></cbc:Description>
122+
</cac:Item>
123+
<cac:Price>
124+
<cbc:PriceAmount currencyID="PEN">100.00</cbc:PriceAmount>
125+
</cac:Price>
126+
</cac:InvoiceLine>
127+
<cac:InvoiceLine>
128+
<cbc:ID>2</cbc:ID>
129+
<cbc:InvoicedQuantity unitCode="NIU" unitCodeListAgencyName="United Nations Economic Commission for Europe" unitCodeListID="UN/ECE rec 20">2</cbc:InvoicedQuantity>
130+
<cbc:LineExtensionAmount currencyID="PEN">200.00</cbc:LineExtensionAmount>
131+
<cac:PricingReference>
132+
<cac:AlternativeConditionPrice>
133+
<cbc:PriceAmount currencyID="PEN">118.00</cbc:PriceAmount>
134+
<cbc:PriceTypeCode listAgencyName="PE:SUNAT" listName="Tipo de Precio" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo16">01</cbc:PriceTypeCode>
135+
</cac:AlternativeConditionPrice>
136+
</cac:PricingReference>
137+
<cac:TaxTotal>
138+
<cbc:TaxAmount currencyID="PEN">36.00</cbc:TaxAmount>
139+
<cac:TaxSubtotal>
140+
<cbc:TaxableAmount currencyID="PEN">200.00</cbc:TaxableAmount>
141+
<cbc:TaxAmount currencyID="PEN">36.00</cbc:TaxAmount>
142+
<cac:TaxCategory>
143+
<cbc:ID schemeAgencyName="United Nations Economic Commission for Europe" schemeID="UN/ECE 5305" schemeName="Tax Category Identifier">S</cbc:ID>
144+
<cbc:Percent>18.00</cbc:Percent>
145+
<cbc:TaxExemptionReasonCode listAgencyName="PE:SUNAT" listName="Afectacion del IGV" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo07">10</cbc:TaxExemptionReasonCode>
146+
<cac:TaxScheme>
147+
<cbc:ID schemeAgencyName="PE:SUNAT" schemeID="UN/ECE 5153" schemeName="Codigo de tributos">1000</cbc:ID>
148+
<cbc:Name>IGV</cbc:Name>
149+
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
150+
</cac:TaxScheme>
151+
</cac:TaxCategory>
152+
</cac:TaxSubtotal>
153+
</cac:TaxTotal>
154+
<cac:Item>
155+
<cbc:Description><![CDATA[Item2]]></cbc:Description>
156+
</cac:Item>
157+
<cac:Price>
158+
<cbc:PriceAmount currencyID="PEN">100.00</cbc:PriceAmount>
159+
</cac:Price>
160+
</cac:InvoiceLine>
161+
</Invoice>

0 commit comments

Comments
 (0)