Skip to content

Guia remision relacionadas #38

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 4 commits into from
Jun 3, 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
Expand Up @@ -37,9 +37,7 @@
import io.github.project.openubl.xmlbuilderlib.models.output.standard.note.debitNote.DebitNoteOutputModel;

import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.TimeZone;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -131,6 +129,19 @@ private static void enrichDocument(DocumentInputModel input, DocumentOutputModel
: FirmanteOutputModelFactory.getFirmante(input.getProveedor())
);

// Guias de remisión relacionadas
builder.withGuiasRemisionRelacionadas(input.getGuiasRemisionRelacionadas() != null ?
input.getGuiasRemisionRelacionadas().stream()
.map(guiaRemisionInput -> {
GuiaRemisionRelacionadaOutputModel guiaRemisionOutput = new GuiaRemisionRelacionadaOutputModel();
guiaRemisionOutput.setSerieNumero(guiaRemisionInput.getSerieNumero());
guiaRemisionOutput.setTipoDocumento(Catalog.valueOfCode(Catalog1_Guia.class, guiaRemisionInput.getTipoDocumento()).orElseThrow(Catalog.invalidCatalogValue));
return guiaRemisionOutput;
})
.collect(Collectors.toList())
: Collections.emptyList()
);

// Detalle
List<DocumentLineOutputModel> lineOutput = input.getDetalle().stream()
.map(f -> DocumentLineOutputModelFactory.getDocumentLineOutput(f, config, systemClock))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* 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.models.catalogs;

import java.util.Optional;
import java.util.stream.Stream;

