Skip to content

Latest commit

History

62 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

CIQuality Gate Status

XBuilder

Java library for creating and signing XML files based on UBL standards.

XBuilder can be found in Maven Central

Installation

Maven

Open your pom.xml file and add:

<dependency>
<groupId>io.github.project-openubl</groupId>
<artifactId>xbuilder</artifactId>
<version>1.1.0.Final</version>
</dependency>

Gradle

Open your build.gradle file and add:

compilegroup: 'io.github.project-openubl', name: 'xbuilder', version: '1.1.0.Final'

Supported countries

  • Perú

If you want support for your country please create an issue.

Getting started

XML files can be created from Input Models; for instance:

InvoiceInputModelinput = InvoiceInputModel.Builder.anInvoiceInputModel()
.withSerie("F001")
.withNumero(1)
.withProveedor(ProveedorInputModel.Builder.aProveedorInputModel()
.withRuc("12345678912")
.withRazonSocial("Softgreen S.A.C.")
.build()
)
.withCliente(ClienteInputModel.Builder.aClienteInputModel()
.withNombre("Carlos Feria")
.withNumeroDocumentoIdentidad("12121212121")
.withTipoDocumentoIdentidad(Catalog6.RUC.toString())
.build()
)
.withDetalle(Arrays.asList(
DocumentLineInputModel.Builder.aDocumentLineInputModel()
.withDescripcion("Item1")
.withCantidad(newBigDecimal(10))
.withPrecioUnitario(newBigDecimal(100))
.withUnidadMedida("KGM")
.build(),
DocumentLineInputModel.Builder.aDocumentLineInputModel()
.withDescripcion("Item2")
.withCantidad(newBigDecimal(10))
.withPrecioUnitario(newBigDecimal(100))
.withUnidadMedida("KGM")
.build())
)
.build();
// Process Input and get XMLDocumentWrapper<InvoiceOutputModel> result = DocumentFacade.createXML(input, config, systemClock);
InvoiceOutputModeloutput = result.getOutput();
Stringxml = result.getXml();

Sign XMLs

After you created the xml file you can now sign it:

Stringxml;
StringsignID = "mySignID";
// Get your certificate using the method of your preferenceX509Certificatecertificate;
PrivateKeyprivateKey;
DocumentsignedXML = XMLSigner.signXML(xml, signID, certificate, privateKey);

About

Java library for creating XML files based on UBL standards

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages