lines;
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/jaxb/models/XMLVoidedDocumentsLine.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.jaxb.models;
2 |
3 | import lombok.Data;
4 | import lombok.NoArgsConstructor;
5 |
6 | import jakarta.xml.bind.annotation.XmlAccessType;
7 | import jakarta.xml.bind.annotation.XmlAccessorType;
8 | import jakarta.xml.bind.annotation.XmlElement;
9 | import jakarta.xml.bind.annotation.XmlType;
10 |
11 | @XmlType(name = "VoidedDocumentsLine")
12 | @XmlAccessorType(XmlAccessType.NONE)
13 | @Data
14 | @NoArgsConstructor
15 | public class XMLVoidedDocumentsLine {
16 |
17 | @XmlElement(name = "DocumentTypeCode", namespace = XMLConstants.CBC)
18 | private String documentTypeCode;
19 |
20 | @XmlElement(name = "DocumentSerialID", namespace = XMLConstants.SAC)
21 | private String documentSerialID;
22 |
23 | @XmlElement(name = "DocumentNumberID", namespace = XMLConstants.SAC)
24 | private Integer documentNumberID;
25 |
26 | @XmlElement(name = "VoidReasonDescription", namespace = XMLConstants.SAC)
27 | private String voidReasonDescription;
28 | }
29 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/jaxb/models/package-info.java:
--------------------------------------------------------------------------------
1 | @XmlSchema(
2 | xmlns = {
3 | @XmlNs(prefix = "cbc", namespaceURI = XMLConstants.CBC),
4 | @XmlNs(prefix = "cac", namespaceURI = XMLConstants.CAC),
5 | @XmlNs(prefix = "sac", namespaceURI = XMLConstants.SAC),
6 | @XmlNs(prefix = "ext", namespaceURI = XMLConstants.EXT)
7 | },
8 | elementFormDefault = XmlNsForm.QUALIFIED
9 | )
10 | package io.github.project.openubl.xbuilder.content.jaxb.models;
11 |
12 | import jakarta.xml.bind.annotation.XmlNs;
13 | import jakarta.xml.bind.annotation.XmlNsForm;
14 | import jakarta.xml.bind.annotation.XmlSchema;
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/common/Cliente.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.common;
2 |
3 | import io.github.project.openubl.xbuilder.content.catalogs.Catalog6;
4 | import io.swagger.v3.oas.annotations.media.Schema;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Builder;
7 | import lombok.Data;
8 | import lombok.NoArgsConstructor;
9 |
10 | /**
11 | * Cliente de la operación.
12 | *
13 | * @author Carlos Feria
14 | */
15 | @Data
16 | @Builder
17 | @NoArgsConstructor
18 | @AllArgsConstructor
19 | public class Cliente {
20 |
21 | /**
22 | * Tipo de documento de identidad del cliente.
23 | *
24 | * Catalogo 06.
25 | *
26 | * Valores válidos: {@link Catalog6}
27 | */
28 | @Schema(description = "Catalogo 06", requiredMode = Schema.RequiredMode.REQUIRED)
29 | private String tipoDocumentoIdentidad;
30 |
31 | /**
32 | * Número de documento de identidad del cliente.
33 | */
34 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
35 | private String numeroDocumentoIdentidad;
36 |
37 | /**
38 | * Nombre del cliente. Si el cliente es personal natural entonces
39 | * es el nombre y apellidos de la persona; si el cliente es una persona jurídica
40 | * entonces es la razón social de la empresa.
41 | */
42 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
43 | private String nombre;
44 |
45 | /**
46 | * Dirección del cliente
47 | */
48 | private Direccion direccion;
49 |
50 | /**
51 | * Datos de contacto del cliente
52 | */
53 | private Contacto contacto;
54 | }
55 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/common/Contacto.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.common;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | /**
10 | * Datos de contacto
11 | *
12 | * @author Carlos Feria
13 | */
14 | @Data
15 | @Builder
16 | @NoArgsConstructor
17 | @AllArgsConstructor
18 | public class Contacto {
19 |
20 | /**
21 | * Número telefónico
22 | */
23 | @Schema(description = "Número telefónico")
24 | private String telefono;
25 |
26 | /**
27 | * Correo electrónico
28 | */
29 | @Schema(description = "Correo electrónico")
30 | private String email;
31 | }
32 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/common/Document.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.common;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import lombok.experimental.SuperBuilder;
7 |
8 | import java.time.LocalDate;
9 |
10 | @Data
11 | @SuperBuilder
12 | @NoArgsConstructor
13 | public abstract class Document {
14 |
15 | /**
16 | * Moneda en la que se emite el comprobante
17 | */
18 | @Schema(minLength = 3, maxLength = 3)
19 | private String moneda;
20 |
21 | /**
22 | * Fecha de emisión del comprobante. Ejemplo 2022-12-25 (YYYY-MM-SS)
23 | */
24 | @Schema(description = "Format: \"YYYY-MM-SS\". Ejemplo: 2022-12-25", pattern = "^\\d{4}-\\d{2}-\\d{2}$")
25 | private LocalDate fechaEmision;
26 |
27 | /**
28 | * Proveedor del bien o servicio
29 | */
30 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
31 | private Proveedor proveedor;
32 |
33 | /**
34 | * Persona que firma electrónicamente el comprobante. Si es NULL los datos del proveedor son usados.
35 | */
36 | @Schema(description = "Persona que firma el comprobante. Si NULL los datos del proveedor son usados.")
37 | private Firmante firmante;
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/common/Firmante.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.common;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | /**
10 | * Persona que firma electrónicamente el documento
11 | *
12 | * @author Carlos Feria
13 | */
14 | @Data
15 | @Builder
16 | @NoArgsConstructor
17 | @AllArgsConstructor
18 | public class Firmante {
19 |
20 | /**
21 | * Número de RUC de la persona
22 | */
23 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minLength = 11, maxLength = 11, pattern = "[0-9]+")
24 | private String ruc;
25 |
26 | /**
27 | * Razón social de la persona
28 | */
29 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
30 | private String razonSocial;
31 | }
32 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/common/Proveedor.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.common;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | /**
10 | * Persona que vende o presta un servicio
11 | *
12 | * @author Carlos Feria
13 | */
14 | @Data
15 | @Builder
16 | @NoArgsConstructor
17 | @AllArgsConstructor
18 | public class Proveedor {
19 |
20 | /**
21 | * Número de RUC de la persona jurídica
22 | */
23 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minLength = 11, maxLength = 11, pattern = "[0-9]+")
24 | private String ruc;
25 |
26 | /**
27 | * Nombre comercial de la persona jurídica
28 | */
29 | private String nombreComercial;
30 |
31 | /**
32 | * Razón social de la persona jurídica
33 | */
34 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
35 | private String razonSocial;
36 |
37 | /**
38 | * Dirección de la persona jurídica
39 | */
40 | private Direccion direccion;
41 |
42 | /**
43 | * Contacto de la persona jurídica
44 | */
45 | private Contacto contacto;
46 | }
47 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/common/TipoCambio.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.common;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.math.BigDecimal;
9 | import java.time.LocalDate;
10 |
11 | @Data
12 | @Builder
13 | @NoArgsConstructor
14 | @AllArgsConstructor
15 | public class TipoCambio {
16 |
17 | private LocalDate fecha;
18 | private BigDecimal valor;
19 | }
20 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/BaseDocumentoTributarioRelacionado.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.general;
2 |
3 | import lombok.Data;
4 | import lombok.experimental.SuperBuilder;
5 |
6 | @Data
7 | @SuperBuilder
8 | public abstract class BaseDocumentoTributarioRelacionado {
9 |
10 | private String serieNumero;
11 | }
12 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/CargoDescuento.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.general;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import lombok.experimental.SuperBuilder;
7 |
8 | import java.math.BigDecimal;
9 |
10 | @Data
11 | @SuperBuilder
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | public class CargoDescuento {
15 |
16 | private String serieNumero;
17 | private String tipo;
18 | private BigDecimal monto;
19 | private BigDecimal porcentaje;
20 | }
21 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/CreditNote.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.general;
2 |
3 | import lombok.Data;
4 | import lombok.EqualsAndHashCode;
5 | import lombok.NoArgsConstructor;
6 | import lombok.experimental.SuperBuilder;
7 | import lombok.extern.jackson.Jacksonized;
8 |
9 | /**
10 | * Clase base para CreditNote y DebitNote.
11 | *
12 | * @author Carlos Feria
13 | */
14 | @Jacksonized
15 | @Data
16 | @SuperBuilder
17 | @NoArgsConstructor
18 | @EqualsAndHashCode(callSuper = true)
19 | public class CreditNote extends Note {
20 | }
21 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/CuotaDePago.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.general;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | import java.math.BigDecimal;
10 | import java.time.LocalDate;
11 |
12 | /**
13 | * Cuota de pago para Invoice
14 | *
15 | * @author Carlos Feria
16 | */
17 | @Data
18 | @Builder
19 | @NoArgsConstructor
20 | @AllArgsConstructor
21 | public class CuotaDePago {
22 |
23 | /**
24 | * Importe de la cuota
25 | */
26 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minimum = "0", exclusiveMinimum = true)
27 | private BigDecimal importe;
28 |
29 | /**
30 | * Fecha de pago de la cuota
31 | */
32 | @Schema(description = "Ejemplo 2022-12-25", requiredMode = Schema.RequiredMode.REQUIRED, pattern = "^\\d{4}-\\d{2}-\\d{2}$")
33 | private LocalDate fechaPago;
34 | }
35 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/DebitNote.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.general;
2 |
3 | import lombok.Data;
4 | import lombok.EqualsAndHashCode;
5 | import lombok.NoArgsConstructor;
6 | import lombok.experimental.SuperBuilder;
7 | import lombok.extern.jackson.Jacksonized;
8 |
9 | @Jacksonized
10 | @Data
11 | @SuperBuilder
12 | @NoArgsConstructor
13 | @EqualsAndHashCode(callSuper = true)
14 | public class DebitNote extends Note {
15 | }
16 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/Descuento.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.general;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | import java.math.BigDecimal;
10 |
11 | @Data
12 | @Builder
13 | @NoArgsConstructor
14 | @AllArgsConstructor
15 | public class Descuento {
16 |
17 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Catalogo 53")
18 | private String tipoDescuento;
19 |
20 | @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED)
21 | private BigDecimal factor;
22 |
23 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
24 | private BigDecimal monto;
25 |
26 | @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED)
27 | private BigDecimal montoBase;
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/Detraccion.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.general;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | import java.math.BigDecimal;
10 |
11 | /**
12 | * Detracción asociada a un Invoice
13 | *
14 | * @author Carlos Feria
15 | */
16 | @Data
17 | @Builder
18 | @NoArgsConstructor
19 | @AllArgsConstructor
20 | public class Detraccion {
21 |
22 | /**
23 | * Catalog59
24 | **/
25 | @Schema(description = "Catalogo 59", requiredMode = Schema.RequiredMode.REQUIRED)
26 | private String medioDePago;
27 |
28 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
29 | private String cuentaBancaria;
30 |
31 | /**
32 | * Catalog54
33 | **/
34 | @Schema(description = "Catalog 54", requiredMode = Schema.RequiredMode.REQUIRED)
35 | private String tipoBienDetraido;
36 |
37 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minimum = "0", maximum = "1", exclusiveMinimum = true)
38 | private BigDecimal porcentaje;
39 |
40 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minimum = "0", exclusiveMinimum = true)
41 | private BigDecimal monto;
42 | }
43 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/DocumentoRelacionado.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.general;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | @Data
10 | @Builder
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | public class DocumentoRelacionado {
14 |
15 | @Schema(description = "Catalog 12", requiredMode = Schema.RequiredMode.REQUIRED)
16 | private String tipoDocumento;
17 |
18 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
19 | private String serieNumero;
20 | }
21 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/FormaDePago.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.general;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 | import lombok.Singular;
8 | import lombok.experimental.SuperBuilder;
9 |
10 | import java.math.BigDecimal;
11 | import java.util.List;
12 |
13 | @Data
14 | @SuperBuilder
15 | @NoArgsConstructor
16 | @AllArgsConstructor
17 | public class FormaDePago {
18 |
19 | @Schema(description = "CREDITO o CONTADO", requiredMode = Schema.RequiredMode.REQUIRED)
20 | private String tipo;
21 |
22 | @Schema(description = "Monto total de pago", requiredMode = Schema.RequiredMode.REQUIRED, minimum = "0")
23 | private BigDecimal total;
24 |
25 | @Schema(description = "Cuotas de pago")
26 | @Singular
27 | private List cuotas;
28 | }
29 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/Guia.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.general;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | @Data
10 | @Builder
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | public class Guia {
14 |
15 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
16 | private String serieNumero;
17 |
18 | /**
19 | * Tipo de documento Guia.
20 | *
21 | * Catalogo 01.
22 | *
23 | * Valores válidos: "09", "31"
24 | */
25 | @Schema(description = "Catalogo 01", requiredMode = Schema.RequiredMode.REQUIRED)
26 | private String tipoDocumento;
27 | }
28 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/Percepcion.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.general;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | import java.math.BigDecimal;
10 |
11 | @Data
12 | @Builder
13 | @NoArgsConstructor
14 | @AllArgsConstructor
15 | public class Percepcion {
16 |
17 | /**
18 | * Catalog53
19 | */
20 | @Schema(description = "Catalog 53", requiredMode = Schema.RequiredMode.REQUIRED)
21 | private String tipo;
22 |
23 | private BigDecimal montoBase; // importeSinImpuestos
24 | private BigDecimal porcentaje; // Establecido por el "tipo"
25 | private BigDecimal monto; // montoBase * porcentaje
26 | private BigDecimal montoTotal; // montoBase + monto
27 | }
28 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/TotalImporte.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.general;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import lombok.experimental.SuperBuilder;
7 |
8 | import java.math.BigDecimal;
9 |
10 | @Data
11 | @SuperBuilder
12 | @NoArgsConstructor
13 | public abstract class TotalImporte {
14 |
15 | @Schema(minimum = "0", requiredMode = Schema.RequiredMode.REQUIRED)
16 | private BigDecimal importe;
17 |
18 | @Schema(minimum = "0", requiredMode = Schema.RequiredMode.REQUIRED)
19 | private BigDecimal importeSinImpuestos;
20 |
21 | @Schema(minimum = "0", requiredMode = Schema.RequiredMode.REQUIRED)
22 | private BigDecimal importeConImpuestos;
23 | }
24 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/TotalImporteInvoice.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.general;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.Data;
5 | import lombok.EqualsAndHashCode;
6 | import lombok.NoArgsConstructor;
7 | import lombok.ToString;
8 | import lombok.experimental.SuperBuilder;
9 |
10 | import java.math.BigDecimal;
11 |
12 | @Data
13 | @SuperBuilder
14 | @NoArgsConstructor
15 | @EqualsAndHashCode(callSuper = true)
16 | @ToString(callSuper = true)
17 | public class TotalImporteInvoice extends TotalImporte {
18 |
19 | @Schema(minimum = "0", requiredMode = Schema.RequiredMode.REQUIRED)
20 | private BigDecimal anticipos;
21 |
22 | @Schema(minimum = "0", requiredMode = Schema.RequiredMode.REQUIRED)
23 | private BigDecimal descuentos;
24 | }
25 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/general/TotalImporteNote.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.general;
2 |
3 | import lombok.Data;
4 | import lombok.EqualsAndHashCode;
5 | import lombok.NoArgsConstructor;
6 | import lombok.ToString;
7 | import lombok.experimental.SuperBuilder;
8 |
9 | @Data
10 | @SuperBuilder
11 | @NoArgsConstructor
12 | @EqualsAndHashCode(callSuper = true)
13 | @ToString(callSuper = true)
14 | public class TotalImporteNote extends TotalImporte {
15 | }
16 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/guia/DespatchAdviceItem.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.guia;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 | import lombok.extern.jackson.Jacksonized;
8 |
9 | import java.math.BigDecimal;
10 |
11 | @Jacksonized
12 | @Data
13 | @Builder
14 | @NoArgsConstructor
15 | @AllArgsConstructor
16 | public class DespatchAdviceItem {
17 | private String unidadMedida;
18 | private BigDecimal cantidad;
19 |
20 | private String descripcion;
21 | private String codigo;
22 | private String codigoSunat;
23 | }
24 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/guia/Destinatario.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.guia;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | @Data
10 | @Builder
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | public class Destinatario {
14 |
15 | @Schema(description = "Catalogo 06", requiredMode = Schema.RequiredMode.REQUIRED)
16 | private String tipoDocumentoIdentidad;
17 |
18 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
19 | private String numeroDocumentoIdentidad;
20 |
21 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
22 | private String nombre;
23 | }
24 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/guia/Destino.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.guia;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | @Data
9 | @Builder
10 | @NoArgsConstructor
11 | @AllArgsConstructor
12 | public class Destino {
13 | private String ubigeo;
14 | private String direccion;
15 | }
16 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/guia/DocumentoBaja.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.guia;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | @Data
10 | @Builder
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | public class DocumentoBaja {
14 |
15 | @Schema(description = "Catalog 01", requiredMode = Schema.RequiredMode.REQUIRED)
16 | private String tipoDocumento;
17 |
18 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
19 | private String serieNumero;
20 | }
21 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/guia/DocumentoRelacionado.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.guia;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | @Data
10 | @Builder
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | public class DocumentoRelacionado {
14 |
15 | @Schema(description = "Catalog 21", requiredMode = Schema.RequiredMode.REQUIRED)
16 | private String tipoDocumento;
17 |
18 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
19 | private String serieNumero;
20 | }
21 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/guia/Envio.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.guia;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | import java.math.BigDecimal;
10 | import java.time.LocalDate;
11 |
12 | @Data
13 | @Builder
14 | @NoArgsConstructor
15 | @AllArgsConstructor
16 | public class Envio {
17 |
18 | @Schema(description = "Catalog 20", requiredMode = Schema.RequiredMode.REQUIRED)
19 | private String tipoTraslado;
20 | private String motivoTraslado;
21 |
22 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
23 | private BigDecimal pesoTotal;
24 |
25 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
26 | private String pesoTotalUnidadMedida;
27 |
28 | private Integer numeroDeBultos;
29 | private boolean transbordoProgramado;
30 |
31 | @Schema(description = "Catalog 18", requiredMode = Schema.RequiredMode.REQUIRED)
32 | private String tipoModalidadTraslado;
33 |
34 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
35 | private LocalDate fechaTraslado;
36 |
37 | private String numeroDeContenedor;
38 | private String codigoDePuerto;
39 |
40 | @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED)
41 | private Transportista transportista;
42 |
43 | @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED)
44 | private Partida partida;
45 |
46 | @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED)
47 | private Destino destino;
48 | }
49 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/guia/Partida.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.guia;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | @Data
9 | @Builder
10 | @NoArgsConstructor
11 | @AllArgsConstructor
12 | public class Partida {
13 | private String ubigeo;
14 | private String direccion;
15 | }
16 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/guia/Proveedor.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.guia;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | @Data
10 | @Builder
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | public class Proveedor {
14 |
15 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minLength = 11, maxLength = 11, pattern = "[0-9]+")
16 | private String ruc;
17 |
18 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
19 | private String razonSocial;
20 | }
21 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/guia/Remitente.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.guia;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | @Data
10 | @Builder
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | public class Remitente {
14 |
15 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minLength = 11, maxLength = 11, pattern = "[0-9]+")
16 | private String ruc;
17 |
18 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
19 | private String razonSocial;
20 | }
21 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/standard/guia/Transportista.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.standard.guia;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | @Data
10 | @Builder
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | public class Transportista {
14 |
15 | @Schema(description = "Catalogo 06", requiredMode = Schema.RequiredMode.REQUIRED)
16 | private String tipoDocumentoIdentidad;
17 |
18 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
19 | private String numeroDocumentoIdentidad;
20 |
21 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
22 | private String nombre;
23 |
24 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
25 | private String placaDelVehiculo;
26 |
27 | @Schema(description = "Catalogo 06", requiredMode = Schema.RequiredMode.REQUIRED)
28 | private String choferTipoDocumentoIdentidad;
29 |
30 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
31 | private String choferNumeroDocumentoIdentidad;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/sunat/SunatDocument.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.sunat;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.common.Document;
4 | import io.swagger.v3.oas.annotations.media.Schema;
5 | import lombok.Data;
6 | import lombok.EqualsAndHashCode;
7 | import lombok.NoArgsConstructor;
8 | import lombok.ToString;
9 | import lombok.experimental.SuperBuilder;
10 |
11 | import java.time.LocalDate;
12 |
13 | @Data
14 | @SuperBuilder
15 | @NoArgsConstructor
16 | @EqualsAndHashCode(callSuper = true)
17 | @ToString(callSuper = true)
18 | public class SunatDocument extends Document {
19 |
20 | /**
21 | * Numero de comprobante emitido para la fecha de emision dada
22 | */
23 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minimum = "1", maximum = "99999999")
24 | private Integer numero;
25 |
26 | /**
27 | * Fecha de emisión de los comprobantes dados de baja. Ejemplo 2022-12-25 (YYYY-MM-SS)
28 | */
29 | @Schema(description = "Format: \"YYYY-MM-SS\". Ejemplo: 2022-12-25", pattern = "^\\d{4}-\\d{2}-\\d{2}$")
30 | private LocalDate fechaEmisionComprobantes;
31 | }
32 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/sunat/baja/VoidedDocuments.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.sunat.baja;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.sunat.SunatDocument;
4 | import io.swagger.v3.oas.annotations.media.ArraySchema;
5 | import io.swagger.v3.oas.annotations.media.Schema;
6 | import lombok.Data;
7 | import lombok.EqualsAndHashCode;
8 | import lombok.NoArgsConstructor;
9 | import lombok.Singular;
10 | import lombok.ToString;
11 | import lombok.experimental.SuperBuilder;
12 | import lombok.extern.jackson.Jacksonized;
13 |
14 | import java.util.List;
15 |
16 | @Jacksonized
17 | @Data
18 | @SuperBuilder
19 | @NoArgsConstructor
20 | @EqualsAndHashCode(callSuper = true)
21 | @ToString(callSuper = true)
22 | public class VoidedDocuments extends SunatDocument {
23 |
24 | /**
25 | * Lista de comprobantes a dar de baja
26 | */
27 | @Singular
28 | @ArraySchema(minItems = 1, schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
29 | private List comprobantes;
30 | }
31 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/sunat/baja/VoidedDocumentsItem.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.sunat.baja;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | @Data
10 | @Builder
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | public class VoidedDocumentsItem {
14 | /**
15 | * Serie del comprobante
16 | */
17 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
18 | private String serie;
19 |
20 | /**
21 | * Número del comprobante
22 | */
23 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minimum = "1", maximum = "99999999")
24 | private Integer numero;
25 |
26 | @Schema(description = "Catalogo 01")
27 | private String tipoComprobante;
28 |
29 | @Schema(description = "Descripción de la razón de baja")
30 | private String descripcionSustento;
31 | }
32 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/sunat/percepcionretencion/BasePercepcionRetencion.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.sunat.percepcionretencion;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.common.Cliente;
4 | import io.github.project.openubl.xbuilder.content.models.common.Document;
5 | import io.swagger.v3.oas.annotations.media.Schema;
6 | import lombok.Data;
7 | import lombok.EqualsAndHashCode;
8 | import lombok.NoArgsConstructor;
9 | import lombok.experimental.SuperBuilder;
10 |
11 | import java.math.BigDecimal;
12 |
13 | @Data
14 | @SuperBuilder
15 | @NoArgsConstructor
16 | @EqualsAndHashCode(callSuper = true)
17 | public abstract class BasePercepcionRetencion extends Document {
18 |
19 | /**
20 | * Número del comprobante
21 | */
22 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minimum = "1", maximum = "99999999")
23 | private Integer numero;
24 |
25 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minimum = "0", maximum = "100", exclusiveMinimum = true)
26 | private BigDecimal tipoRegimenPorcentaje;
27 |
28 | private String observacion;
29 |
30 | /**
31 | * Cliente
32 | */
33 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
34 | private Cliente cliente;
35 |
36 | private PercepcionRetencionOperacion operacion;
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/sunat/percepcionretencion/ComprobanteAfectado.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.sunat.percepcionretencion;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | import java.math.BigDecimal;
10 | import java.time.LocalDate;
11 |
12 | @Data
13 | @Builder
14 | @NoArgsConstructor
15 | @AllArgsConstructor
16 | public class ComprobanteAfectado {
17 | private String moneda;
18 |
19 | @Schema(description = "Catalogo 01")
20 | private String tipoComprobante;
21 |
22 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
23 | private String serieNumero;
24 |
25 | @Schema(description = "Format: \"YYYY-MM-SS\". Ejemplo: 2022-12-25", pattern = "^\\d{4}-\\d{2}-\\d{2}$")
26 | private LocalDate fechaEmision;
27 |
28 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
29 | private BigDecimal importeTotal;
30 | }
31 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/sunat/percepcionretencion/PercepcionRetencionOperacion.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.sunat.percepcionretencion;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.common.TipoCambio;
4 | import io.swagger.v3.oas.annotations.media.Schema;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Builder;
7 | import lombok.Data;
8 | import lombok.NoArgsConstructor;
9 |
10 | import java.math.BigDecimal;
11 | import java.time.LocalDate;
12 |
13 | @Data
14 | @Builder
15 | @NoArgsConstructor
16 | @AllArgsConstructor
17 | public class PercepcionRetencionOperacion {
18 |
19 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Numero de cobro o pago")
20 | private Integer numeroOperacion;
21 |
22 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Fecha en la que se realiza el cobro o pago")
23 | private LocalDate fechaOperacion;
24 |
25 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Importe del cobro o pago")
26 | private BigDecimal importeOperacion;
27 |
28 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
29 | private ComprobanteAfectado comprobante;
30 |
31 | private TipoCambio tipoCambio;
32 | }
33 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/sunat/percepcionretencion/Perception.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.sunat.percepcionretencion;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.Data;
5 | import lombok.EqualsAndHashCode;
6 | import lombok.NoArgsConstructor;
7 | import lombok.ToString;
8 | import lombok.experimental.SuperBuilder;
9 | import lombok.extern.jackson.Jacksonized;
10 |
11 | import java.math.BigDecimal;
12 |
13 | @Jacksonized
14 | @Data
15 | @SuperBuilder
16 | @NoArgsConstructor
17 | @EqualsAndHashCode(callSuper = true)
18 | @ToString(callSuper = true)
19 | public class Perception extends BasePercepcionRetencion {
20 | /**
21 | * Serie del comprobante
22 | */
23 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minLength = 4, pattern = "^[P|p].*$")
24 | private String serie;
25 |
26 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Catalog 22")
27 | private String tipoRegimen;
28 |
29 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minimum = "0")
30 | private BigDecimal importeTotalPercibido;
31 |
32 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minimum = "0")
33 | private BigDecimal importeTotalCobrado;
34 | }
35 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/sunat/percepcionretencion/Retention.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.sunat.percepcionretencion;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.Data;
5 | import lombok.EqualsAndHashCode;
6 | import lombok.NoArgsConstructor;
7 | import lombok.ToString;
8 | import lombok.experimental.SuperBuilder;
9 | import lombok.extern.jackson.Jacksonized;
10 |
11 | import java.math.BigDecimal;
12 |
13 | @Jacksonized
14 | @Data
15 | @SuperBuilder
16 | @NoArgsConstructor
17 | @EqualsAndHashCode(callSuper = true)
18 | @ToString(callSuper = true)
19 | public class Retention extends BasePercepcionRetencion {
20 | /**
21 | * Serie del comprobante
22 | */
23 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minLength = 4, pattern = "^[R|r].*$")
24 | private String serie;
25 |
26 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Catalog 23")
27 | private String tipoRegimen;
28 |
29 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minimum = "0")
30 | private BigDecimal importeTotalRetenido;
31 |
32 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, minimum = "0")
33 | private BigDecimal importeTotalPagado;
34 | }
35 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/sunat/resumen/Comprobante.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.sunat.resumen;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.common.Cliente;
4 | import io.swagger.v3.oas.annotations.media.Schema;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Builder;
7 | import lombok.Data;
8 | import lombok.NoArgsConstructor;
9 |
10 | @Data
11 | @Builder
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | public class Comprobante {
15 |
16 | @Schema(requiredMode = Schema.RequiredMode.AUTO, description = "Moneda del comprobante declarado")
17 | private String moneda;
18 |
19 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Catalogo 01")
20 | private String tipoComprobante;
21 |
22 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
23 | private String serieNumero;
24 |
25 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
26 | private Cliente cliente;
27 |
28 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
29 | private ComprobanteValorVenta valorVenta;
30 |
31 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
32 | private ComprobanteImpuestos impuestos;
33 |
34 | private ComprobanteAfectado comprobanteAfectado;
35 | }
36 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/sunat/resumen/ComprobanteAfectado.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.sunat.resumen;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | @Data
10 | @Builder
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | public class ComprobanteAfectado {
14 |
15 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Catalogo 01")
16 | private String tipoComprobante;
17 |
18 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Comprobante afectado")
19 | private String serieNumero;
20 | }
21 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/sunat/resumen/ComprobanteImpuestos.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.sunat.resumen;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | import java.math.BigDecimal;
10 |
11 | @Data
12 | @Builder
13 | @NoArgsConstructor
14 | @AllArgsConstructor
15 | public class ComprobanteImpuestos {
16 |
17 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "IGV del comprobante")
18 | private BigDecimal igv;
19 |
20 | @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "ICB del comprobante")
21 | private BigDecimal icb;
22 | }
23 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/sunat/resumen/ComprobanteValorVenta.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.sunat.resumen;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | import java.math.BigDecimal;
10 |
11 | @Data
12 | @Builder
13 | @NoArgsConstructor
14 | @AllArgsConstructor
15 | public class ComprobanteValorVenta {
16 |
17 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
18 | private BigDecimal importeTotal;
19 | private BigDecimal otrosCargos;
20 | private BigDecimal gravado;
21 | private BigDecimal exonerado;
22 | private BigDecimal inafecto;
23 | private BigDecimal gratuito;
24 | }
25 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/sunat/resumen/SummaryDocuments.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.sunat.resumen;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.sunat.SunatDocument;
4 | import io.swagger.v3.oas.annotations.media.ArraySchema;
5 | import io.swagger.v3.oas.annotations.media.Schema;
6 | import lombok.Data;
7 | import lombok.EqualsAndHashCode;
8 | import lombok.NoArgsConstructor;
9 | import lombok.Singular;
10 | import lombok.ToString;
11 | import lombok.experimental.SuperBuilder;
12 | import lombok.extern.jackson.Jacksonized;
13 |
14 | import java.util.List;
15 |
16 | @Jacksonized
17 | @Data
18 | @SuperBuilder
19 | @NoArgsConstructor
20 | @EqualsAndHashCode(callSuper = true)
21 | @ToString(callSuper = true)
22 | public class SummaryDocuments extends SunatDocument {
23 |
24 | /**
25 | * Lista de comprobantes
26 | */
27 | @Singular
28 | @ArraySchema(minItems = 1, schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
29 | private List comprobantes;
30 | }
31 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/sunat/resumen/SummaryDocumentsItem.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.sunat.resumen;
2 |
3 | import io.swagger.v3.oas.annotations.media.Schema;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | @Data
10 | @Builder
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | public class SummaryDocumentsItem {
14 |
15 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Catalogo Catalog19")
16 | private String tipoOperacion;
17 |
18 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
19 | private Comprobante comprobante;
20 | }
21 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/content/models/utils/UBLRegex.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.content.models.utils;
2 |
3 | import lombok.Data;
4 |
5 | import java.util.regex.Pattern;
6 |
7 | @Data
8 | public class UBLRegex {
9 |
10 | public static final Pattern FACTURA_SERIE_REGEX = Pattern.compile("^[F|f].*$");
11 | public static final Pattern BOLETA_SERIE_REGEX = Pattern.compile("^[B|b].*$");
12 |
13 | private UBLRegex() {
14 | // Just static methods
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/config/DateProvider.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.config;
2 |
3 | import java.time.LocalDate;
4 |
5 | public interface DateProvider {
6 | LocalDate now();
7 | }
8 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/config/Defaults.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.config;
2 |
3 | import lombok.Builder;
4 | import lombok.Getter;
5 |
6 | import java.math.BigDecimal;
7 |
8 | @Getter
9 | @Builder
10 | public class Defaults {
11 | private BigDecimal icbTasa = new BigDecimal("0.5");
12 | private BigDecimal igvTasa = new BigDecimal("0.18");
13 | private BigDecimal ivapTasa = new BigDecimal("0.04");
14 | }
15 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/AbstractBodyRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie;
2 |
3 | import io.github.project.openubl.xbuilder.enricher.config.Defaults;
4 | import io.github.project.openubl.xbuilder.enricher.kie.ruleunits.BodyRuleContext;
5 |
6 | public abstract class AbstractBodyRule implements RuleFactory, Rule {
7 |
8 | private Defaults defaults;
9 | private BodyRuleContext ruleContext;
10 |
11 | @Override
12 | public Rule create(Defaults defaults, RuleContext ruleContext) {
13 | this.defaults = defaults;
14 | if (ruleContext instanceof BodyRuleContext) {
15 | this.ruleContext = (BodyRuleContext) ruleContext;
16 | } else {
17 | throw new IllegalStateException("HeaderRule requires HeaderContext");
18 | }
19 | return this;
20 | }
21 |
22 | public BodyRuleContext getRuleContext() {
23 | return ruleContext;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/AbstractHeaderRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie;
2 |
3 | import io.github.project.openubl.xbuilder.enricher.config.Defaults;
4 | import io.github.project.openubl.xbuilder.enricher.kie.ruleunits.HeaderRuleContext;
5 |
6 | public abstract class AbstractHeaderRule implements RuleFactory, Rule {
7 |
8 | private Defaults defaults;
9 | private HeaderRuleContext ruleContext;
10 |
11 | @Override
12 | public Rule create(Defaults defaults, RuleContext ruleContext) {
13 | this.defaults = defaults;
14 | if (ruleContext instanceof HeaderRuleContext) {
15 | this.ruleContext = (HeaderRuleContext) ruleContext;
16 | } else {
17 | throw new IllegalStateException("HeaderRule requires HeaderContext");
18 | }
19 | return this;
20 | }
21 |
22 | public Defaults getDefaults() {
23 | return defaults;
24 | }
25 |
26 | public HeaderRuleContext getRuleContext() {
27 | return ruleContext;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/Rule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie;
2 |
3 | public interface Rule {
4 | void modify(Object object);
5 | }
6 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/RuleContext.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie;
2 |
3 | public interface RuleContext {
4 | }
5 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/RuleFactory.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie;
2 |
3 | import io.github.project.openubl.xbuilder.enricher.config.Defaults;
4 |
5 | public interface RuleFactory {
6 | boolean test(Object object);
7 |
8 | Rule create(Defaults defaults, RuleContext ruleContext);
9 | }
10 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/RuleFactoryRegistry.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 | import java.util.ServiceLoader;
6 | import java.util.stream.Collectors;
7 |
8 | public class RuleFactoryRegistry {
9 |
10 | public static List getRuleFactories(RulePhase.PhaseType phaseType) {
11 | return ServiceLoader
12 | .load(RuleFactory.class)
13 | .stream()
14 | .map(ruleProvider -> {
15 | RulePhase rulePhase = ruleProvider.type().getAnnotation(RulePhase.class);
16 | return Map.entry(ruleProvider, rulePhase);
17 | })
18 | .filter(ruleProviderPhaseEntry -> {
19 | RulePhase rulePhase = ruleProviderPhaseEntry.getValue();
20 | return rulePhase.type().equals(phaseType);
21 | })
22 | .sorted((o1, o2) -> o2.getValue().priority() - o1.getValue().priority())
23 | .map(ruleProviderPhaseEntry -> ruleProviderPhaseEntry.getKey().get())
24 | .collect(Collectors.toList());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/RulePhase.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Target(ElementType.TYPE)
10 | public @interface RulePhase {
11 | PhaseType type();
12 |
13 | int priority() default 0;
14 |
15 | enum PhaseType {
16 | ENRICH,
17 | PROCESS,
18 | SUMMARY,
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/RuleUnit.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie;
2 |
3 | public interface RuleUnit {
4 | void modify(Object object);
5 | }
6 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/body/descuento/FactorRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.body.descuento;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.standard.general.Descuento;
4 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
6 |
7 | import java.math.BigDecimal;
8 | import java.util.function.Consumer;
9 |
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isDescuento;
11 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenDescuento;
12 |
13 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
14 | public class FactorRule extends AbstractBodyRule {
15 |
16 | @Override
17 | public boolean test(Object object) {
18 | return isDescuento.test(object) && whenDescuento.apply(object)
19 | .map(descuento -> descuento.getFactor() == null)
20 | .orElse(false);
21 | }
22 |
23 | @Override
24 | public void modify(Object object) {
25 | Consumer consumer = descuento -> {
26 | descuento.setFactor(BigDecimal.ONE);
27 | };
28 | whenDescuento.apply(object).ifPresent(consumer);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/body/descuento/MontoBaseRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.body.descuento;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.standard.general.Descuento;
4 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
6 |
7 | import java.util.function.Consumer;
8 |
9 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isDescuento;
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenDescuento;
11 |
12 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
13 | public class MontoBaseRule extends AbstractBodyRule {
14 |
15 | @Override
16 | public boolean test(Object object) {
17 | return isDescuento.test(object) && whenDescuento.apply(object)
18 | .map(descuento -> descuento.getMontoBase() == null && descuento.getMonto() != null)
19 | .orElse(false);
20 | }
21 |
22 | @Override
23 | public void modify(Object object) {
24 | Consumer consumer = descuento -> {
25 | descuento.setMontoBase(descuento.getMonto());
26 | };
27 | whenDescuento.apply(object).ifPresent(consumer);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/body/detalle/IgvTipoRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.body.detalle;
2 |
3 | import io.github.project.openubl.xbuilder.content.catalogs.Catalog;
4 | import io.github.project.openubl.xbuilder.content.catalogs.Catalog7;
5 | import io.github.project.openubl.xbuilder.content.models.standard.general.DocumentoVentaDetalle;
6 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule;
7 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
8 |
9 | import java.util.function.Consumer;
10 |
11 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isSalesDocumentItem;
12 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenSalesDocumentItem;
13 |
14 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
15 | public class IgvTipoRule extends AbstractBodyRule {
16 |
17 | @Override
18 | public boolean test(Object object) {
19 | return isSalesDocumentItem.test(object);
20 | }
21 |
22 | @Override
23 | public void modify(Object object) {
24 | Consumer consumer = detalle -> {
25 | Catalog7 catalog7;
26 | if (detalle.getIgvTipo() == null) {
27 | catalog7 = Catalog7.GRAVADO_OPERACION_ONEROSA;
28 | } else {
29 | catalog7 = Catalog.valueOfCode(Catalog7.class, detalle.getIgvTipo()).orElseThrow(Catalog.invalidCatalogValue);
30 | }
31 |
32 | detalle.setIgvTipo(catalog7.getCode());
33 | };
34 | whenSalesDocumentItem.apply(object).ifPresent(consumer);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/body/detalle/IscTipoRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.body.detalle;
2 |
3 | import io.github.project.openubl.xbuilder.content.catalogs.Catalog;
4 | import io.github.project.openubl.xbuilder.content.catalogs.Catalog8;
5 | import io.github.project.openubl.xbuilder.content.models.standard.general.DocumentoVentaDetalle;
6 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule;
7 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
8 |
9 | import java.util.function.Consumer;
10 |
11 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isSalesDocumentItem;
12 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenSalesDocumentItem;
13 |
14 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
15 | public class IscTipoRule extends AbstractBodyRule {
16 |
17 | @Override
18 | public boolean test(Object object) {
19 | return isSalesDocumentItem.test(object);
20 | }
21 |
22 | @Override
23 | public void modify(Object object) {
24 | Consumer consumer = detalle -> {
25 | Catalog8 catalog8;
26 | if (detalle.getIscTipo() == null) {
27 | catalog8 = Catalog8.SISTEMA_AL_VALOR;
28 | } else {
29 | catalog8 = Catalog.valueOfCode(Catalog8.class, detalle.getIscTipo()).orElseThrow(Catalog.invalidCatalogValue);
30 | }
31 |
32 | detalle.setIscTipo(catalog8.getCode());
33 | };
34 | whenSalesDocumentItem.apply(object).ifPresent(consumer);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/body/detalle/TasaIcbRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.body.detalle;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.standard.general.DocumentoVentaDetalle;
4 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
6 |
7 | import java.math.BigDecimal;
8 | import java.util.function.Consumer;
9 |
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isSalesDocumentItem;
11 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenSalesDocumentItem;
12 |
13 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
14 | public class TasaIcbRule extends AbstractBodyRule {
15 |
16 | @Override
17 | public boolean test(Object object) {
18 | return (isSalesDocumentItem.test(object) && whenSalesDocumentItem.apply(object)
19 | .map(documento -> documento.getTasaIcb() == null)
20 | .orElse(false)
21 | );
22 | }
23 |
24 | @Override
25 | public void modify(Object object) {
26 | Consumer consumer = detalle -> {
27 | BigDecimal tasaIcb = getRuleContext().getTasaIcb();
28 | detalle.setTasaIcb(tasaIcb);
29 | };
30 | whenSalesDocumentItem.apply(object).ifPresent(consumer);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/body/detalle/UnidadDeMedidaRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.body.detalle;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.standard.general.DocumentoVentaDetalle;
4 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
6 |
7 | import java.util.function.Consumer;
8 |
9 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isSalesDocumentItem;
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenSalesDocumentItem;
11 |
12 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
13 | public class UnidadDeMedidaRule extends AbstractBodyRule {
14 |
15 | @Override
16 | public boolean test(Object object) {
17 | return (isSalesDocumentItem.test(object) && whenSalesDocumentItem.apply(object)
18 | .map(documento -> documento.getUnidadMedida() == null)
19 | .orElse(false)
20 | );
21 | }
22 |
23 | @Override
24 | public void modify(Object object) {
25 | Consumer consumer = detalle -> detalle.setUnidadMedida("NIU");
26 | whenSalesDocumentItem.apply(object).ifPresent(consumer);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/body/summaryDocumentItem/MonedaRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.body.summaryDocumentItem;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.sunat.resumen.SummaryDocumentsItem;
4 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
6 |
7 | import java.util.function.Consumer;
8 |
9 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isSummaryDocumentsItem;
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenSummaryDocumentsItem;
11 |
12 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
13 | public class MonedaRule extends AbstractBodyRule {
14 |
15 | @Override
16 | public boolean test(Object object) {
17 | return (isSummaryDocumentsItem.test(object) && whenSummaryDocumentsItem.apply(object)
18 | .map(item -> item.getComprobante() != null &&
19 | item.getComprobante().getMoneda() == null
20 | )
21 | .orElse(false)
22 | );
23 | }
24 |
25 | @Override
26 | public void modify(Object object) {
27 | Consumer consumer = item -> {
28 | String moneda = getRuleContext().getMoneda();
29 | item.getComprobante().setMoneda(moneda);
30 | };
31 | whenSummaryDocumentsItem.apply(object).ifPresent(consumer);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/body/summaryDocumentItem/TipoOperacionRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.body.summaryDocumentItem;
2 |
3 | import io.github.project.openubl.xbuilder.content.catalogs.Catalog;
4 | import io.github.project.openubl.xbuilder.content.catalogs.Catalog19;
5 | import io.github.project.openubl.xbuilder.content.models.sunat.resumen.SummaryDocumentsItem;
6 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule;
7 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
8 |
9 | import java.util.function.Consumer;
10 |
11 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isSummaryDocumentsItem;
12 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenSummaryDocumentsItem;
13 |
14 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
15 | public class TipoOperacionRule extends AbstractBodyRule {
16 |
17 | @Override
18 | public boolean test(Object object) {
19 | return (
20 | isSummaryDocumentsItem.test(object) &&
21 | whenSummaryDocumentsItem.apply(object).map(item -> item.getTipoOperacion() != null).orElse(false)
22 | );
23 | }
24 |
25 | @Override
26 | public void modify(Object object) {
27 | Consumer consumer = item -> {
28 | Catalog.valueOfCode(Catalog19.class, item.getTipoOperacion())
29 | .ifPresent(catalog -> item.setTipoOperacion(catalog.getCode()));
30 | };
31 | whenSummaryDocumentsItem.apply(object).ifPresent(consumer);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/header/MonedaRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.header;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.common.Document;
4 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractHeaderRule;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
6 |
7 | import java.util.function.Consumer;
8 |
9 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isDocument;
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenDocument;
11 |
12 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
13 | public class MonedaRule extends AbstractHeaderRule {
14 |
15 | @Override
16 | public boolean test(Object object) {
17 | return (
18 | isDocument.test(object) &&
19 | whenDocument.apply(object).map(documento -> documento.getMoneda() == null).orElse(false)
20 | );
21 | }
22 |
23 | @Override
24 | public void modify(Object object) {
25 | Consumer consumer = document -> document.setMoneda("PEN");
26 | whenDocument.apply(object).ifPresent(consumer);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/header/TasaIcbRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.header;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.standard.general.SalesDocument;
4 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractHeaderRule;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
6 |
7 | import java.util.function.Consumer;
8 |
9 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isSalesDocument;
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenSalesDocument;
11 |
12 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
13 | public class TasaIcbRule extends AbstractHeaderRule {
14 |
15 | @Override
16 | public boolean test(Object object) {
17 | return (
18 | isSalesDocument.test(object) &&
19 | whenSalesDocument.apply(object).map(documento -> documento.getTasaIcb() == null).orElse(false)
20 | );
21 | }
22 |
23 | @Override
24 | public void modify(Object object) {
25 | Consumer consumer = document -> document.setTasaIcb(getDefaults().getIcbTasa());
26 | whenSalesDocument.apply(object).ifPresent(consumer);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/header/TasaIgvRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.header;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.standard.general.SalesDocument;
4 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractHeaderRule;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
6 |
7 | import java.util.function.Consumer;
8 |
9 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isSalesDocument;
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenSalesDocument;
11 |
12 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
13 | public class TasaIgvRule extends AbstractHeaderRule {
14 |
15 | @Override
16 | public boolean test(Object object) {
17 | return (isSalesDocument.test(object) && whenSalesDocument.apply(object)
18 | .map(documento -> documento.getTasaIgv() == null)
19 | .orElse(false)
20 | );
21 | }
22 |
23 | @Override
24 | public void modify(Object object) {
25 | Consumer consumer = document -> document.setTasaIgv(getDefaults().getIgvTasa());
26 | whenSalesDocument.apply(object).ifPresent(consumer);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/header/TasaIvapRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.header;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.standard.general.SalesDocument;
4 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractHeaderRule;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
6 |
7 | import java.util.function.Consumer;
8 |
9 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isSalesDocument;
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenSalesDocument;
11 |
12 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
13 | public class TasaIvapRule extends AbstractHeaderRule {
14 |
15 | @Override
16 | public boolean test(Object object) {
17 | return (isSalesDocument.test(object) && whenSalesDocument.apply(object)
18 | .map(documento -> documento.getTasaIvap() == null)
19 | .orElse(false)
20 | );
21 | }
22 |
23 | @Override
24 | public void modify(Object object) {
25 | Consumer consumer = document -> document.setTasaIvap(getDefaults().getIvapTasa());
26 | whenSalesDocument.apply(object).ifPresent(consumer);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/header/invoice/DetraccionRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.header.invoice;
2 |
3 | import io.github.project.openubl.xbuilder.content.catalogs.Catalog52;
4 | import io.github.project.openubl.xbuilder.content.models.standard.general.Invoice;
5 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractHeaderRule;
6 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
7 |
8 | import java.util.HashMap;
9 | import java.util.Map;
10 | import java.util.function.Consumer;
11 |
12 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isInvoice;
13 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenInvoice;
14 |
15 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
16 | public class DetraccionRule extends AbstractHeaderRule {
17 |
18 | @Override
19 | public boolean test(Object object) {
20 | return (
21 | isInvoice.test(object) &&
22 | whenInvoice.apply(object).map(documento -> documento.getDetraccion() != null).orElse(false)
23 | );
24 | }
25 |
26 | @Override
27 | public void modify(Object object) {
28 | Consumer consumer = document -> {
29 | Catalog52 leyenda = Catalog52.OPERACION_SUJETA_A_DETRACCION;
30 |
31 | Map leyendas = new HashMap<>(document.getLeyendas());
32 | leyendas.put(leyenda.getCode(), leyenda.getLabel());
33 |
34 | document.setLeyendas(leyendas);
35 | };
36 | whenInvoice.apply(object).ifPresent(consumer);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/header/invoice/FormaDePagoRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.header.invoice;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.standard.general.FormaDePago;
4 | import io.github.project.openubl.xbuilder.content.models.standard.general.Invoice;
5 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractHeaderRule;
6 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
7 |
8 | import java.util.function.Consumer;
9 |
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isInvoice;
11 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenInvoice;
12 |
13 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
14 | public class FormaDePagoRule extends AbstractHeaderRule {
15 |
16 | @Override
17 | public boolean test(Object object) {
18 | return (
19 | isInvoice.test(object) &&
20 | whenInvoice.apply(object).map(documento -> documento.getFormaDePago() == null).orElse(false)
21 | );
22 | }
23 |
24 | @Override
25 | public void modify(Object object) {
26 | Consumer consumer = document -> {
27 | document.setFormaDePago(FormaDePago.builder().build());
28 | };
29 | whenInvoice.apply(object).ifPresent(consumer);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/header/invoice/FormaDePagoTipoRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.header.invoice;
2 |
3 | import io.github.project.openubl.xbuilder.content.catalogs.CatalogContadoCredito;
4 | import io.github.project.openubl.xbuilder.content.models.standard.general.Invoice;
5 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractHeaderRule;
6 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
7 |
8 | import java.util.function.Consumer;
9 |
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isInvoice;
11 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenInvoice;
12 |
13 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
14 | public class FormaDePagoTipoRule extends AbstractHeaderRule {
15 |
16 | @Override
17 | public boolean test(Object object) {
18 | return isInvoice.test(object);
19 | }
20 |
21 | @Override
22 | public void modify(Object object) {
23 | Consumer consumer = document -> {
24 | CatalogContadoCredito formaDePagoTipo = document.getFormaDePago().getCuotas() == null ||
25 | document.getFormaDePago().getCuotas().isEmpty()
26 | ? CatalogContadoCredito.CONTADO
27 | : CatalogContadoCredito.CREDITO;
28 |
29 | document.getFormaDePago().setTipo(formaDePagoTipo.getCode());
30 | };
31 | whenInvoice.apply(object).ifPresent(consumer);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/enrich/header/invoice/PercepcionRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.header.invoice;
2 |
3 | import io.github.project.openubl.xbuilder.content.catalogs.Catalog52;
4 | import io.github.project.openubl.xbuilder.content.models.standard.general.Invoice;
5 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractHeaderRule;
6 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
7 |
8 | import java.util.HashMap;
9 | import java.util.Map;
10 | import java.util.function.Consumer;
11 |
12 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isInvoice;
13 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenInvoice;
14 |
15 | @RulePhase(type = RulePhase.PhaseType.ENRICH)
16 | public class PercepcionRule extends AbstractHeaderRule {
17 |
18 | @Override
19 | public boolean test(Object object) {
20 | return (
21 | isInvoice.test(object) &&
22 | whenInvoice.apply(object).map(documento -> documento.getPercepcion() != null).orElse(false)
23 | );
24 | }
25 |
26 | @Override
27 | public void modify(Object object) {
28 | Consumer consumer = document -> {
29 | Catalog52 leyenda = Catalog52.COMPROBANTE_DE_PERCEPCION;
30 |
31 | Map leyendas = new HashMap<>(document.getLeyendas());
32 | leyendas.put(leyenda.getCode(), leyenda.getLabel());
33 |
34 | document.setLeyendas(leyendas);
35 | };
36 | whenInvoice.apply(object).ifPresent(consumer);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/process/body/detalle/IcbAplicaRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.process.body.detalle;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.standard.general.DocumentoVentaDetalle;
4 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
6 |
7 | import java.math.BigDecimal;
8 | import java.util.function.Consumer;
9 |
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isSalesDocumentItem;
11 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenSalesDocumentItem;
12 |
13 | @RulePhase(type = RulePhase.PhaseType.PROCESS)
14 | public class IcbAplicaRule extends AbstractBodyRule {
15 |
16 | @Override
17 | public boolean test(Object object) {
18 | return (isSalesDocumentItem.test(object) && whenSalesDocumentItem.apply(object)
19 | .map(documento -> !documento.isIcbAplica() &&
20 | documento.getIcb() != null &&
21 | documento.getIcb().compareTo(BigDecimal.ZERO) > 0
22 | )
23 | .orElse(false)
24 | );
25 | }
26 |
27 | @Override
28 | public void modify(Object object) {
29 | Consumer consumer = detalle -> {
30 | detalle.setIcbAplica(true);
31 | };
32 | whenSalesDocumentItem.apply(object).ifPresent(consumer);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/process/body/detalle/IcbRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.process.body.detalle;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.standard.general.DocumentoVentaDetalle;
4 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
6 |
7 | import java.math.BigDecimal;
8 | import java.util.function.Consumer;
9 |
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isSalesDocumentItem;
11 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenSalesDocumentItem;
12 |
13 | @RulePhase(type = RulePhase.PhaseType.PROCESS)
14 | public class IcbRule extends AbstractBodyRule {
15 |
16 | @Override
17 | public boolean test(Object object) {
18 | return (isSalesDocumentItem.test(object) && whenSalesDocumentItem.apply(object)
19 | .map(documento -> documento.getIcb() == null)
20 | .orElse(false)
21 | );
22 | }
23 |
24 | @Override
25 | public void modify(Object object) {
26 | Consumer consumer = detalle -> {
27 | BigDecimal icb = detalle.isIcbAplica()
28 | ? detalle.getCantidad().multiply(getRuleContext().getTasaIcb())
29 | : BigDecimal.ZERO;
30 | detalle.setIcb(icb);
31 | };
32 | whenSalesDocumentItem.apply(object).ifPresent(consumer);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/process/body/detalle/IgvRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.process.body.detalle;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.standard.general.DocumentoVentaDetalle;
4 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
6 |
7 | import java.math.BigDecimal;
8 | import java.util.function.Consumer;
9 |
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isSalesDocumentItem;
11 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenSalesDocumentItem;
12 |
13 | @RulePhase(type = RulePhase.PhaseType.PROCESS)
14 | public class IgvRule extends AbstractBodyRule {
15 |
16 | @Override
17 | public boolean test(Object object) {
18 | return (isSalesDocumentItem.test(object) && whenSalesDocumentItem.apply(object)
19 | .map(documento -> documento.getIgv() == null &&
20 | documento.getIgvBaseImponible() != null &&
21 | documento.getTasaIgv() != null
22 | )
23 | .orElse(false)
24 | );
25 | }
26 |
27 | @Override
28 | public void modify(Object object) {
29 | Consumer consumer = detalle -> {
30 | BigDecimal igv = detalle.getIgvBaseImponible().multiply(detalle.getTasaIgv());
31 | detalle.setIgv(igv);
32 | };
33 | whenSalesDocumentItem.apply(object).ifPresent(consumer);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/process/body/detalle/IscRule.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.process.body.detalle;
2 |
3 | import io.github.project.openubl.xbuilder.content.models.standard.general.DocumentoVentaDetalle;
4 | import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
6 |
7 | import java.math.BigDecimal;
8 | import java.util.function.Consumer;
9 |
10 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isSalesDocumentItem;
11 | import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenSalesDocumentItem;
12 |
13 | @RulePhase(type = RulePhase.PhaseType.PROCESS)
14 | public class IscRule extends AbstractBodyRule {
15 |
16 | @Override
17 | public boolean test(Object object) {
18 | return (isSalesDocumentItem.test(object) && whenSalesDocumentItem.apply(object)
19 | .map(documento -> documento.getIsc() == null &&
20 | documento.getIscBaseImponible() != null &&
21 | documento.getTasaIsc() != null
22 | )
23 | .orElse(false)
24 | );
25 | }
26 |
27 | @Override
28 | public void modify(Object object) {
29 | Consumer consumer = detalle -> {
30 | BigDecimal isc = detalle.getIscBaseImponible().multiply(detalle.getTasaIsc());
31 | detalle.setIsc(isc);
32 | };
33 | whenSalesDocumentItem.apply(object).ifPresent(consumer);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/rules/utils/Impuesto.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.rules.utils;
2 |
3 | import lombok.Builder;
4 | import lombok.Data;
5 |
6 | import java.math.BigDecimal;
7 |
8 | @Data
9 | @Builder
10 | public class Impuesto {
11 | private BigDecimal baseImponible;
12 |
13 | private BigDecimal importe;
14 | private BigDecimal importeIgv;
15 | private BigDecimal importeIsc;
16 | private BigDecimal importeIcb;
17 | }
18 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/ruleunits/BodyRuleContext.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.ruleunits;
2 |
3 | import io.github.project.openubl.xbuilder.enricher.kie.RuleContext;
4 | import lombok.Builder;
5 | import lombok.Getter;
6 |
7 | import java.math.BigDecimal;
8 |
9 | @Getter
10 | @Builder
11 | public class BodyRuleContext implements RuleContext {
12 |
13 | private String moneda;
14 | private BigDecimal tasaIgv;
15 | private BigDecimal tasaIvap;
16 | private BigDecimal tasaIcb;
17 | }
18 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/ruleunits/BodyRuleUnit.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.ruleunits;
2 |
3 | import io.github.project.openubl.xbuilder.enricher.config.Defaults;
4 | import io.github.project.openubl.xbuilder.enricher.kie.RuleFactory;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RuleFactoryRegistry;
6 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
7 | import io.github.project.openubl.xbuilder.enricher.kie.RuleUnit;
8 |
9 | import java.util.List;
10 |
11 | public class BodyRuleUnit implements RuleUnit {
12 |
13 | private final Defaults defaults;
14 | private final BodyRuleContext context;
15 | private final List rules;
16 |
17 | public BodyRuleUnit(RulePhase.PhaseType phaseType, Defaults defaults, BodyRuleContext context) {
18 | this.defaults = defaults;
19 | this.context = context;
20 | this.rules = RuleFactoryRegistry.getRuleFactories(phaseType);
21 | }
22 |
23 | @Override
24 | public void modify(Object object) {
25 | int prevHashCode;
26 | int currentHashCode;
27 |
28 | do {
29 | prevHashCode = object.hashCode();
30 | rules
31 | .stream()
32 | .filter(factory -> factory.test(object))
33 | .map(factory -> factory.create(defaults, context))
34 | .forEach(rule -> rule.modify(object));
35 | currentHashCode = object.hashCode();
36 | } while (prevHashCode != currentHashCode);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/ruleunits/HeaderRuleContext.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.ruleunits;
2 |
3 | import io.github.project.openubl.xbuilder.enricher.kie.RuleContext;
4 | import lombok.Builder;
5 | import lombok.Getter;
6 |
7 | import java.time.LocalDate;
8 |
9 | @Getter
10 | @Builder
11 | public class HeaderRuleContext implements RuleContext {
12 |
13 | private LocalDate localDate;
14 | }
15 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/enricher/kie/ruleunits/HeaderRuleUnit.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.enricher.kie.ruleunits;
2 |
3 | import io.github.project.openubl.xbuilder.enricher.config.Defaults;
4 | import io.github.project.openubl.xbuilder.enricher.kie.RuleFactory;
5 | import io.github.project.openubl.xbuilder.enricher.kie.RuleFactoryRegistry;
6 | import io.github.project.openubl.xbuilder.enricher.kie.RulePhase;
7 | import io.github.project.openubl.xbuilder.enricher.kie.RuleUnit;
8 |
9 | import java.util.List;
10 |
11 | public class HeaderRuleUnit implements RuleUnit {
12 |
13 | private final Defaults defaults;
14 | private final HeaderRuleContext context;
15 | private final List rules;
16 |
17 | public HeaderRuleUnit(RulePhase.PhaseType phaseType, Defaults defaults, HeaderRuleContext context) {
18 | this.defaults = defaults;
19 | this.context = context;
20 | this.rules = RuleFactoryRegistry.getRuleFactories(phaseType);
21 | }
22 |
23 | @Override
24 | public void modify(Object object) {
25 | int prevHashCode;
26 | int currentHashCode;
27 |
28 | do {
29 | prevHashCode = object.hashCode();
30 | rules
31 | .stream()
32 | .filter(factory -> factory.test(object))
33 | .map(factory -> factory.create(defaults, context))
34 | .forEach(rule -> rule.modify(object));
35 | currentHashCode = object.hashCode();
36 | } while (prevHashCode != currentHashCode);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/signature/CertificateDetails.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xbuilder.signature;
2 |
3 | import java.security.PrivateKey;
4 | import java.security.cert.X509Certificate;
5 |
6 | public class CertificateDetails {
7 |
8 | private PrivateKey privateKey;
9 |
10 | private X509Certificate x509Certificate;
11 |
12 | public PrivateKey getPrivateKey() {
13 | return privateKey;
14 | }
15 |
16 | public void setPrivateKey(PrivateKey privateKey) {
17 | this.privateKey = privateKey;
18 | }
19 |
20 | public X509Certificate getX509Certificate() {
21 | return x509Certificate;
22 | }
23 |
24 | public void setX509Certificate(X509Certificate x509Certificate) {
25 | this.x509Certificate = x509Certificate;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/common/signature.xml:
--------------------------------------------------------------------------------
1 |
2 | {firmante.ruc}
3 |
4 |
5 | {firmante.ruc}
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | #PROJECT-OPENUBL-SIGN
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/standard/include/address.xml:
--------------------------------------------------------------------------------
1 | {#if direccion.ubigeo}
2 | {direccion.ubigeo}
3 | {/if}
4 | {#if direccion.codigoLocal}
5 | {direccion.codigoLocal}
6 | {/if}
7 | {#if direccion.urbanizacion}
8 | {direccion.urbanizacion}
9 | {/if}
10 | {#if direccion.provincia}
11 | {direccion.provincia}
12 | {/if}
13 | {#if direccion.departamento}
14 | {direccion.departamento}
15 | {/if}
16 | {#if direccion.distrito}
17 | {direccion.distrito}
18 | {/if}
19 | {#if direccion.direccion}
20 |
21 |
22 |
23 | {/if}
24 | {#if direccion.codigoPais}
25 |
26 | {direccion.codigoPais}
27 |
28 | {/if}
29 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/standard/include/contact.xml:
--------------------------------------------------------------------------------
1 |
2 | {#if contacto.telefono}
3 | {contacto.telefono}
4 | {/if}
5 | {#if contacto.email}
6 | {contacto.email}
7 | {/if}
8 |
9 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/standard/include/customer.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {cliente.numeroDocumentoIdentidad}
5 |
6 |
7 |
8 | {#if cliente.direccion}
9 |
10 | {#include ubl/standard/include/address.xml direccion=cliente.direccion /}
11 |
12 | {/if}
13 |
14 | {#if cliente.contacto}
15 | {#include ubl/standard/include/contact.xml contacto=cliente.contacto /}
16 | {/if}
17 |
18 |
19 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/standard/include/documentos-relacionados.xml:
--------------------------------------------------------------------------------
1 | {#each item.documentosRelacionados.orEmpty}
2 |
3 | {it.serieNumero}
4 | {it.tipoDocumento}
5 |
6 | {/each}
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/standard/include/general-data.xml:
--------------------------------------------------------------------------------
1 | 2.1
2 | 2.0
3 | {item.serie}-{item.numero}
4 | {item.fechaEmision}
5 | {#if item.horaEmision}
6 | {item.horaEmision.format('HH:mm:ss')}
7 | {/if}
8 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/standard/include/guias.xml:
--------------------------------------------------------------------------------
1 | {#each item.guias.orEmpty}
2 |
3 | {it.serieNumero}
4 | {it.tipoDocumento}
5 |
6 | {/each}
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/standard/include/monetary-total.xml:
--------------------------------------------------------------------------------
1 | {totalImporte.importeSinImpuestos.scale(2)}
2 | {totalImporte.importe.scale(2)}
3 | {totalImporte.importe.scale(2)}
4 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/standard/include/namespaces.xml:
--------------------------------------------------------------------------------
1 | xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
2 | xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
3 | xmlns:ccts="urn:un:unece:uncefact:documentation:2"
4 | xmlns:cec="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
5 | xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
6 | xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
7 | xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2"
8 | xmlns:sac="urn:sunat:names:specification:ubl:peru:schema:xsd:SunatAggregateComponents-1"
9 | xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"
10 | xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
11 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/standard/include/note/invoice-reference.xml:
--------------------------------------------------------------------------------
1 |
2 | {item.comprobanteAfectadoSerieNumero}
3 | {item.comprobanteAfectadoTipo}
4 |
5 |
6 | {#if item.ordenDeCompra}
7 |
8 | {item.ordenDeCompra}
9 |
10 | {/if}
11 |
12 |
13 | {item.comprobanteAfectadoSerieNumero}
14 | {item.comprobanteAfectadoTipo}
15 |
16 |
17 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/standard/include/payment-terms.xml:
--------------------------------------------------------------------------------
1 |
2 | FormaPago
3 | {item.tipo}
4 | {#if item.tipo == 'Credito'}
5 | {item.total.scale(2)}
6 | {/if}
7 |
8 | {#each item.cuotas.orEmpty}
9 |
10 | FormaPago
11 | Cuota{it_index.add(1).format('%03d')}
12 | {it.importe.scale(2)}
13 | {it.fechaPago}
14 |
15 | {/each}
16 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/standard/include/supplier.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {proveedor.ruc}
5 |
6 | {#if proveedor.nombreComercial}
7 |
8 | {proveedor.nombreComercial}
9 |
10 | {/if}
11 |
12 |
13 | {#if proveedor.direccion}
14 |
15 | {#include ubl/standard/include/address.xml direccion=proveedor.direccion /}
16 |
17 | {/if}
18 |
19 | {#if proveedor.contacto}
20 | {#include ubl/standard/include/contact.xml contacto=proveedor.contacto /}
21 | {/if}
22 |
23 |
24 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/standard/include/ubl-extensions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/sunat/include/agent-party.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | {proveedor.ruc}
4 |
5 | {#if proveedor.nombreComercial}
6 |
7 |
8 |
9 | {/if}
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/sunat/include/receiver-party.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | {cliente.numeroDocumentoIdentidad}
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/xbuilder/core/src/main/resources/templates/ubl/sunat/include/supplier.xml:
--------------------------------------------------------------------------------
1 |
2 | {proveedor.ruc}
3 | 6
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/xbuilder/core/src/test/java/e2e/enricher/enrich/InvoiceTest.java:
--------------------------------------------------------------------------------
1 | package e2e.enricher.enrich;
2 |
3 | import e2e.AbstractTest;
4 | import io.github.project.openubl.xbuilder.content.catalogs.Catalog1_Invoice;
5 | import io.github.project.openubl.xbuilder.content.models.standard.general.Invoice;
6 | import io.github.project.openubl.xbuilder.enricher.ContentEnricher;
7 | import org.junit.jupiter.api.Test;
8 |
9 | import static org.junit.jupiter.api.Assertions.assertEquals;
10 |
11 | public class InvoiceTest extends AbstractTest {
12 |
13 | @Test
14 | public void testEnrichTipoComprobante() {
15 | // Given
16 | Invoice input = Invoice.builder()
17 | .serie("F001-1")
18 | .tipoComprobante(Catalog1_Invoice.BOLETA.getCode()) // This should be overwritten
19 | .build();
20 |
21 | // When
22 | ContentEnricher enricher = new ContentEnricher(defaults, dateProvider);
23 | enricher.enrich(input);
24 |
25 | // Then
26 | assertEquals(Catalog1_Invoice.FACTURA.getCode(), input.getTipoComprobante());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/xbuilder/core/src/test/java/e2e/homologacion/HomologacionConstants.java:
--------------------------------------------------------------------------------
1 | package e2e.homologacion;
2 |
3 | import io.github.project.openubl.xbuilder.content.catalogs.Catalog6;
4 | import io.github.project.openubl.xbuilder.content.models.common.Cliente;
5 | import io.github.project.openubl.xbuilder.content.models.common.Proveedor;
6 |
7 | public class HomologacionConstants {
8 |
9 | public static final Proveedor proveedor = Proveedor.builder()
10 | .ruc("12345678912")
11 | .razonSocial("Softgreen S.A.C.")
12 | .build();
13 | public static final Cliente cliente = Cliente.builder()
14 | .nombre("Carlos Feria")
15 | .numeroDocumentoIdentidad("12121212121")
16 | .tipoDocumentoIdentidad(Catalog6.RUC.toString())
17 | .build();
18 | }
19 |
--------------------------------------------------------------------------------
/xbuilder/core/src/test/java/e2e/homologacion/ManualDeHomologación_Version_3_0.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/project-openubl/xhandler-java/9dea32a3e38d85899e2c0cb045ec4e4f9b87fb42/xbuilder/core/src/test/java/e2e/homologacion/ManualDeHomologación_Version_3_0.pdf
--------------------------------------------------------------------------------
/xbuilder/core/src/test/resources/LLAMA-PE-CERTIFICADO-DEMO-10467793549.pfx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/project-openubl/xhandler-java/9dea32a3e38d85899e2c0cb045ec4e4f9b87fb42/xbuilder/core/src/test/resources/LLAMA-PE-CERTIFICADO-DEMO-10467793549.pfx
--------------------------------------------------------------------------------
/xbuilder/core/src/test/resources/xsd/2.0/message.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/xbuilder/core/src/test/resources/xsd/2.0/message.xsl:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/xbuilder/core/src/test/resources/xsd/2.1/common/UBL-XAdESv141-2.1.xsd:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/xbuilder/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 |
7 | io.github.project-openubl
8 | xhandler-parent
9 | 5.0.3-SNAPSHOT
10 | ../pom.xml
11 |
12 |
13 | xbuilder-parent
14 | XBuilder - Parent
15 | XBuilder parent
16 | pom
17 |
18 |
19 | core
20 | quarkus-extension
21 |
22 |
23 |
--------------------------------------------------------------------------------
/xbuilder/quarkus-extension/deployment/src/test/java/io/github/project/openubl/quarkus/xbuilder/test/QuarkusXbuilderDevModeTest.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.quarkus.xbuilder.test;
2 |
3 | import io.quarkus.test.QuarkusDevModeTest;
4 | import org.jboss.shrinkwrap.api.ShrinkWrap;
5 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
6 | import org.junit.jupiter.api.Assertions;
7 | import org.junit.jupiter.api.Test;
8 | import org.junit.jupiter.api.extension.RegisterExtension;
9 |
10 | public class QuarkusXbuilderDevModeTest {
11 |
12 | // Start hot reload (DevMode) test with your extension loaded
13 | @RegisterExtension
14 | static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest()
15 | .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
16 |
17 | @Test
18 | public void writeYourOwnDevModeTest() {
19 | // Write your dev mode tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-hot-reload for more information
20 | Assertions.assertTrue(true, "Add dev mode assertions to " + getClass().getName());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/xbuilder/quarkus-extension/deployment/src/test/java/io/github/project/openubl/quarkus/xbuilder/test/QuarkusXbuilderTest.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.quarkus.xbuilder.test;
2 |
3 | import io.quarkus.test.QuarkusUnitTest;
4 | import org.jboss.shrinkwrap.api.ShrinkWrap;
5 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
6 | import org.junit.jupiter.api.Assertions;
7 | import org.junit.jupiter.api.Test;
8 | import org.junit.jupiter.api.extension.RegisterExtension;
9 |
10 | public class QuarkusXbuilderTest {
11 |
12 | // Start unit test with your extension loaded
13 | @RegisterExtension
14 | static final QuarkusUnitTest unitTest = new QuarkusUnitTest()
15 | .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
16 |
17 | @Test
18 | public void writeYourOwnUnitTest() {
19 | // Write your unit tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-extensions for more information
20 | Assertions.assertTrue(true, "Add some assertions to " + getClass().getName());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/xbuilder/quarkus-extension/integration-tests/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | quarkus.xbuilder.igv-tasa=0.2
2 | quarkus.xbuilder.icb-tasa=0.2
3 |
--------------------------------------------------------------------------------
/xbuilder/quarkus-extension/integration-tests/src/test/java/io/github/project/openubl/quarkus/xbuilder/it/QuarkusXbuilderResourceIT.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.quarkus.xbuilder.it;
2 |
3 | import io.quarkus.test.junit.QuarkusIntegrationTest;
4 |
5 | @QuarkusIntegrationTest
6 | public class QuarkusXbuilderResourceIT extends QuarkusXbuilderResourceTest {
7 | }
8 |
--------------------------------------------------------------------------------
/xbuilder/quarkus-extension/integration-tests/src/test/resources/.gitignore:
--------------------------------------------------------------------------------
1 | /e2e/
2 |
--------------------------------------------------------------------------------
/xbuilder/quarkus-extension/runtime/src/main/java/io/github/project/openubl/quarkus/xbuilder/XBuilder.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.quarkus.xbuilder;
2 |
3 | import io.github.project.openubl.xbuilder.enricher.config.Defaults;
4 | import io.quarkus.qute.Template;
5 |
6 | public interface XBuilder {
7 | Template getTemplate(Type type);
8 |
9 | Defaults getDefaults();
10 |
11 | enum Type {
12 | INVOICE("invoice.xml"),
13 | CREDIT_NOTE("creditNote.xml"),
14 | DEBIT_NOTE("debitNote.xml"),
15 | VOIDED_DOCUMENTS("voidedDocuments.xml"),
16 | SUMMARY_DOCUMENTS("summaryDocuments.xml"),
17 | PERCEPTION("perception.xml"),
18 | RETENTION("retention.xml"),
19 | DESPATCH_ADVICE("despatchAdvice.xml");
20 |
21 | private final String templatePath;
22 |
23 | Type(String templatePath) {
24 | this.templatePath = templatePath;
25 | }
26 |
27 | public String getTemplatePath() {
28 | return templatePath;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/xbuilder/quarkus-extension/runtime/src/main/java/io/github/project/openubl/quarkus/xbuilder/runtime/DefaultXBuilder.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.quarkus.xbuilder.runtime;
2 |
3 | import io.github.project.openubl.quarkus.xbuilder.XBuilder;
4 | import io.github.project.openubl.xbuilder.enricher.config.Defaults;
5 | import io.github.project.openubl.xbuilder.renderer.EngineProducer;
6 | import io.quarkus.qute.Engine;
7 | import io.quarkus.qute.EngineBuilder;
8 | import io.quarkus.qute.HtmlEscaper;
9 | import io.quarkus.qute.Template;
10 |
11 | import jakarta.enterprise.event.Observes;
12 | import jakarta.inject.Inject;
13 | import jakarta.inject.Singleton;
14 | import java.math.BigDecimal;
15 | import java.util.List;
16 |
17 | @Singleton
18 | public class DefaultXBuilder implements XBuilder {
19 |
20 | @Inject
21 | Engine engine;
22 |
23 | @Inject
24 | XBuilderConfig config;
25 |
26 | void configureEngine(@Observes EngineBuilder builder) {
27 | builder.addResultMapper(
28 | new HtmlEscaper(List.of("text/html", "text/xml", "application/xml", "application/xhtml+xml"))
29 | );
30 |
31 | EngineProducer.getInstance().getEngine().getValueResolvers().forEach(builder::addValueResolver);
32 | }
33 |
34 | @Override
35 | public Template getTemplate(Type type) {
36 | return engine.getTemplate(CustomTemplateLocator.PREFIX + type.getTemplatePath());
37 | }
38 |
39 | @Override
40 | public Defaults getDefaults() {
41 | return Defaults.builder()
42 | .igvTasa(config.igvTasa.orElse(new BigDecimal("0.18")))
43 | .icbTasa(config.icbTasa.orElse(new BigDecimal("0.2")))
44 | .build();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/xbuilder/quarkus-extension/runtime/src/main/java/io/github/project/openubl/quarkus/xbuilder/runtime/XBuilderConfig.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.quarkus.xbuilder.runtime;
2 |
3 | import io.quarkus.runtime.annotations.ConfigItem;
4 | import io.quarkus.runtime.annotations.ConfigPhase;
5 | import io.quarkus.runtime.annotations.ConfigRoot;
6 |
7 | import java.math.BigDecimal;
8 | import java.util.Optional;
9 |
10 | @ConfigRoot(name = "xbuilder", phase = ConfigPhase.RUN_TIME)
11 | public class XBuilderConfig {
12 |
13 | /**
14 | * Default igvTasa
15 | */
16 | @ConfigItem
17 | public Optional igvTasa;
18 |
19 | /**
20 | * Default icbTasa
21 | */
22 | @ConfigItem
23 | public Optional icbTasa;
24 | }
25 |
--------------------------------------------------------------------------------
/xbuilder/quarkus-extension/runtime/src/main/resources/META-INF/quarkus-extension.yaml:
--------------------------------------------------------------------------------
1 | name: "Quarkus XBuilder"
2 | description: "XBuilder support."
3 | metadata:
4 | keywords:
5 | - quarkus-xbuilder
6 | - openubl
7 | # guide: ...
8 | categories:
9 | - "miscellaneous"
10 | status: "preview"
11 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/Constants.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender;
2 |
3 | public class Constants {
4 |
5 | public static final String XSENDER_BILL_SERVICE_URI = "direct:xsender-billService";
6 | public static final String XSENDER_BILL_CONSULT_SERVICE_URI = "direct:xsender-billConsultService";
7 | public static final String XSENDER_BILL_VALID_SERVICE_URI = "direct:xsender-billValidService";
8 |
9 | public static final String XSENDER_CREDENTIALS_API_URI = "direct:xsender-credentialsApi";
10 | }
11 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/camel/StandaloneCamel.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.camel;
2 |
3 | import lombok.Synchronized;
4 | import org.apache.camel.main.Main;
5 |
6 | public final class StandaloneCamel {
7 |
8 | private static StandaloneCamel instance;
9 | private final Main mainCamel;
10 |
11 | private StandaloneCamel() throws Exception {
12 | mainCamel = new Main(StandaloneCamel.class);
13 | mainCamel.start();
14 | }
15 |
16 | @Synchronized
17 | public static StandaloneCamel getInstance() {
18 | if (instance == null) {
19 | try {
20 | instance = new StandaloneCamel();
21 | } catch (Exception e) {
22 | throw new RuntimeException(e);
23 | }
24 | }
25 | return instance;
26 | }
27 |
28 | public Main getMainCamel() {
29 | return mainCamel;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/camel/routes/TicketResponseType.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.camel.routes;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 |
6 | import java.util.Arrays;
7 | import java.util.Optional;
8 |
9 | @Getter
10 | @AllArgsConstructor
11 | public enum TicketResponseType {
12 | PROCESO_CORRECTAMENTE(0, "Procesó correctamente"),
13 | EN_PROCESO(98, "En proceso"),
14 | PROCESO_CON_ERRORES(99, "Procesó con errores");
15 |
16 | private final int code;
17 | private final String description;
18 |
19 | public static Optional getFromCode(int code) {
20 | return Arrays.stream(TicketResponseType.values()).filter(f -> f.getCode() == code).findFirst();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/camel/utils/CamelData.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.camel.utils;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 |
7 | import java.util.Map;
8 |
9 | @Data
10 | @Builder
11 | @AllArgsConstructor
12 | public class CamelData {
13 | private Object body;
14 | private Map headers;
15 | }
16 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/company/CompanyCredentials.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.company;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 |
7 | @Data
8 | @Builder
9 | @AllArgsConstructor
10 | public class CompanyCredentials {
11 |
12 | private final String username;
13 | private final String password;
14 | private final String clientId;
15 | private final String clientSecret;
16 | private final String token;
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/company/CompanyURLs.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.company;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 |
7 | @Data
8 | @Builder
9 | @AllArgsConstructor
10 | public class CompanyURLs {
11 |
12 | private final String invoice;
13 | private final String perceptionRetention;
14 | private final String despatch;
15 | }
16 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/files/BillServiceFileAnalyzer.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.files;
2 |
3 | import io.github.project.openubl.xsender.files.xml.XmlContent;
4 | import io.github.project.openubl.xsender.sunat.BillServiceDestination;
5 |
6 | public interface BillServiceFileAnalyzer {
7 | ZipFile getZipFile();
8 |
9 | BillServiceDestination getSendFileDestination();
10 |
11 | BillServiceDestination getVerifyTicketDestination();
12 |
13 | XmlContent getXmlContent();
14 | }
15 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/files/ZipFile.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.files;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 |
7 | @Data
8 | @Builder
9 | @AllArgsConstructor
10 | public class ZipFile {
11 | private final byte[] file;
12 | private final String filename;
13 | }
14 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/files/exceptions/UnsupportedXMLFileException.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.files.exceptions;
2 |
3 | public class UnsupportedXMLFileException extends Exception {
4 |
5 | public UnsupportedXMLFileException(String message) {
6 | super(message);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/files/xml/DocumentType.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.files.xml;
2 |
3 | public class DocumentType {
4 |
5 | public static final String INVOICE = "Invoice";
6 | public static final String CREDIT_NOTE = "CreditNote";
7 | public static final String DEBIT_NOTE = "DebitNote";
8 | public static final String VOIDED_DOCUMENT = "VoidedDocuments";
9 | public static final String SUMMARY_DOCUMENT = "SummaryDocuments";
10 | public static final String PERCEPTION = "Perception";
11 | public static final String RETENTION = "Retention";
12 | public static final String DESPATCH_ADVICE = "DespatchAdvice";
13 | }
14 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/files/xml/XmlContent.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.files.xml;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | @Data
9 | @Builder
10 | @NoArgsConstructor
11 | @AllArgsConstructor
12 | public class XmlContent {
13 |
14 | private String documentType;
15 | private String documentID;
16 | private String ruc;
17 | private String voidedLineDocumentTypeCode;
18 | }
19 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/files/xml/XmlContentProvider.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.files.xml;
2 |
3 | import org.xml.sax.SAXException;
4 |
5 | import javax.xml.parsers.ParserConfigurationException;
6 | import javax.xml.parsers.SAXParser;
7 | import javax.xml.parsers.SAXParserFactory;
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 |
11 | public class XmlContentProvider {
12 |
13 | private XmlContentProvider() {
14 | // Only static methods
15 | }
16 |
17 | public static XmlContent getSunatDocument(InputStream is) throws ParserConfigurationException, SAXException, IOException {
18 | XmlHandler handler = new XmlHandler();
19 |
20 | SAXParserFactory factory = SAXParserFactory.newDefaultInstance();
21 | factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
22 | factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
23 | factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
24 | factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
25 | factory.setNamespaceAware(true);
26 |
27 | SAXParser parser = factory.newSAXParser();
28 | parser.parse(is, handler);
29 |
30 | return handler.getModel();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/models/Metadata.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.models;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 |
7 | import java.util.List;
8 |
9 | @Data
10 | @Builder
11 | @AllArgsConstructor
12 | public class Metadata {
13 | private final Integer responseCode;
14 | private final String description;
15 | private final List notes;
16 | }
17 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/models/Status.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.models;
2 |
3 | public enum Status {
4 | ACEPTADO,
5 | RECHAZADO,
6 | BAJA,
7 | EXCEPCION,
8 | EN_PROCESO,
9 | UNKNOWN;
10 |
11 | public static Status fromCode(int code) {
12 | if (code == 0) {
13 | return Status.ACEPTADO;
14 | } else if (code == 98) {
15 | return Status.EN_PROCESO;
16 | } else if (code == 99) {
17 | return Status.EXCEPCION;
18 | } else if (code >= 100 && code < 2_000) {
19 | return Status.EXCEPCION;
20 | } else if (code >= 2000 && code < 4000) {
21 | return Status.RECHAZADO;
22 | } else if (code >= 4000) {
23 | return Status.ACEPTADO;
24 | } else {
25 | return Status.UNKNOWN;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/models/Sunat.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.models;
2 |
3 | import lombok.Builder;
4 | import lombok.Data;
5 |
6 | @Data
7 | @Builder
8 | public class Sunat {
9 | private String ticket;
10 | private byte[] cdr;
11 | }
12 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/models/SunatResponse.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.models;
2 |
3 | import lombok.Builder;
4 | import lombok.Data;
5 |
6 | @Data
7 | @Builder
8 | public class SunatResponse {
9 | private Status status;
10 | private Metadata metadata;
11 | private Sunat sunat;
12 |
13 | public boolean isTicket() {
14 | return sunat != null && sunat.getTicket() != null;
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/models/rest/ResponseAccessTokenSuccessDto.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.models.rest;
2 |
3 |
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | import java.time.ZonedDateTime;
10 |
11 | @Data
12 | @Builder
13 | @NoArgsConstructor
14 | @AllArgsConstructor
15 | public class ResponseAccessTokenSuccessDto {
16 |
17 | private String access_token;
18 | private int expires_in;
19 | private ZonedDateTime created_in;
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/models/rest/ResponseDocumentErrorDto.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.models.rest;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 | import lombok.Singular;
8 |
9 | import java.util.List;
10 |
11 | @Data
12 | @Builder
13 | @NoArgsConstructor
14 | @AllArgsConstructor
15 | public class ResponseDocumentErrorDto {
16 | private String cod;
17 | private String msg;
18 | private String exc;
19 |
20 | private String status;
21 | private String message;
22 |
23 | @Singular
24 | private List errors;
25 |
26 | @Data
27 | @Builder
28 | @NoArgsConstructor
29 | @AllArgsConstructor
30 | public static class Error {
31 | private String cod;
32 | private String msg;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/models/rest/ResponseDocumentSuccessDto.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.models.rest;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.time.ZonedDateTime;
9 |
10 | @Data
11 | @Builder
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | public class ResponseDocumentSuccessDto {
15 | private String numTicket;
16 | private ZonedDateTime fecRecepcion;
17 |
18 | private String codRespuesta;
19 | private String arcCdr;
20 | private String indCdrGenerado;
21 | private Error error;
22 |
23 | @Data
24 | @Builder
25 | @NoArgsConstructor
26 | @AllArgsConstructor
27 | public static class Error {
28 | private String numError;
29 | private String desError;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/sunat/BillConsultServiceDestination.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.sunat;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.Getter;
7 |
8 | @Data
9 | @Builder
10 | @AllArgsConstructor
11 | public class BillConsultServiceDestination {
12 | private final String url;
13 | private final Operation operation;
14 |
15 | @Getter
16 | @AllArgsConstructor
17 | public enum Operation {
18 | GET_STATUS("getStatus"),
19 | GET_STATUS_CDR("getStatusCdr");
20 |
21 | private final String webMethod;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/sunat/BillServiceDestination.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.sunat;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.Getter;
7 | import org.apache.camel.component.http.HttpMethods;
8 |
9 | @Data
10 | @Builder
11 | @AllArgsConstructor
12 | public class BillServiceDestination {
13 | private final String url;
14 | private final SoapOperation soapOperation;
15 | private final RestOperation restOperation;
16 |
17 | @Getter
18 | @AllArgsConstructor
19 | public enum SoapOperation {
20 | SEND_BILL("sendBill"),
21 | SEND_SUMMARY("sendSummary"),
22 | SEND_PACK("sendPack"),
23 | GET_STATUS("getStatus");
24 |
25 | private final String webMethod;
26 | }
27 |
28 | @Getter
29 | @AllArgsConstructor
30 | public enum RestOperation {
31 | SEND_DOCUMENT(HttpMethods.POST, "/comprobantes"),
32 | VERIFY_TICKET(HttpMethods.GET, "/comprobantes/envios");
33 |
34 | private final HttpMethods method;
35 | private final String path;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/sunat/BillValidServiceDestination.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.sunat;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 |
7 | @Data
8 | @Builder
9 | @AllArgsConstructor
10 | public class BillValidServiceDestination {
11 | private final String url;
12 | }
13 |
--------------------------------------------------------------------------------
/xsender/core/src/main/java/io/github/project/openubl/xsender/sunat/catalog/Catalog1.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.sunat.catalog;
2 |
3 | import java.util.Optional;
4 | import java.util.stream.Stream;
5 |
6 | public enum Catalog1 {
7 | FACTURA("01"),
8 | BOLETA("03"),
9 | NOTA_CREDITO("07"),
10 | NOTA_DEBITO("08"),
11 | GUIA_REMISION_REMITENTE("09"),
12 | TICKET_MAQUINA_REGISTRADORA("12"),
13 | DOCUMENTOS_FINANCIEROS("13"),
14 | DOCUMENTOS_AFP("18"),
15 | GUIA_REMISION_TRANSPORTISTA("31"),
16 | COMPROBANTE_PAGO_SEAE("56"),
17 | GUIA_REMISION_REMITENTE_COMPLEMENTARIA("71"),
18 | GUIA_REMISION_TRANSPORTISTA_COMPLEMENTARIA("72"),
19 |
20 | RETENCION("20"),
21 | PERCEPCION("40"),
22 | PERCEPCION_VENTA_INTERNA("21");
23 |
24 | private final String code;
25 |
26 | Catalog1(String code) {
27 | this.code = code;
28 | }
29 |
30 | public String getCode() {
31 | return code;
32 | }
33 |
34 | public static Optional valueOfCode(String code) {
35 | return Stream.of(Catalog1.values()).filter(p -> p.getCode().equals(code)).findFirst();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/xsender/core/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # to configure camel main
2 | # https://camel.apache.org/components/next/others/main.html
3 | camel.main.name=XSenderCamel
4 | enableLoggingFeature=false
--------------------------------------------------------------------------------
/xsender/core/src/test/java/io/github/project/openubl/xsender/sunat/catalog/Catalog1Test.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.xsender.sunat.catalog;
2 |
3 | import org.junit.jupiter.api.Test;
4 |
5 | import java.util.Optional;
6 |
7 | import static org.junit.jupiter.api.Assertions.assertEquals;
8 | import static org.junit.jupiter.api.Assertions.assertFalse;
9 | import static org.junit.jupiter.api.Assertions.assertTrue;
10 |
11 | public class Catalog1Test {
12 |
13 | @Test
14 | public void givenValidCodeShouldReturnEnumValue() {
15 | Optional result = Catalog1.valueOfCode("01");
16 |
17 | assertTrue(result.isPresent());
18 | assertEquals(Catalog1.FACTURA, result.get());
19 | }
20 |
21 | @Test
22 | public void givenInvalidCodeShouldReturnEmptyValue() {
23 | Optional result = Catalog1.valueOfCode("010");
24 |
25 | assertFalse(result.isPresent());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/xsender/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 |
7 | io.github.project-openubl
8 | xhandler-parent
9 | 5.0.3-SNAPSHOT
10 | ../pom.xml
11 |
12 |
13 | xsender-parent
14 | XSender - Parent
15 | Java library for sending XML files to SUNAT
16 | pom
17 |
18 |
19 | core
20 | quarkus-extension
21 | spring-boot-extension
22 |
23 |
24 |
--------------------------------------------------------------------------------
/xsender/quarkus-extension/deployment/src/test/java/io/github/project/openubl/quarkus/xsender/test/QuarkusXsenderDevModeTest.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.quarkus.xsender.test;
2 |
3 | import io.quarkus.test.QuarkusDevModeTest;
4 | import org.jboss.shrinkwrap.api.ShrinkWrap;
5 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
6 | import org.junit.jupiter.api.Assertions;
7 | import org.junit.jupiter.api.Test;
8 | import org.junit.jupiter.api.extension.RegisterExtension;
9 |
10 | public class QuarkusXsenderDevModeTest {
11 |
12 | // Start hot reload (DevMode) test with your extension loaded
13 | @RegisterExtension
14 | static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest()
15 | .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
16 |
17 | @Test
18 | public void writeYourOwnDevModeTest() {
19 | // Write your dev mode tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-hot-reload for more information
20 | Assertions.assertTrue(true, "Add dev mode assertions to " + getClass().getName());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/xsender/quarkus-extension/deployment/src/test/java/io/github/project/openubl/quarkus/xsender/test/QuarkusXsenderTest.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.quarkus.xsender.test;
2 |
3 | import io.quarkus.test.QuarkusUnitTest;
4 | import org.jboss.shrinkwrap.api.ShrinkWrap;
5 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
6 | import org.junit.jupiter.api.Assertions;
7 | import org.junit.jupiter.api.Test;
8 | import org.junit.jupiter.api.extension.RegisterExtension;
9 |
10 | public class QuarkusXsenderTest {
11 |
12 | // Start unit test with your extension loaded
13 | @RegisterExtension
14 | static final QuarkusUnitTest unitTest = new QuarkusUnitTest()
15 | .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
16 |
17 | @Test
18 | public void writeYourOwnUnitTest() {
19 | // Write your unit tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-extensions for more information
20 | Assertions.assertTrue(true, "Add some assertions to " + getClass().getName());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/xsender/quarkus-extension/integration-tests/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | quarkus.cxf.path=/soapservice
2 | quarkus.native.resources.includes=xmls/*.xml
3 | quarkus.xsender.enable-logging-feature=true
--------------------------------------------------------------------------------
/xsender/quarkus-extension/integration-tests/src/test/java/io/github/project/openubl/quarkus/xsender/it/QuarkusSenderResourceIT.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.quarkus.xsender.it;
2 |
3 | import io.quarkus.test.junit.QuarkusIntegrationTest;
4 |
5 | @QuarkusIntegrationTest
6 | public class QuarkusSenderResourceIT extends QuarkusXSenderResourceTest {
7 | }
8 |
--------------------------------------------------------------------------------
/xsender/quarkus-extension/runtime/src/main/java/io/github/project/openubl/quarkus/xsender/XSender.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.quarkus.xsender;
2 |
3 | import io.github.project.openubl.quarkus.xsender.runtime.XSenderConfig;
4 | import io.github.project.openubl.xsender.camel.routes.CxfEndpointConfiguration;
5 | import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
6 |
7 | import jakarta.enterprise.context.ApplicationScoped;
8 | import jakarta.enterprise.inject.Produces;
9 | import jakarta.inject.Inject;
10 | import jakarta.inject.Named;
11 |
12 | public class XSender {
13 |
14 | @Inject
15 | XSenderConfig config;
16 |
17 | @Produces
18 | @ApplicationScoped
19 | @Named("cxfBillServiceEndpoint")
20 | CxfEndpoint produceCxfBillServiceEndpoint() {
21 | return new CxfEndpointConfiguration().cxfBillServiceEndpoint(config.enableLoggingFeature);
22 | }
23 |
24 | @Produces
25 | @ApplicationScoped
26 | @Named("cxfBillConsultServiceEndpoint")
27 | CxfEndpoint produceCxfBillConsultServiceEndpoint() {
28 | return new CxfEndpointConfiguration().cxfBillConsultServiceEndpoint(config.enableLoggingFeature);
29 | }
30 |
31 | @Produces
32 | @ApplicationScoped
33 | @Named("cxfBillValidServiceEndpoint")
34 | CxfEndpoint produceCxfBillValidServiceEndpoint() {
35 | return new CxfEndpointConfiguration().cxfBillValidServiceEndpoint(config.enableLoggingFeature);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/xsender/quarkus-extension/runtime/src/main/java/io/github/project/openubl/quarkus/xsender/runtime/XSenderConfig.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.quarkus.xsender.runtime;
2 |
3 | import io.quarkus.runtime.annotations.ConfigItem;
4 | import io.quarkus.runtime.annotations.ConfigPhase;
5 | import io.quarkus.runtime.annotations.ConfigRoot;
6 |
7 | @ConfigRoot(name = "xsender", phase = ConfigPhase.RUN_TIME)
8 | public class XSenderConfig {
9 |
10 | /**
11 | * Enable logging feature
12 | */
13 | @ConfigItem
14 | public boolean enableLoggingFeature;
15 | }
16 |
--------------------------------------------------------------------------------
/xsender/quarkus-extension/runtime/src/main/resources/META-INF/quarkus-extension.yaml:
--------------------------------------------------------------------------------
1 | name: "Quarkus XSender"
2 | description: "XSender support."
3 | metadata:
4 | keywords:
5 | - quarkus-xsender
6 | - openubl
7 | # guide: ...
8 | categories:
9 | - "miscellaneous"
10 | status: "preview"
11 |
--------------------------------------------------------------------------------
/xsender/spring-boot-extension/integration-tests/src/main/java/io/github/project/openubl/springboot/xsender/it/Application.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.springboot.xsender.it;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.context.annotation.ComponentScan;
6 |
7 | @ComponentScan
8 | @ComponentScan("io.github.project.openubl.spring.xsender.runtime")
9 | @SpringBootApplication
10 | public class Application {
11 |
12 | public static void main(String[] args) {
13 | SpringApplication.run(Application.class, args);
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/xsender/spring-boot-extension/integration-tests/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.xsender.enable-logging-feature=true
2 |
--------------------------------------------------------------------------------
/xsender/spring-boot-extension/runtime/src/main/java/io/github/project/openubl/spring/xsender/runtime/XSenderSpringSetup.java:
--------------------------------------------------------------------------------
1 | package io.github.project.openubl.spring.xsender.runtime;
2 |
3 | import io.github.project.openubl.xsender.camel.routes.CxfEndpointConfiguration;
4 | import io.github.project.openubl.xsender.camel.routes.SunatRouteBuilder;
5 | import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
6 | import org.springframework.beans.factory.annotation.Value;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.context.annotation.Configuration;
9 |
10 | @Configuration
11 | public class XSenderSpringSetup {
12 |
13 | @Value("${spring.xsender.enable-logging-feature:false}")
14 | private boolean enableLoggingFeature;
15 |
16 | @Bean
17 | public SunatRouteBuilder produceSunatRouteBuilder() {
18 | return new SunatRouteBuilder();
19 | }
20 |
21 | @Bean(name = "cxfBillServiceEndpoint")
22 | CxfEndpoint produceCxfBillServiceEndpoint() {
23 | return new CxfEndpointConfiguration().cxfBillServiceEndpoint(enableLoggingFeature);
24 | }
25 |
26 | @Bean(name = "cxfBillConsultServiceEndpoint")
27 | CxfEndpoint produceCxfBillConsultServiceEndpoint() {
28 | return new CxfEndpointConfiguration().cxfBillConsultServiceEndpoint(enableLoggingFeature);
29 | }
30 |
31 | @Bean(name = "cxfBillValidServiceEndpoint")
32 | CxfEndpoint produceCxfBillValidServiceEndpoint() {
33 | return new CxfEndpointConfiguration().cxfBillValidServiceEndpoint(enableLoggingFeature);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------