Openfact Java Client

Openfact Java Client for manage UBl documents

License

License

Categories

Categories

Java Languages CLI User Interface
GroupId

GroupId

org.sistcoop
ArtifactId

ArtifactId

openfact-java-client
Last Version

Last Version

1.1.9
Release Date

Release Date

Type

Type

jar
Description

Description

Openfact Java Client
Openfact Java Client for manage UBl documents
Source Code Management

Source Code Management

https://github.com/openfact/openfact-java-client/tree/master/

Download openfact-java-client

How to add to project

<!-- https://jarcasting.com/artifacts/org.sistcoop/openfact-java-client/ -->
<dependency>
    <groupId>org.sistcoop</groupId>
    <artifactId>openfact-java-client</artifactId>
    <version>1.1.9</version>
</dependency>
// https://jarcasting.com/artifacts/org.sistcoop/openfact-java-client/
implementation 'org.sistcoop:openfact-java-client:1.1.9'
// https://jarcasting.com/artifacts/org.sistcoop/openfact-java-client/
implementation ("org.sistcoop:openfact-java-client:1.1.9")
'org.sistcoop:openfact-java-client:jar:1.1.9'
<dependency org="org.sistcoop" name="openfact-java-client" rev="1.1.9">
  <artifact name="openfact-java-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.sistcoop', module='openfact-java-client', version='1.1.9')
)
libraryDependencies += "org.sistcoop" % "openfact-java-client" % "1.1.9"
[org.sistcoop/openfact-java-client "1.1.9"]

Dependencies

compile (3)

Group / Artifact Type Version
org.jboss.resteasy : resteasy-client jar 3.6.1.Final
org.jboss.resteasy : resteasy-jackson-provider jar 3.6.1.Final
com.fasterxml.jackson.core : jackson-databind jar 2.9.6

test (2)

Group / Artifact Type Version
org.mockito : mockito-core jar 2.20.1
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

openfact-java-client

Maven users

Add this dependency to your project's POM:

<dependency>
    <groupId>org.sistcoop</groupId>
    <artifactId>openfact-java-client</artifactId>
    <version>${version}</version>
</dependency>

Gradle users

Add this dependency to your project's build file:

compile "org.sistcoop:openfact-java-client:${version}"

Getting Started

Please add the needed dependencies and execute the following Java code:

public class ComprobantesApiExample {

    public static void main(String[] args) {
        String openfactUrl = "http://openfacturl";
        String tokenServerUrl = "http://securityserverutl";
        String refreshToken = "mirefreshtoken";

        TokenManager tokenManager = OpenfactClientFactory.getTokenManager("openfact-web-console", tokenServerUrl, refreshToken);
        DocumentsService service = OpenfactClientFactory.getDocumentsService(openfactUrl, tokenManager);
        OrganizationClient client = new OrganizationClient("miempresa", service);

        DocumentResponseRepresentation invoice = client.createInvoiceAndParseAsEntity(getInvoice(), true);
        System.out.println("Document created:" + invoice.getDocumentId());
    }
    
