Skip to content

Repository files navigation

Sonarcloud StatusRenovate enabledMaven Central

GOBL Java implementation

Early stage functionality

  • parse Invoice from Json file
  • make Invoice signature and save it as an Envelop
  • save Invoice to file
  • load and save JWK keys from/to file
  • Invoice extract from Envelop
  • signature verification when extract document from Envelop (only one signature is supported now)

Current limitation

  • The only possible type of document that can be placed inside a signed Envelope is an Invoice. This decision is dictated by the simplification of implementation at this stage of the project.
  • There is no tax calculation logic
  • and much, much more — so help is more than welcome

Parse Invoice

publicclassMain {
publicstaticvoidmain(String[] args) {
Goblgobl = newGobl();
Invoiceinvoice = gobl.parseInvoice("src/test/resources/invoice.json");
System.out.println(invoice);
}
}

Sign Invoice file

publicclassMain {
publicstaticvoidmain(String[] args) {
Goblgobl = newGobl();
KeySupportkeySupport = newKeySupport();
valkeys = keySupport.generate();
valenvelope = gobl.signInvoice("src/test/resources/invoice.json", keys.privateKey(), UUID.randomUUID());
System.out.println(envelope);
}
}

Sign Invoice with key from file

publicclassMain {
publicstaticvoidmain(String[] args) {
Goblgobl = newGobl();
KeySupportkeySupport = newKeySupport();
Keykey = keySupport.loadKey(Path.of("src/test/resources/id_es256.jwk"));
valenvelope = gobl.signInvoice("src/test/resources/invoice.json", (ECPrivateKey) key, UUID.randomUUID());
System.out.println(envelope);
}
}

Check signature and extract Invoice from Envelope

try{
Filefile = newFile("src/test/resources/invoice-signed.json");
KeySupportkeySupport = newKeySupport();
KeypublicKey = keySupport.loadKey(Path.of("src/test/resources/id_es256.pub.jwk"));
Invoiceinvoice = gobl.extractFromEnvelope(file, Invoice.class, publicKey); // validation OKSystem.out.println(invoice);
} catch (SignatureExceptionex) {
// validation failed
} 

Create and Save Invoice

valinvoice = newInvoice()
.withCode("standard")
.withIssueDate("2024-01-01")
.withCustomer(newParty()
.withName("Company INC")
.withAddresses(List.of(newAddress()
.withCountry("Poland")
.withCode("05-092")
.withStreet("Warszawska")))
.withTaxId(newIdentity()
.withCode("2222222222")
.withCountry("PL"))
).withCustomer(newParty()
.withName("Customer sp. z o.o.")
.withAddresses(List.of(newAddress()
.withCountry("Poland")
.withCode("05-092")
.withStreet("Warszawska")))
.withTaxId(newIdentity()
.withCode("1111111111")
.withCountry("PL"))
).withLines(List.of(newLine()
.withI(1)
.withItem(newItem()
.withName("Myszka")
.withCurrency("PLN")
.withPrice("100"))));
Goblgobl = newGobl();
gobl.saveInvoice(invoice, System.out);

Maven dependency

<dependency>
<groupId>io.alapierre.gobl</groupId>
<artifactId>gobl-core</artifactId>
<version>0.0.2</version>
</dependency>

Build requirements

The project can be built on JDK17+.

Building the API client library requires:

  1. Java 17+
  2. Maven

About

GOBO Java implementation

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages