Skip to content

Add guias #83

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
Apr 9, 2022
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
Expand Up @@ -107,5 +107,6 @@ public abstract class Document {
/**
* Guias de remision relacionadas
*/
private List<GuiaRemisionRelacionada> guiasRemisionRelacionadas;
@Singular
private List<Guia> guias;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,22 @@
*/
package io.github.project.openubl.xbuilder.content.models.standard.general;

import io.github.project.openubl.xbuilder.content.catalogs.Catalog6;
import lombok.Builder;
import lombok.Data;

@Data
public class GuiaRemisionRelacionada {
@Builder
public class Guia {

private String serieNumero;

/**
* Tipo de documento Guia.
* <p>
* Catalogo 01.
* <p>
* Valores válidos: "09", "31"
*/
private String tipoDocumento;
}
1 change: 1 addition & 0 deletions src/main/resources/templates/Renderer/creditNote.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{/for}
<cbc:DocumentCurrencyCode listID="ISO 4217 Alpha" listAgencyName="United Nations Economic Commission for Europe" listName="Currency">{moneda}</cbc:DocumentCurrencyCode>
{#include "ubl/standard/include/note/invoice-reference.xml" item=this /}
{#include ubl/standard/include/guias.xml item=this /}
{#include ubl/common/signature.xml firmante=this.firmante /}
{#include ubl/standard/include/supplier.xml proveedor=this.proveedor /}
{#include ubl/standard/include/customer.xml cliente=this.cliente /}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/templates/Renderer/debitNote.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{/for}
<cbc:DocumentCurrencyCode listID="ISO 4217 Alpha" listAgencyName="United Nations Economic Commission for Europe" listName="Currency">{moneda}</cbc:DocumentCurrencyCode>
{#include "ubl/standard/include/note/invoice-reference.xml" item=this /}
{#include ubl/standard/include/guias.xml item=this /}
{#include ubl/common/signature.xml firmante=this.firmante /}
{#include ubl/standard/include/supplier.xml proveedor=this.proveedor /}
{#include ubl/standard/include/customer.xml cliente=this.cliente /}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/templates/Renderer/invoice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<cbc:ID>{ordenDeCompra}</cbc:ID>
</cac:OrderReference>
{/if}
{#include ubl/standard/include/guias.xml item=this /}
{#each anticipos.orEmpty}
<cac:AdditionalDocumentReference>
<cbc:ID>{it.comprobanteSerieNumero}</cbc:ID>
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/templates/ubl/standard/include/guias.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{#each item.guias.orEmpty}
<cac:DespatchDocumentReference>
<cbc:ID>{it.serieNumero}</cbc:ID>
<cbc:DocumentTypeCode>{it.tipoDocumento}</cbc:DocumentTypeCode>
</cac:DespatchDocumentReference>
{/each}
84 changes: 84 additions & 0 deletions src/test/java/e2e/renderer/invoice/InvoiceGuiasTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright 2019 Project OpenUBL, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License - 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.apache.org/licenses/LICENSE-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 e2e.renderer.invoice;

import e2e.AbstractTest;
import e2e.renderer.XMLAssertUtils;
import io.github.project.openubl.xbuilder.content.catalogs.Catalog1;
import io.github.project.openubl.xbuilder.content.catalogs.Catalog6;
import io.github.project.openubl.xbuilder.content.models.common.Cliente;
import io.github.project.openubl.xbuilder.content.models.common.Proveedor;
import io.github.project.openubl.xbuilder.content.models.standard.general.DocumentoDetalle;
import io.github.project.openubl.xbuilder.content.models.standard.general.Guia;
import io.github.project.openubl.xbuilder.content.models.standard.general.Invoice;
import io.github.project.openubl.xbuilder.enricher.ContentEnricher;
import io.github.project.openubl.xbuilder.renderer.TemplateProducer;
import io.quarkus.qute.Template;
import java.math.BigDecimal;
import org.junit.jupiter.api.Test;

public class InvoiceGuiasTest extends AbstractTest {

@Test
public void testGuiaConSerieT() throws Exception {
// Given
Invoice input = Invoice
.builder()
.serie("F001")
.numero(1)
.proveedor(Proveedor.builder().ruc("12345678912").razonSocial("Softgreen S.A.C.").build())
.cliente(
Cliente
.builder()
.nombre("Carlos Feria")
.numeroDocumentoIdentidad("12121212121")
.tipoDocumentoIdentidad(Catalog6.RUC.toString())
.build()
)
.detalle(
DocumentoDetalle
.builder()
.descripcion("Item1")
.cantidad(new BigDecimal("2"))
.precio(new BigDecimal("100"))
.build()
)
.detalle(
DocumentoDetalle
.builder()
.descripcion("Item2")
.cantidad(new BigDecimal("2"))
.precio(new BigDecimal("100"))
.build()
)
.guia(
Guia.builder().tipoDocumento(Catalog1.GUIA_REMISION_REMITENTE.getCode()).serieNumero("T001-1").build()
)
.build();

ContentEnricher enricher = new ContentEnricher(defaults, dateProvider);
enricher.enrich(input);

// When
Template template = TemplateProducer.getInstance().getInvoice();
String xml = template.data(input).render();

// Then
XMLAssertUtils.assertSnapshot(xml, getClass(), "guiaSerieT.xml");
XMLAssertUtils.assertSendSunat(xml);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
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:cec="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
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:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
<ext:UBLExtensions>
<ext:UBLExtension>
<ext:ExtensionContent/>
</ext:UBLExtension>
</ext:UBLExtensions>
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:CustomizationID>2.0</cbc:CustomizationID>
<cbc:ID>F001-1</cbc:ID>
<cbc:IssueDate>2019-12-24</cbc:IssueDate>
<cbc:InvoiceTypeCode listID="0101" listAgencyName="PE:SUNAT" listName="Tipo de Documento" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo01">01</cbc:InvoiceTypeCode>
<cbc:DocumentCurrencyCode listID="ISO 4217 Alpha" listAgencyName="United Nations Economic Commission for Europe" listName="Currency">PEN</cbc:DocumentCurrencyCode>
<cac:DespatchDocumentReference>
<cbc:ID>T001-1</cbc:ID>
<cbc:DocumentTypeCode>09</cbc:DocumentTypeCode>
</cac:DespatchDocumentReference>
<cac:Signature>
<cbc:ID>12345678912</cbc:ID>
<cac:SignatoryParty>
<cac:PartyIdentification>
<cbc:ID>12345678912</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<cbc:Name><![CDATA[Softgreen 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>
<cac:Party>
<cac:PartyIdentification>
<cbc:ID schemeID="6" schemeAgencyName="PE:SUNAT" schemeName="Documento de Identidad" schemeURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo06">12345678912</cbc:ID>
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Softgreen S.A.C.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
<cac:AccountingCustomerParty>
<cac:Party>
<cac:PartyIdentification>
<cbc:ID schemeID="6" schemeAgencyName="PE:SUNAT" schemeName="Documento de Identidad" schemeURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo06">12121212121</cbc:ID>
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[Carlos Feria]]></cbc:RegistrationName>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingCustomerParty>
<cac:PaymentTerms>
<cbc:ID>FormaPago</cbc:ID>
<cbc:PaymentMeansID>Contado</cbc:PaymentMeansID>
</cac:PaymentTerms>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="PEN">72.00</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="PEN">400.00</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="PEN">72.00</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID schemeAgencyName="United Nations Economic Commission for Europe" schemeID="UN/ECE 5305" schemeName="Tax Category Identifie">S</cbc:ID>
<cac:TaxScheme>
<cbc:ID schemeAgencyName="PE:SUNAT" schemeID="UN/ECE 5153" schemeName="Codigo de tributos">1000</cbc:ID>
<cbc:Name>IGV</cbc:Name>
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:LegalMonetaryTotal>
<cbc:LineExtensionAmount currencyID="PEN">400.00</cbc:LineExtensionAmount>
<cbc:TaxInclusiveAmount currencyID="PEN">472.00</cbc:TaxInclusiveAmount>
<cbc:PrepaidAmount currencyID="PEN">0</cbc:PrepaidAmount>
<cbc:PayableAmount currencyID="PEN">472.00</cbc:PayableAmount>
</cac:LegalMonetaryTotal>
<cac:InvoiceLine>
<cbc:ID>1</cbc:ID>
<cbc:InvoicedQuantity unitCode="NIU" unitCodeListAgencyName="United Nations Economic Commission for Europe" unitCodeListID="UN/ECE rec 20">2</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="PEN">200.00</cbc:LineExtensionAmount>
<cac:PricingReference>
<cac:AlternativeConditionPrice>
<cbc:PriceAmount currencyID="PEN">118.00</cbc:PriceAmount>
<cbc:PriceTypeCode listAgencyName="PE:SUNAT" listName="Tipo de Precio" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo16">01</cbc:PriceTypeCode>
</cac:AlternativeConditionPrice>
</cac:PricingReference>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="PEN">36.00</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="PEN">200.00</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="PEN">36.00</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID schemeAgencyName="United Nations Economic Commission for Europe" schemeID="UN/ECE 5305" schemeName="Tax Category Identifier">S</cbc:ID>
<cbc:Percent>18.00</cbc:Percent>
<cbc:TaxExemptionReasonCode listAgencyName="PE:SUNAT" listName="Afectacion del IGV" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo07">10</cbc:TaxExemptionReasonCode>
<cac:TaxScheme>
<cbc:ID schemeAgencyName="PE:SUNAT" schemeID="UN/ECE 5153" schemeName="Codigo de tributos">1000</cbc:ID>
<cbc:Name>IGV</cbc:Name>
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:Item>
<cbc:Description><![CDATA[Item1]]></cbc:Description>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="PEN">100.00</cbc:PriceAmount>
</cac:Price>
</cac:InvoiceLine>
<cac:InvoiceLine>
<cbc:ID>2</cbc:ID>
<cbc:InvoicedQuantity unitCode="NIU" unitCodeListAgencyName="United Nations Economic Commission for Europe" unitCodeListID="UN/ECE rec 20">2</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="PEN">200.00</cbc:LineExtensionAmount>
<cac:PricingReference>
<cac:AlternativeConditionPrice>
<cbc:PriceAmount currencyID="PEN">118.00</cbc:PriceAmount>
<cbc:PriceTypeCode listAgencyName="PE:SUNAT" listName="Tipo de Precio" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo16">01</cbc:PriceTypeCode>
</cac:AlternativeConditionPrice>
</cac:PricingReference>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="PEN">36.00</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="PEN">200.00</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="PEN">36.00</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID schemeAgencyName="United Nations Economic Commission for Europe" schemeID="UN/ECE 5305" schemeName="Tax Category Identifier">S</cbc:ID>
<cbc:Percent>18.00</cbc:Percent>
<cbc:TaxExemptionReasonCode listAgencyName="PE:SUNAT" listName="Afectacion del IGV" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo07">10</cbc:TaxExemptionReasonCode>
<cac:TaxScheme>
<cbc:ID schemeAgencyName="PE:SUNAT" schemeID="UN/ECE 5153" schemeName="Codigo de tributos">1000</cbc:ID>
<cbc:Name>IGV</cbc:Name>
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:Item>
<cbc:Description><![CDATA[Item2]]></cbc:Description>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="PEN">100.00</cbc:PriceAmount>
</cac:Price>
</cac:InvoiceLine>
</Invoice>