    public static DocumentRequestRepresentation getInvoice() {
        DocumentRequestRepresentation invoice = new DocumentRequestRepresentation();

        invoice.setFechaDeEmision(new Date());

        invoice.setTipo("01"); // Tipo de Documento (Boleta/factura)
        invoice.setEntidadDenominacion("Juan Perez"); // Nombre del cliente
        invoice.setEntidadEmail("[email protected]"); // Email del cliente
        invoice.setEntidadNumeroDeDocumento("10254125878"); // Numero de documento del cliente (RUC/DNI)
        invoice.setEntidadTipoDeDocumento("6"); // Tipo de Documento del cliente (RUC/DNI)
        invoice.setEnviarAutomaticamenteASunat(true);
        invoice.setEnviarAutomaticamenteAlCliente(true);
        invoice.setIgv(new BigDecimal(18)); // IGV Aplicado a la operacion expresada en porcentaje 18%
        invoice.setMoneda("PEN"); // Moneda nacional
        invoice.setObservaciones("Mis observaciones");

        invoice.setOperacionGratuita(false); // Si la operacion es gratuita
        invoice.setTotalGratuita(BigDecimal.ZERO);

        invoice.setTotalGravada(new BigDecimal(120_100));
        invoice.setTotalExonerada(BigDecimal.ZERO);
        invoice.setTotalInafecta(BigDecimal.ZERO);

        invoice.setTotal(new BigDecimal(141_718));
        invoice.setTotalIgv(new BigDecimal(21_618));
        invoice.setTotalOtrosCargos(BigDecimal.ZERO); // Otros cargos aplicados
        invoice.setDescuentoGlobal(BigDecimal.ZERO); // Descuentos aplicados

        // Detalle de la factura
        List<LineRepresentation> lines = new ArrayList<>();
        LineRepresentation line1 = new LineRepresentation();
        LineRepresentation line2 = new LineRepresentation();    

        line1.setCantidad(new BigDecimal(2));
        line1.setDescripcion("Carro Toyota ultimo modelo");
        line1.setCodigoProducto("CTUM010"); //Codigo del producto yo servicio
        line1.setCodigoSunat("52151504"); //Codigo de producto segun la codificacion de la sunat
        line1.setTipoDeIgv("10"); // Codigo de operacion (Gravado - Operacion Onerosa)
        line1.setValorUnitario(new BigDecimal(60_000)); // Precio unitario sin igv
        line1.setIgv(new BigDecimal(21_600)); // Igv aplicado al item
        line1.setPrecioUnitario(new BigDecimal(70_800)); // Precio unitario con igv
        line1.setSubtotal(new BigDecimal(120_000)); // Subtotal sin igv
        line1.setTotal(new BigDecimal(141_600)); // Subtotal con igv
        lines.add(line1);
        
        line2.setCantidad(new BigDecimal(1));
        line2.setDescripcion("Llanta doble filo original");
        line1.setCodigoProducto("LDFO025"); //Codigo del producto yo servicio
        line1.setCodigoSunat("51121703"); //Codigo de producto segun la codificacion de la sunat
        line2.setTipoDeIgv("10"); // Codigo de operacion (Gravado - Operacion Onerosa)
        line2.setValorUnitario(new BigDecimal(100)); // Precio unitario sin igv
        line2.setIgv(new BigDecimal(18)); // Igv aplicado al item
        line2.setPrecioUnitario(new BigDecimal(118)); // Precio unitario con igv
        line2.setSubtotal(new BigDecimal(100)); // Subtotal sin igv
        line2.setTotal(new BigDecimal(118)); // Subtotal con igv
        lines.add(line2);
        invoice.setDetalle(lines);
        return invoice;
    }
}

Documentation for API Endpoints

All URIs are relative to https://localhost:8080/api

Class Method HTTP request Description
ComprobantesApi createCreditNote POST /admin/organizations/{organization}/sunat/documents/credit-notes Crear Nota de Crédito
ComprobantesApi createDebitNote POST /admin/organizations/{organization}/sunat/documents/debit-notes Crear Nota de Débito
ComprobantesApi createInvoice POST /admin/organizations/{organization}/sunat/documents/invoices Crear boleta/factura
ComprobantesApi createPerception POST /admin/organizations/{organization}/sunat/documents/perceptions Crear Percepción
ComprobantesApi createRetention POST /admin/organizations/{organization}/sunat/documents/retentions Crear Retención
ComprobantesApi createVoidedDocument POST /admin/organizations/{organization}/sunat/documents/voided-documents Crear VoidedDocument
ComprobantesApi getCdr GET /admin/organizations/{organization}/sunat/documents/{id}/cdr
ComprobantesApi getDocumentById GET /admin/organizations/{organization}/documents/{id} Obtener comprobante

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

keycloak

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

Recommendation

It's recommended to create an instance of OrganizationClient per thread in a multithreaded environment to avoid any potential issues.

org.sistcoop

openfact

Versions

Version
1.1.9
1.1.5
1.1.2
1.1.1.Final
1.1.0.Final
1.0.8.Final
1.0.7.Final
1.0.6.Final
1.0.5.Final
1.0.4.Final
1.0.3.Final
1.0.2.Final
1.0.1.Final
1.0.0.Final