Invoice OCR Java

The java client library supports the invoice API for extracting data from invoices.

Using this sample invoice below, we are going to illustrate how to extract the data that we want using the client library.
sample invoicesample invoice

Quick Start


// Init a new client
Client mindeeClient = new Client("<YOUR_MINDEE_API_KEY>");

// Load a file from disk and parse it
InvoiceResponse invoiceResponse = mindeeClient.loadDocument("./a74eaa5-c8e283b-sample_invoice.jpeg").parse(InvoiceResponse.class);

// Print a summary of the parsed data
logger.info(invoiceResponse.documentSummary());

Output:

-----Invoice data-----
Filename: a74eaa5-c8e283b-sample_invoice.jpeg
Invoice number: 14
Total amount including taxes: 2608.2
Total amount excluding taxes: 2415.0
Invoice date: 2018-09-25
Invoice due date: 2018-09-25
Supplier name: TURNPIKE DESIGNS CO.
Supplier address: 156 University Ave, Toronto ON, Canada M5H 2H7
Customer name: JIRO DOI
Customer company registration: 
Customer address: 1954 Bloon Street West Toronto, ON, M6P 3K9 Canada
Payment details: 
Company numbers: 
Taxes: 193.2 8.0%
Total taxes: 193.2
Locale: en; en; CAD;
----------------------

Extracted Fields

Attributes that will be extracted from the document and available in the InvoiceResponse object:

Invoice Information

Invoice Number

The invoice number for the invoice being processed

  • invoiceNumberof type Field
logger.info(invoiceResponse.getInvoice().getInvoiceNumber().getValue());

Locale

Invoice Date

  • invoiceDate of type Date

Due Date

  • dueDate of type Date

Customer Information

Customer Name

Customer's name

  • customerName of type Field
logger.info(invoiceResponse.getInvoice().getCustomerName().getValue());

Customer Address

Customer's Postal Address

  • customerAddress of type Field
logger.info(invoiceResponse.getInvoice().getCustomerAddress().getValue());

Customer Company Registration

A list with the customers company registration information

  • customerCompanyRegistration of type List< Field >
    The field contains an extraField with a key "type"
invoiceResponse.getInvoice().getCustomerCompanyRegistration().stream()
      .map((registration) -> String.join(":",registration.getExtraFields().get("type"),
        registration.getValue()))
      .forEach(System.out::println);

Supplier Information

Supplier Name

logger.info(invoiceResponse.getInvoice().getSupplier().getValue());

Supplier Address

  • supplierAddress of type Field
logger.info(invoiceResponse.getInvoice().getSupplierAddress().getValue());

Supplier Company Registrations

A list with the supplier's company registration information

invoiceResponse.getInvoice().getCustomerCompanyRegistration().stream()
      .map((registration) -> String.join(":",registration.getExtraFields().get("type"),
        registration.getValue()))
      .forEach(System.out::println);
/// SAMPLE OUTPUT 
//        VAT NUMBER:FR1112323222
//        SIRET:1111111111
//        SIREN:1122221111

Payment Details

A list of the invoice supplier's payment details.

invoiceResponse.getInvoice().getPaymentDetails()
        .stream().map(PaymentDetails::getPaymentDetailsSummary)
        .forEach(System.out::println);

Taxes and Amounts

Taxes

A list of the taxes seen on the invoice

  • taxes of type List < Tax >
invoiceResponse.getInvoice().getTaxes()
      .stream()
      .map(Tax::getTaxSummary)
      .forEach(System.out::println);

Total Tax

The total tax for the invoice

logger.info(invoiceResponse.getInvoice().getTotalTax().getValue());

Total Including Taxes

The total amount including taxes for the invoice

logger.info(invoiceResponse.getInvoice().getTotalIncl().getValue());

Total Excluding Taxes

The total amount excluding taxes for the invoice

logger.info(invoiceResponse.getInvoice().getTotalExcl().getValue());

 

Questions?
Slack Logo IconSlack Logo Icon  Join our Slack


Did this page help you?