Java · Track 7 · Tutorial 4 of 5

Drill into an account, and read the cash flow

Go a level deeper: open a statement section into its accounts, and read the cash flow line by line.

You will needThe statements script from Read the profit and loss and the balance sheet.
By the endAccount-level figures for any section, and the cash flow as your reports show it.

1Open a section

Add detail=1 and a section to a statement read, and it answers that section's accounts instead of the sections. Each account carries one figure per month asked for.

Opening a section into its accounts
A detail read opens one section into its accounts, one figure per month.

2Read revenue by account, and the cash flow

Create AccountDetail.java:

AccountDetail.java

// AccountDetail.java - opens the REVENUE section account by account, then reads the cash flow.
import com.fasterxml.jackson.databind.JsonNode;
import java.util.ArrayList;
import java.util.List;

public class AccountDetail {
    public static void main(String[] args) throws Exception {
        JsonNode detail = Brizo.call("GET", "/organisations/" + Brizo.COMPANY_ID
                + "/statements/profit-loss?period=2026-09&number_of_months=3&detail=1&section=REVENUE").body();
        List<String> months = new ArrayList<>();
        detail.path("months").forEach(month -> months.add(month.asText()));
        System.out.println("Revenue by account, " + String.join(", ", months) + ":");
        for (JsonNode account : detail.path("data")) {
            List<String> amounts = new ArrayList<>();
            account.path("movement").forEach(amount -> amounts.add(Brizo.money(amount)));
            System.out.println("  " + account.path("code").asText() + " " + account.path("name").asText() + ": " + String.join(" / ", amounts));
        }

        JsonNode cash = Brizo.call("GET", "/organisations/" + Brizo.COMPANY_ID + "/statements/cash-flow?period=2026-09&is_ytd=1").body();
        System.out.println("\nCash flow, " + cash.path("period").asText() + " (" + cash.path("basis").asText() + "):");
        for (JsonNode line : cash.path("lines")) {
            System.out.println(String.format("  %-40s%s", line.path("title").asText(), Brizo.money(line.path("value"))));
        }
    }
}

3Run it

gradle -q run -Pmain=AccountDetail

Check

First the revenue accounts with a figure for each of the three months, then the cash flow's lines for the year to date. basis says whether you asked for the month or the year to date.

The cash flow, line by line
The cash flow answers each line it prints, in order, for the month or the year to date.

4Good to know

  • The section has to be one of the statement's own: ask the balance sheet for REVENUE and the answer lists the sections it does have.
  • The cash flow's lines and their order come from the group's own cash flow report, so they match what the screen shows.

Want more detail? See the documentation