Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ mvn verify -f xsender/spring-boot-extension/integration-tests/
make sync CORE=6.0.0-alpha.1 # el núcleo de una versión de xhandler-rust
```

`make sync` copia el núcleo, los modelos (`xbuilder/core/.../xbuilder/models/`) y el corpus de
conformidad (`testdata/conformance/`). No los edites a mano. Una versión solo se publica con el
`make sync` copia el núcleo, los modelos (`xbuilder/core/.../xbuilder/models/`), las respuestas
de SUNAT (`xsender/core/.../xsender/models/answers/`) y el corpus de conformidad
(`testdata/conformance/`). No los edites a mano. Una versión solo se publica con el
núcleo de la versión igual de xhandler-rust: `make verify-core` lo comprueba.
Estos comandos descargan el `core.sh` de xhandler-rust (`xhandler-wasm/core.sh`) del tag del
núcleo; `CORE_SH=<ruta>` usa una copia local, p. ej. al cambiarlo allá.
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The core (xhandler.wasm and its VERSION in xhandler-core, the xbuilder models and
# testdata/conformance) comes from xhandler-rust:
# The core (xhandler.wasm and its VERSION in xhandler-core, the generated xbuilder models and
# xsender answers, and testdata/conformance) comes from xhandler-rust:
#
# make sync CORE=<version> the xhandler-rust v<version> release
# make sync a checkout of xhandler-rust (RUST_REPO), for development
Expand All @@ -14,7 +14,9 @@ WASM := xhandler-core/src/main/wasm/xhandler.wasm
VERSION_FILE := xhandler-core/src/main/resources/io/github/project/openubl/xhandler/core/VERSION
MODELS := xbuilder/core/src/main/java/io/github/project/openubl/xbuilder/models

SYNCED := $(WASM) $(VERSION_FILE) $(MODELS) testdata/conformance
ANSWERS := xsender/core/src/main/java/io/github/project/openubl/xsender/models/answers

SYNCED := $(WASM) $(VERSION_FILE) $(MODELS) $(ANSWERS) testdata/conformance

# core.sh syncs and verifies a released core. It lives in xhandler-rust, next to the release
# format it reads, and is downloaded from the tag of the core at hand (from main for a core
Expand All @@ -33,6 +35,7 @@ sync: dist
cp $(DIST)/xhandler.wasm $(WASM)
cp $(DIST)/VERSION $(VERSION_FILE)
rm -rf $(MODELS) && mkdir -p $(MODELS) && cp $(DIST)/models/java/*.java $(MODELS)/
rm -rf $(ANSWERS) && mkdir -p $(ANSWERS) && cp $(DIST)/models/java/xsender/*.java $(ANSWERS)/
rm -rf testdata/conformance && cp -r $(DIST)/conformance testdata/conformance
$(if $(CORE),rm -rf $(DIST))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.project.openubl.xsender.models;

import io.github.project.openubl.xsender.models.answers.CDR;
import lombok.Builder;
import lombok.Data;

Expand All @@ -9,6 +10,11 @@ public class SunatResponse {
private Status status;
private Metadata metadata;
private Sunat sunat;
/**
* The CDR as the xhandler core read it, with every field it has (e.g.
* {@code documentDescription}); null without CDR
*/
private CDR cdr;

public boolean isTicket() {
return sunat != null && sunat.getTicket() != null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Code generated by xhandler-wasm/codegen.py from xhandler.schema.json. DO NOT EDIT.
package io.github.project.openubl.xsender.models.answers;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* The receipt SUNAT gives back (Constancia de Recepción)
*/
@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class CDR {
/**
* The CDR zip
*/
@JsonProperty("zip")
private byte[] zip;

@JsonProperty("response_code")
private String responseCode;

@JsonProperty("description")
private String description;

@JsonProperty("notes")
private List<String> notes;

/**
* For an accepted guía de remisión, the URL its printed copy's QR code
* must encode; null for other documents
*/
@JsonProperty("document_description")
private String documentDescription;

@JsonProperty("status")
private Status status;

/**
* The ticket status, only when verifying a ticket
*/
@JsonProperty("status_code")
private String statusCode;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Code generated by xhandler-wasm/codegen.py from xhandler.schema.json. DO NOT EDIT.
package io.github.project.openubl.xsender.models.answers;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* The answer of the consult and validation services
*/
@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ConsultResult {
@JsonProperty("status")
private ConsultStatus status;

@JsonProperty("fault")
private Fault fault;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Code generated by xhandler-wasm/codegen.py from xhandler.schema.json. DO NOT EDIT.
package io.github.project.openubl.xsender.models.answers;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* A status of the consult services: e.g. "0001" (accepted) for getStatus, or
* "0" for validaCDPcriterios
*/
@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ConsultStatus {
@JsonProperty("status_code")
private String statusCode;

@JsonProperty("status_message")
private String statusMessage;

/**
* The CDR zip of getStatusCdr
*/
@JsonProperty("cdr_zip")
private byte[] cdrZip;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Code generated by xhandler-wasm/codegen.py from xhandler.schema.json. DO NOT EDIT.
package io.github.project.openubl.xsender.models.answers;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* An error answered by SUNAT
*/
@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Fault {
/**
* SUNAT's code as given: the SOAP faultcode (e.g. "soap-env:Client.0111")
* or the error code of a REST answer (e.g. "1033")
*/
@JsonProperty("code")
private String code;

/**
* The number in `code` (111), when it has one
*/
@JsonProperty("sunat_code")
private Long sunatCode;

/**
* The status of the answer, e.g. 500 for SOAP faults or 422 for REST
* errors
*/
@JsonProperty("http_status")
private Integer httpStatus;

@JsonProperty("message")
private String message;

@JsonProperty("status")
private Status status;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Code generated by xhandler-wasm/codegen.py from xhandler.schema.json. DO NOT EDIT.
package io.github.project.openubl.xsender.models.answers;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* A ticket status without CDR, e.g. "98" (in progress)
*/
@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class NoCDR {
@JsonProperty("status_code")
private String statusCode;

@JsonProperty("status")
private Status status;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Code generated by xhandler-wasm/codegen.py from xhandler.schema.json. DO NOT EDIT.
package io.github.project.openubl.xsender.models.answers;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* The answer to a sent file: a CDR, a ticket to verify later (summaries,
* voided documents, packs, guías) or a fault
*/
@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class SendFileAnswer {
@JsonProperty("cdr")
private CDR cdr;

@JsonProperty("ticket")
private String ticket;

@JsonProperty("fault")
private Fault fault;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Code generated by xhandler-wasm/codegen.py from xhandler.schema.json. DO NOT EDIT.
package io.github.project.openubl.xsender.models.answers;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The SUNAT verdict of a document, from its response code
*/
public enum Status {
@JsonProperty("ACEPTADO")
ACCEPTED,
@JsonProperty("RECHAZADO")
REJECTED,
@JsonProperty("EXCEPCION")
EXCEPTION,
@JsonProperty("EN_PROCESO")
IN_PROGRESS,
@JsonProperty("UNKNOWN")
UNKNOWN
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Code generated by xhandler-wasm/codegen.py from xhandler.schema.json. DO NOT EDIT.
package io.github.project.openubl.xsender.models.answers;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* The answer to a ticket: a CDR, no CDR yet (e.g. in progress) or a fault
*/
@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class VerifyResult {
@JsonProperty("cdr")
private CDR cdr;

@JsonProperty("no_cdr")
private NoCDR noCdr;

@JsonProperty("fault")
private Fault fault;
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public SunatResponse sendFile(BillServiceDestination destination, ZipFile zipFil
"target", Destinations.target(destination),
"file", file(zipFile.getFilename(), zipFile.getFile())
));
return SunatResponses.of(exchange(call, destination.getRestOperation() != null, credentials));
return SunatResponses.send(exchange(call, destination.getRestOperation() != null, credentials));
}

/**
Expand All @@ -105,7 +105,7 @@ public SunatResponse verifyTicket(BillServiceDestination destination, String tic
"target", Destinations.target(destination),
"ticket", ticket
));
return SunatResponses.of(exchange(call, destination.getRestOperation() != null, credentials));
return SunatResponses.verify(exchange(call, destination.getRestOperation() != null, credentials));
}

/**
Expand Down
Loading
Loading