Java · Track 4 · Tutorial 4 of 4

Read invoices and bills back

Read back what BrizoConsol holds: the month's invoices and bills, with what's still owed on each.

You will needInvoices and bills sent in the earlier tutorials of this track.
By the endA script that reads any month's documents, and finds the ones you need.

1Read September's documents

Create ReadDocuments.java:

ReadDocuments.java

// ReadDocuments.java - reads September's invoices and bills back.
import com.fasterxml.jackson.databind.JsonNode;

public class ReadDocuments {
    public static void main(String[] args) throws Exception {
        for (String kind : new String[] {"invoices", "bills"}) {
            Brizo.Answer answer = Brizo.call("GET", "/organisations/" + Brizo.COMPANY_ID + "/" + kind + "?period=2026-09");
            System.out.println(Character.toUpperCase(kind.charAt(0)) + kind.substring(1) + ":");
            for (JsonNode document : answer.body().path("data")) {
                System.out.println("  " + document.path("number").asText() + "  " + document.path("party").path("name").asText() + "  "
                        + document.path("currency").asText() + " " + Brizo.money(document.path("total"))
                        + "  due " + Brizo.money(document.path("amount_due")) + "  " + document.path("status").asText());
            }
        }
    }
}
What you can ask for, and what comes back
Reading documents back: a month, optionally narrowed, with every document's details and lines.

2Run it

gradle -q run -Pmain=ReadDocuments

Check

Invoices:
  INV-1001  Harbour Trading Pte Ltd  SGD 10,000.00  due 5,000.00  OVERDUE
  INV-1002  Pacific Desk Co  USD 1,000.00  due 1,000.00  OVERDUE
Bills:
  BILL-501  Northwind Furniture Supply  SGD 8,000.00  due 5,000.00  OVERDUE

Each document as you sent it, with its status. Sent after their October due dates, with money still owed, all three read OVERDUE.

Status reflects the day they were sent
The status was worked out when each document was sent: money still owed, due date passed.

3Narrow it down

  • status=OVERDUE - only documents in that state.
  • account_code=4000 - documents with a line on that account.
  • external_id=INV-1001 - one document. An identity the company doesn't hold answers 404.

Want more detail? See the documentation