Skip to content

Otros documentos tributarios relacionados #40

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
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,7 +37,10 @@
import io.github.project.openubl.xmlbuilderlib.models.output.standard.note.debitNote.DebitNoteOutputModel;

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

Expand Down Expand Up @@ -142,6 +145,19 @@ private static void enrichDocument(DocumentInputModel input, DocumentOutputModel
: Collections.emptyList()
);

// Otros documentos tributarios relacionados
builder.withOtrosDocumentosTributariosRelacionados(input.getOtrosDocumentosTributariosRelacionados() != null ?
input.getOtrosDocumentosTributariosRelacionados().stream()
.map(docInput -> {
DocumentoTributarioRelacionadoOutputModel docOutput = new DocumentoTributarioRelacionadoOutputModel();
docOutput.setSerieNumero(docInput.getSerieNumero());
docOutput.setTipoDocumento(Catalog.valueOfCode(Catalog12.class, docInput.getTipoDocumento()).orElseThrow(Catalog.invalidCatalogValue));
return docOutput;
})
.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
Expand Up @@ -22,6 +22,11 @@ public enum Catalog12 implements Catalog {
BOLETA_DE_VENTA_EMITIDA_POR_ANTICIPOS("03"),
TICKET_DE_SALIDA("04"),
CODIGO_SCOP("05"),
FACTURA_ELECTRONICA_REMITENTE("06"),
GUIA_DE_REMISION_REMITENTE("07"),
DECLARACION_DE_SALIDA_DEL_DEPOSITO_FRANCO("08"),
DECLARACION_SIMPLIFICADA_DE_IMPORTACION("09"),
LIQUIDACION_DE_COMPRA_EMITIDA_POR_ANTICIPOS("10"),
OTROS("99");

private final String code;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* 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;

public enum Catalog12_Doc_Trib_Relacionado_CreditNote implements Catalog {
FACTURA_EMITIDA_PARA_CORREGIR_ERROR_EN_EL_RUC("01"),
TICKET_DE_SALIDA("04"),
CODIGO_SCOP("05"),
OTROS("99");

private final String code;

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

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* 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;

public enum Catalog12_Doc_Trib_Relacionado_DebitNote implements Catalog {
TICKET_DE_SALIDA("04"),
CODIGO_SCOP("05"),
OTROS("99");

private final String code;

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

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* 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;

public enum Catalog12_Doc_Trib_Relacionado_Invoice implements Catalog {
TICKET_DE_SALIDA("04"),
CODIGO_SCOP("05"),
FACTURA_ELECTRONICA_REMITENTE("06"),
GUIA_DE_REMISION_REMITENTE("07"),
DECLARACION_DE_SALIDA_DEL_DEPOSITO_FRANCO("08"),
DECLARACION_SIMPLIFICADA_DE_IMPORTACION("09"),
OTROS("99");

private final String code;

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

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import io.github.project.openubl.xmlbuilderlib.models.input.constraints.HighLevelGroupValidation;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import java.math.BigDecimal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

import javax.validation.constraints.NotBlank;

public class DocumentoTributarioRelacionadoInputModel {
public abstract class DocTribRelacionadoInputModel {

@NotBlank
private String serieNumero;
protected String serieNumero;

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

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public abstract class DocumentInputModel {
@Valid
private List<GuiaRemisionRelacionadaInputModel> guiasRemisionRelacionadas;

public abstract List<? extends DocTribRelacionadoInputModel> getOtrosDocumentosTributariosRelacionados();

public String getSerie() {
return serie;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
package io.github.project.openubl.xmlbuilderlib.models.input.standard.invoice;

import io.github.project.openubl.xmlbuilderlib.models.input.standard.DocumentoTributarioRelacionadoInputModel;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.DocTribRelacionadoInputModel;

import javax.validation.constraints.NotBlank;

public class AnticipoInputModel extends DocumentoTributarioRelacionadoInputModel {
public class AnticipoInputModel extends DocTribRelacionadoInputModel {

@NotBlank
private String ruc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog53;
import io.github.project.openubl.xmlbuilderlib.models.catalogs.constraints.CatalogConstraint;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.DocumentoTributarioRelacionadoInputModel;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.DocTribRelacionadoInputModel;

import java.math.BigDecimal;

public class CargoDescuentoInputModel extends DocumentoTributarioRelacionadoInputModel {
public class CargoDescuentoInputModel extends DocTribRelacionadoInputModel {

@CatalogConstraint(value = Catalog53.class)
private String tipo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog54;
import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog59;
import io.github.project.openubl.xmlbuilderlib.models.catalogs.constraints.CatalogConstraint;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.DocumentoTributarioRelacionadoInputModel;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.DocTribRelacionadoInputModel;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

public class DetraccionRelacionadaInputModel extends DocumentoTributarioRelacionadoInputModel {
public class DetraccionRelacionadaInputModel extends DocTribRelacionadoInputModel {

@CatalogConstraint(value = Catalog59.class)
private String medioDePago;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* 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.input.standard.invoice;

import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog12_Doc_Trib_Relacionado_Invoice;
import io.github.project.openubl.xmlbuilderlib.models.catalogs.constraints.CatalogConstraint;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.DocTribRelacionadoInputModel;

public class DocTribRelacionadoInputModel_Invoice extends DocTribRelacionadoInputModel {

@CatalogConstraint(value = Catalog12_Doc_Trib_Relacionado_Invoice.class)
protected String tipoDocumento;

public String getTipoDocumento() {
return tipoDocumento;
}

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

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

private Builder() {
}

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

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

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

public DocTribRelacionadoInputModel_Invoice build() {
DocTribRelacionadoInputModel_Invoice docTribRelacionadoInputModel_Invoice = new DocTribRelacionadoInputModel_Invoice();
docTribRelacionadoInputModel_Invoice.setSerieNumero(serieNumero);
docTribRelacionadoInputModel_Invoice.setTipoDocumento(tipoDocumento);
return docTribRelacionadoInputModel_Invoice;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public class InvoiceInputModel extends DocumentInputModel {
@CuotaDePagoInputModel_Porcentaje100CollectionConstraint(groups = HighLevelGroupValidation.class)
private List<CuotaDePagoInputModel> cuotasDePago;

@Valid
private List<DocTribRelacionadoInputModel_Invoice> otrosDocumentosTributariosRelacionados;

public List<CuotaDePagoInputModel> getCuotasDePago() {
return cuotasDePago;
}
Expand All @@ -43,6 +46,15 @@ public void setCuotasDePago(List<CuotaDePagoInputModel> cuotasDePago) {
this.cuotasDePago = cuotasDePago;
}

@Override
public List<DocTribRelacionadoInputModel_Invoice> getOtrosDocumentosTributariosRelacionados() {
return otrosDocumentosTributariosRelacionados;
}

public void setOtrosDocumentosTributariosRelacionados(List<DocTribRelacionadoInputModel_Invoice> otrosDocumentosTributariosRelacionados) {
this.otrosDocumentosTributariosRelacionados = otrosDocumentosTributariosRelacionados;
}

public static final class Builder {
protected String serie;
private Integer numero;
Expand All @@ -53,6 +65,7 @@ public static final class Builder {
private List<DocumentLineInputModel> detalle;
private List<CuotaDePagoInputModel> cuotasDePago;
private List<GuiaRemisionRelacionadaInputModel> guiasRemisionRelacionadas;
private List<DocTribRelacionadoInputModel_Invoice> otrosDocumentosTributariosRelacionados;

private Builder() {
}
Expand Down Expand Up @@ -106,6 +119,11 @@ public Builder withGuiasRemisionRelacionadas(List<GuiaRemisionRelacionadaInputMo
return this;
}

public Builder withOtrosDocumentosTributariosRelacionados(List<DocTribRelacionadoInputModel_Invoice> otrosDocumentosTributariosRelacionados) {
this.otrosDocumentosTributariosRelacionados = otrosDocumentosTributariosRelacionados;
return this;
}

public InvoiceInputModel build() {
InvoiceInputModel invoiceInputModel = new InvoiceInputModel();
invoiceInputModel.setSerie(serie);
Expand All @@ -117,6 +135,7 @@ public InvoiceInputModel build() {
invoiceInputModel.setDetalle(detalle);
invoiceInputModel.setCuotasDePago(cuotasDePago);
invoiceInputModel.setGuiasRemisionRelacionadas(guiasRemisionRelacionadas);
invoiceInputModel.setOtrosDocumentosTributariosRelacionados(otrosDocumentosTributariosRelacionados);
return invoiceInputModel;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

import io.github.project.openubl.xmlbuilderlib.models.catalogs.Catalog53;
import io.github.project.openubl.xmlbuilderlib.models.catalogs.constraints.CatalogConstraint;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.DocumentoTributarioRelacionadoInputModel;
import io.github.project.openubl.xmlbuilderlib.models.input.standard.DocTribRelacionadoInputModel;

import java.math.BigDecimal;

public class PercepcionRelacionadaInputModel extends DocumentoTributarioRelacionadoInputModel {
public class PercepcionRelacionadaInputModel extends DocTribRelacionadoInputModel {

@CatalogConstraint(value = Catalog53.class)
private String tipo;
Expand Down
Loading