public enum Catalog1_Guia implements Catalog {

GUIA_REMISION_REMITENTE("09"),
GUIA_REMISION_TRANSPORTISTA("31");

private final String code;

Catalog1_Guia(String code) {
this.code = code;
}

public static Optional<Catalog1_Guia> valueOfCode(String code) {
return Stream.of(Catalog1_Guia.values())
.filter(p -> p.code.equals(code))
.findFirst();
}

@Override
public String getCode() {
return code;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public abstract class DocumentInputModel {
@Valid
private List<DocumentLineInputModel> detalle;

@Valid
private List<GuiaRemisionRelacionadaInputModel> guiasRemisionRelacionadas;

public String getSerie() {
return serie;
}
Expand Down Expand Up @@ -114,4 +117,11 @@ public void setDetalle(List<DocumentLineInputModel> detalle) {
this.detalle = detalle;
}

public List<GuiaRemisionRelacionadaInputModel> getGuiasRemisionRelacionadas() {
return guiasRemisionRelacionadas;
}

public void setGuiasRemisionRelacionadas(List<GuiaRemisionRelacionadaInputModel> guiasRemisionRelacionadas) {
this.guiasRemisionRelacionadas = guiasRemisionRelacionadas;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package io.github.project.openubl.xmlbuilderlib.models.input.standard;

import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog1;
import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog1_Guia;
import io.github.project.openubl.xmlbuilderlib.models.catalogs.constraints.CatalogConstraint;

import javax.validation.constraints.NotBlank;
Expand All @@ -26,8 +26,8 @@ public class GuiaRemisionRelacionadaInputModel {
@NotBlank
protected String serieNumero;

@CatalogConstraint(value = Catalog1.class)
private String tipoDocumento;
@CatalogConstraint(value = Catalog1_Guia.class)
protected String tipoDocumento;

public String getSerieNumero() {
return serieNumero;
Expand All @@ -45,4 +45,32 @@ public void setTipoDocumento(String tipoDocumento) {
this.tipoDocumento = tipoDocumento;
}

public static final class Builder {
protected String serieNumero;
protected String tipoDocumento;

private Builder() {
}

public static Builder aGuiaRemisionRelacionadaInputModel() {
return new Builder();
}

public Builder withSerieNumero(String serieNumero) {
this.serieNumero = serieNumero;
return this;
}

public Builder withTipoDocumento(String tipoDocumento) {
this.tipoDocumento = tipoDocumento;
return this;
}

public GuiaRemisionRelacionadaInputModel build() {
GuiaRemisionRelacionadaInputModel guiaRemisionRelacionadaInputModel = new GuiaRemisionRelacionadaInputModel();
guiaRemisionRelacionadaInputModel.setSerieNumero(serieNumero);
guiaRemisionRelacionadaInputModel.setTipoDocumento(tipoDocumento);
return guiaRemisionRelacionadaInputModel;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.github.project.openubl.xmlbuilderlib.models.input.constraints.HighLevelGroupValidation;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.DocumentInputModel;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.DocumentLineInputModel;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.GuiaRemisionRelacionadaInputModel;

import javax.validation.Valid;
import java.util.List;
Expand Down Expand Up @@ -51,6 +52,7 @@ public static final class Builder {
private FirmanteInputModel firmante;
private List<DocumentLineInputModel> detalle;
private List<CuotaDePagoInputModel> cuotasDePago;
private List<GuiaRemisionRelacionadaInputModel> guiasRemisionRelacionadas;

private Builder() {
}
Expand Down Expand Up @@ -99,6 +101,11 @@ public Builder withCuotasDePago(List<CuotaDePagoInputModel> cuotasDePago) {
return this;
}

public Builder withGuiasRemisionRelacionadas(List<GuiaRemisionRelacionadaInputModel> guiasRemisionRelacionadas) {
this.guiasRemisionRelacionadas = guiasRemisionRelacionadas;
return this;
}

public InvoiceInputModel build() {
InvoiceInputModel invoiceInputModel = new InvoiceInputModel();
invoiceInputModel.setSerie(serie);
Expand All @@ -109,6 +116,7 @@ public InvoiceInputModel build() {
invoiceInputModel.setFirmante(firmante);
invoiceInputModel.setDetalle(detalle);
invoiceInputModel.setCuotasDePago(cuotasDePago);
invoiceInputModel.setGuiasRemisionRelacionadas(guiasRemisionRelacionadas);
return invoiceInputModel;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.github.project.openubl.xmlbuilderlib.models.input.constraints.CuotaDePagoInputModel_Porcentaje100CollectionConstraint;
import io.github.project.openubl.xmlbuilderlib.models.input.constraints.HighLevelGroupValidation;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.DocumentLineInputModel;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.GuiaRemisionRelacionadaInputModel;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.note.NoteInputModel;

import javax.validation.Valid;
Expand Down Expand Up @@ -67,6 +68,7 @@ public static final class Builder {
private FirmanteInputModel firmante;
private List<DocumentLineInputModel> detalle;
private List<CuotaDePagoInputModel> cuotasDePago;
private List<GuiaRemisionRelacionadaInputModel> guiasRemisionRelacionadas;

private Builder() {
}
Expand Down Expand Up @@ -130,6 +132,11 @@ public Builder withCuotasDePago(List<CuotaDePagoInputModel> cuotasDePago) {
return this;
}

public Builder withGuiasRemisionRelacionadas(List<GuiaRemisionRelacionadaInputModel> guiasRemisionRelacionadas) {
this.guiasRemisionRelacionadas = guiasRemisionRelacionadas;
return this;
}

public CreditNoteInputModel build() {
CreditNoteInputModel creditNoteInputModel = new CreditNoteInputModel();
creditNoteInputModel.setSerieNumeroComprobanteAfectado(serieNumeroComprobanteAfectado);
Expand All @@ -143,6 +150,7 @@ public CreditNoteInputModel build() {
creditNoteInputModel.setFirmante(firmante);
creditNoteInputModel.setDetalle(detalle);
creditNoteInputModel.setCuotasDePago(cuotasDePago);
creditNoteInputModel.setGuiasRemisionRelacionadas(guiasRemisionRelacionadas);
return creditNoteInputModel;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.github.project.openubl.xmlbuilderlib.models.input.common.FirmanteInputModel;
import io.github.project.openubl.xmlbuilderlib.models.input.common.ProveedorInputModel;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.DocumentLineInputModel;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.GuiaRemisionRelacionadaInputModel;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.note.NoteInputModel;

import java.util.List;
Expand Down Expand Up @@ -51,7 +52,7 @@ public static final class Builder {
private ProveedorInputModel proveedor;
private FirmanteInputModel firmante;
private List<DocumentLineInputModel> detalle;
private List<CuotaDePagoInputModel> cuotasDePago;
private List<GuiaRemisionRelacionadaInputModel> guiasRemisionRelacionadas;

private Builder() {
}
Expand Down Expand Up @@ -110,8 +111,8 @@ public Builder withDetalle(List<DocumentLineInputModel> detalle) {
return this;
}

public Builder withCuotasDePago(List<CuotaDePagoInputModel> cuotasDePago) {
this.cuotasDePago = cuotasDePago;
public Builder withGuiasRemisionRelacionadas(List<GuiaRemisionRelacionadaInputModel> guiasRemisionRelacionadas) {
this.guiasRemisionRelacionadas = guiasRemisionRelacionadas;
return this;
}

Expand All @@ -127,6 +128,7 @@ public DebitNoteInputModel build() {
debitNoteInputModel.setProveedor(proveedor);
debitNoteInputModel.setFirmante(firmante);
debitNoteInputModel.setDetalle(detalle);
debitNoteInputModel.setGuiasRemisionRelacionadas(guiasRemisionRelacionadas);
return debitNoteInputModel;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public abstract class DocumentOutputModel {
@Valid
protected FormaPagoOutputModel formaPago;

@NotNull
@Valid
protected List<GuiaRemisionRelacionadaOutputModel> guiasRemisionRelacionadas;

public String getMoneda() {
return moneda;
}
Expand Down Expand Up @@ -158,6 +162,14 @@ public void setFormaPago(FormaPagoOutputModel formaPago) {
this.formaPago = formaPago;
}

public List<GuiaRemisionRelacionadaOutputModel> getGuiasRemisionRelacionadas() {
return guiasRemisionRelacionadas;
}

public void setGuiasRemisionRelacionadas(List<GuiaRemisionRelacionadaOutputModel> guiasRemisionRelacionadas) {
this.guiasRemisionRelacionadas = guiasRemisionRelacionadas;
}

public static class Builder {
protected String moneda;
protected String serieNumero;
Expand All @@ -170,6 +182,7 @@ public static class Builder {
protected DocumentImpuestosOutputModel impuestos;
protected List<DocumentLineOutputModel> detalle;
protected FormaPagoOutputModel formaPago;
protected List<GuiaRemisionRelacionadaOutputModel> guiasRemisionRelacionadas;

protected Builder() {
}
Expand Down Expand Up @@ -232,5 +245,10 @@ public Builder withFormaPago(FormaPagoOutputModel formaPago) {
this.formaPago = formaPago;
return this;
}

public Builder withGuiasRemisionRelacionadas(List<GuiaRemisionRelacionadaOutputModel> guiasRemisionRelacionadas) {
this.guiasRemisionRelacionadas = guiasRemisionRelacionadas;
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package io.github.project.openubl.xmlbuilderlib.models.output.standard;

import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog1;
import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog1_Guia;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
Expand All @@ -27,7 +27,7 @@ public class GuiaRemisionRelacionadaOutputModel {
protected String serieNumero;

@NotNull
private Catalog1 tipoDocumento;
private Catalog1_Guia tipoDocumento;

public String getSerieNumero() {
return serieNumero;
Expand All @@ -37,11 +37,11 @@ public void setSerieNumero(String serieNumero) {
this.serieNumero = serieNumero;
}

public Catalog1 getTipoDocumento() {
public Catalog1_Guia getTipoDocumento() {
return tipoDocumento;
}

public void setTipoDocumento(Catalog1 tipoDocumento) {
public void setTipoDocumento(Catalog1_Guia tipoDocumento) {
this.tipoDocumento = tipoDocumento;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public InvoiceOutputModel build() {
invoiceOutputModel.setDetalle(detalle);
invoiceOutputModel.setTipoInvoice(tipoInvoice);
invoiceOutputModel.setFormaPago(formaPago);
invoiceOutputModel.setGuiasRemisionRelacionadas(guiasRemisionRelacionadas);
return invoiceOutputModel;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public CreditNoteOutputModel build() {
creditNoteOutputModel.setImpuestos(impuestos);
creditNoteOutputModel.setDetalle(detalle);
creditNoteOutputModel.setFormaPago(formaPago);
creditNoteOutputModel.setGuiasRemisionRelacionadas(guiasRemisionRelacionadas);
return creditNoteOutputModel;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public DebitNoteOutputModel build() {
debitNoteOutputModel.setImpuestos(impuestos);
debitNoteOutputModel.setDetalle(detalle);
debitNoteOutputModel.setFormaPago(formaPago);
debitNoteOutputModel.setGuiasRemisionRelacionadas(guiasRemisionRelacionadas);
return debitNoteOutputModel;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#list guiasRemisionRelacionadas as item>
<cac:DespatchDocumentReference>
<cbc:ID>${item.serieNumero}</cbc:ID>
<cbc:DocumentTypeCode listAgencyName="PE:SUNAT" listName="Guía relacionada" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo01">${item.tipoDocumento.code}</cbc:DocumentTypeCode>
<cbc:DocumentTypeCode listAgencyName="PE:SUNAT" listName="Tipo de Documento" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo01">${item.tipoDocumento.code}</cbc:DocumentTypeCode>
</cac:DespatchDocumentReference>
</#list>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<#-- <#include "./common/legends.ftl">-->
<cbc:DocumentCurrencyCode listID="ISO 4217 Alpha" listAgencyName="United Nations Economic Commission for Europe" listName="Currency">${moneda}</cbc:DocumentCurrencyCode>
<#include "common/note/invoice-reference.ftl">
<#-- <#include "./common/despatch-document-reference.ftl">-->
<#include "common/despatch-document-reference.ftl">
<#-- <#include "./common/additional-document-reference.ftl">-->
<#include "../signature.ftl">
<#include "common/supplier.ftl">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<#-- <#include "./common/legends.ftl">-->
<cbc:DocumentCurrencyCode listID="ISO 4217 Alpha" listAgencyName="United Nations Economic Commission for Europe" listName="Currency">${moneda}</cbc:DocumentCurrencyCode>
<#include "common/note/invoice-reference.ftl">
<#-- <#include "./common/despatch-document-reference.ftl">-->
<#include "common/despatch-document-reference.ftl">
<#-- <#include "./common/additional-document-reference.ftl">-->
<#include "../signature.ftl">
<#include "common/supplier.ftl">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<#-- <cbc:ID>${orderCompra}</cbc:ID>-->
<#-- </cac:OrderReference>-->
<#-- </#if>-->
<#-- <#include "./common/despatch-document-reference.ftl">-->
<#include "common/despatch-document-reference.ftl">
<#-- <#include "./common/additional-document-reference.ftl">-->
<#-- <#list anticipos as item>-->
<#-- <cac:AdditionalDocumentReference>-->
Expand Down
Loading